Commit Graph

371 Commits

Author SHA1 Message Date
Guangcong Luo
2d3614f325 Refactor battle.dex out of battle
In most other similar systems, like TeamValidator, we use `thing.dex`
instead of having it extend `ModdedDex`. Battle has always extended
`ModdedDex`, though. This changes Battle to match the others.

This should fix an issue with `Battle.data` not being cached.

This also frees up Battle to extend ObjectReadWriteStream<string> in
a future update.
2019-10-06 04:50:35 +11:00
urkerab
948257cce7 Change weight units to hectograms (#5765) 2019-10-03 14:00:16 +10:00
Kirk Scheibelhut
57dd3b527f Add isPokeball field to Items data (#5644) 2019-07-22 16:20:09 -05:00
Kirk Scheibelhut
a0734bde6f Redo Endless Battle Clause with a new specification (#5472) 2019-05-07 11:18:06 +09:30
Marty-D
75b92ab1dd
Fix Eject Button interaction with U-turn/Volt Switch 2019-04-23 16:50:05 -04:00
Marty-D
80619d62a5
Prevent multiple Eject Button activations from a single attack 2019-04-19 11:38:36 -04:00
Kirk Scheibelhut
0efd71dfef Move Data.ActiveMove methods to Pokemon (#5416)
See #5415 for context - having these methods is unsafe and leads
to crashes because not all ActiveMoves are created through the
Data.ActiveMove constructor. Instead of Pokemon, these could
alternatively be static methods on ActiveMove (or the ActiveMove
class could be completely abolished and reverted back to an
interface), but #5415 will deal with ActiveMove long term, this just
fixes the crashes.
2019-04-06 13:14:50 +08:00
MacChaeger
d3f1161b62 Fix Weakness Policy and Clangorous Soulblaze in doubles (#5389) 2019-04-04 18:51:27 +08:00
Slayer95
628f32e8fb Stricter type definitions for dex data (#5375)
BattleStatuses switched to PureEffectData
2019-03-30 22:31:04 +08:00
Kirk Scheibelhut
9f5a727ad1 Pull Field out of Battle (#5333) 2019-03-23 02:52:12 +09:00
Kirk Scheibelhut
03b2c92cb1 Make isNonstandard specify reason for non-standardness (#5330) 2019-03-22 01:49:22 +09:00
Kirk Scheibelhut
4be90a0a28 Cleanup sim/battle.ts (#5325) 2019-03-22 01:25:12 +09:00
Marty-D
17b3c037e1 Add Bottle Caps 2019-02-16 23:29:01 -05:00
HoeenHero
9c9004cacf Fix "Fix terrain seed activation timing (#5163)"
Shouldn't of reverted this so quickly. Credit to the code goes to @MacChaeger
2019-02-16 20:31:07 -05:00
HoeenHero
f8a1612906
Revert "Fix terrain seed activation timing (#5163)" (#5173)
This reverts commit 250955ee68.
2019-02-16 19:46:53 -05:00
MacChaeger
250955ee68 Fix terrain seed activation timing (#5163) 2019-02-16 19:30:00 -05:00
Konrad Borowski
a97b879e2d Prevent using Leppa Berry from triggering Endless Battle (#5158)
Previously, using Leppa Berry by itself caused Endless Battle Clause
to consider Pokemon to be stale. However, it is reasonable to use
Leppa Berry without an intent to cause an endless battle - for
instance to increase the PP of a move with a low PP.
2019-02-15 17:43:19 -06:00
Guangcong Luo
b498bb222c Require object literal method shorthand 2019-02-11 18:14:09 -06:00
Russell Jones
e4923a08d5 Use more accurate multiplier for Big Root (#5120) 2019-01-25 10:39:58 -05:00
Marty-D
5d06968819 Release Custap, Enigma, Jaboca, Micle, and Rowap Berries 2019-01-08 08:25:57 -05:00
Alexander B
eecde00ed3 Fix Leppa Berry (#5025) 2018-12-14 01:12:41 -06:00
Guangcong Luo
877c9feeeb Fix onEffectiveness event signature
I fixed `onAfterSubDamage` in the previous commit, but this one I left
for later.
2018-12-08 22:52:59 -06:00
Guangcong Luo
c752b327ca Fix no-target charge moves 2018-11-27 23:25:29 -06:00
Guangcong Luo
37a5cf25cc Fix Power Herb animation 2018-11-19 17:20:55 -06:00
Quinton Lee
94016f6218 Update Typescript to 3.1 (#4879) 2018-10-05 04:02:54 -05:00
Guangcong Luo
2c15a1663a
BrightPowder -> Bright Powder
Fixes https://github.com/Zarel/Pokemon-Showdown-Client/issues/1142
2018-09-01 04:09:35 -05:00
Marty-D
21cf8fbab0 Descriptions: Change "Ability [name]" to "[name] Ability" 2018-08-25 12:56:23 -04:00
Marty-D
ac71237de1 Gen II-III: Fix Berry usage timing 2018-08-21 16:36:23 -04:00
MacChaeger
82c792f82c Update to TypeScript 3.0.1 (#4710) 2018-08-07 03:27:28 +09:00
MacChaeger
08ba5bc831 Make formeChange handle relevant messages and ability changes (#4654) 2018-05-23 19:55:05 -04:00
Marty-D
8a6ef0d792 Implement Metronome item slightly less incorrectly
This is still wrong because spamming a Fire attack in Primordial Sea
should not boost damage, but then you run into the problem of boosting
multiple times against multiple targets.
TODO: fix this
2018-05-14 09:50:27 -04:00
Marty-D
d110807efd
Fix Mystery Berry message 2018-05-14 13:31:48 +00:00
Marty-D
f79a889e84
Fix crash in Mystery Berry 2018-05-14 13:24:57 +00:00
Marty-D
2d40904573 Fix some item sprites 2018-04-25 08:50:55 -04:00
Marty-D
e453a772fb Add some miscellaneous items 2018-04-23 21:13:15 -04:00
asgdf
b4a51985d9 Fix Protective Pads throwing errors in valid situations (#4527) 2018-03-29 15:06:21 -04:00
Quinton Lee
c799393710 Typescript data/ and config/formats (#4513)
Also removes Battle Factory methods accidentally re-added in d0a4a689a7
2018-03-26 09:50:51 -05:00
KrisXV
d0a4a689a7 Refactor data/ and mafia.js to for...of (#4490) 2018-03-23 18:51:52 -07:00
Matthew Glazar
6c2350f5b6 Refactor random indexes into sample function
Often, you just need a random item in an array. Throughout Pokemon
Showdown's code, there are many instances of the following pattern:

    let randomThing = things[this.random(things.length)];

Make this code easier to read by factoring the indexing into the
PRNG#sample function:

    let randomThing = this.sample(things);

Run the following sed script to refactor lots of code to use sample:

    s/\([a-zA-Z0-9.]\{1,\}\)\[this\.random(\1\.length)\]/this.sample(\1)/

This commit should not change behaviour. In particular, PRNG#next is
called the same number of times with the same number of parameter as
before this commit, and PRNG#next's results are interpreted in the same
way as before this commit.
2018-03-12 05:53:33 +09:00
Matthew Glazar
45a876917d Refactor random booleans into randomChance function
Often, you just need a random boolean. Throughout Pokemon Showdown's
code, there are many creative ways of requesting random booleans. For
example:

    if (this.random(10) < 3) {
    if (this.isWeather(['sunnyday', 'desolateland']) || this.random(2) === 0) {
    let shiny = !this.random(1024);
    if (uberCount > 1 && this.random(5) >= 1) continue;
    if (!this.random(3)) ability = ability1.name;
    } else if ((ability === 'Iron Barbs' || ability === 'Rough Skin') && this.random(2)) {
    if (typeof secondary.chance === 'undefined' || this.random(256) <= effectChance) {
    if (accuracy !== true && this.random(256) > accuracy) {

Enable these methods to converge by introducing the PRNG#randomChance
function. It accepts a probability and returns true with that
probability.

Run the following sed script to refactor many common patterns to use
randomChance:

    s/this\.random(\([0-9]\{1,\}\)) >= \([0-9]\{1,\}\)/!this.randomChance(\2, \1)/g
    s/this\.random(\([0-9]\{1,\}\)) < \([0-9]\{1,\}\)/this.randomChance(\2, \1)/g
    s/this\.random(\([0-9]\{1,\}\)) === 0/this.randomChance(1, \1)/g
    s/!this\.random(\([0-9]\{1,\}\))/this.randomChance(1, \1)/g

The sed script takes advantage of the following properties:

    random(x) < y     is equivalent to   randomChance(y, x)
    random(x) >= y    is equivalent to   !(random(x) < y), i.e. !randomChance(y, x)
    random(x) === 0   is equivalent to   random(x) < 1, i.e. randomChance(1, x)
    !random(x)        is equivalent to   random(x) === 0, i.e. randomChance(1, x)

This commit should not change behaviour. In particular, PRNG#next is
called the same number of times with the same number of parameter as
before this commit, and PRNG#next's results are interpreted in the same
way as before this commit.
2018-03-08 20:11:33 +09:00
Marty-D
42b3846c6c
Fix Jaboca/Rowap Berry activation 2018-03-08 01:45:47 +00:00
Marty-D
ad27420a1e Update Life Orb's interaction with OHKO moves 2018-01-29 19:46:11 -05:00
urkerab
f0c93655c4 Fix Protective Pads mechanics (#4362) 2018-01-23 11:19:07 -05:00
urkerab
99d682ca26 Change lastMove from a string to a Move (#4298) 2018-01-03 11:54:35 -06:00
urkerab
94efee424d Indicate when an item activates after it is consumed (#3979) 2018-01-01 14:15:32 -06:00
urkerab
2873bd8366 Remove an unused parameter from eatItem and useItem (#4210) 2017-12-23 21:36:51 -06:00
Marty-D
63bec7bf32 Fix source of status for Flame/Toxic Orb
Relevant for Corrosion
2017-12-19 09:53:53 -05:00
MacChaeger
8d571be74e Fix certain Abilities not being overwritten by most forme changes (#4245) 2017-12-14 11:45:12 -05:00
urkerab
2336bd7573 Make Leftovers/Black Sludge recovery happen during Grassy Terrain recovery (#3970) 2017-12-09 23:27:35 -06:00
Guangcong Luo
c0da44c482 Refactor moveset -> moveSlots
pokemon.moveset is now pokemon.moveSlots, which is at least slightly
clearer about what it's doing (tracking move state, mainly PP).

Mostly, this gives a consistent naming scheme for `move` (a Move
object) vs `moveSlot` (a MoveSlot object).

This also refactors a lot of existing `moveSlot` accesses to be modern,
including using `for...of`.
2017-12-05 11:12:44 -06:00