Commit Graph

188 Commits

Author SHA1 Message Date
Kirk Scheibelhut
be82a3b817 Move -mustrecharge message to onStart (#5488)
This way it doesn't show up at the end of the turn or get added 3 separate times.

Fixes #5462.
2019-05-08 16:39:56 -04:00
Kirk Scheibelhut
29430984f6 Only add the '-status slp' message in statuses (#5486) 2019-05-08 11:52:44 -04: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
MacChaeger
9a7ce3dedf Put side conditions on p1 and p2 in multi battles (#5341) 2019-03-27 11:00:36 +08:00
Kirk Scheibelhut
9f5a727ad1 Pull Field out of Battle (#5333) 2019-03-23 02:52:12 +09:00
Kirk Scheibelhut
4be90a0a28 Cleanup sim/battle.ts (#5325) 2019-03-22 01:25:12 +09:00
Marty-D
39a8b4270e Fix Stealth Rock effectiveness during Delta Stream 2019-03-16 14:38:03 -04:00
Kirk Scheibelhut
a04d4da992 Add more hints to Gen 1 & 4, migrate others to Battle#hint (#5258) 2019-03-06 11:24:47 -06:00
Guangcong Luo
b498bb222c Require object literal method shorthand 2019-02-11 18:14:09 -06:00
asgdf
9b4c42cc8f Fix partial trapping moves in the statbar after having ended (#5108) 2019-01-15 19:25:46 -06:00
Alexander B
73a158631e Desolate Land activates before Dazzling (#5107) 2019-01-15 11:05:32 -06:00
Guangcong Luo
13614b9890 Update for TypeScript 3.2
TypeScript 3.2 unearthed a metric fuckton of bugs, making this change
take effectively forever.
2018-12-08 21:39:38 -06:00
urkerab
5d259fe6ac Fix charge moves without target (#4974) 2018-11-19 17:09:56 -06:00
Lycanium Z
766508d860 Doom Desire is affected by Adaptability &Normalize (#4975) 2018-11-18 22:11:03 -06:00
Alexander B
34c3096d6b "But it failed!" messages should not reveal the target (#4944) 2018-11-01 09:41:04 -04:00
Marty-D
733ea72d4f Make a move fail if the target is the user and it's not self-target 2018-09-03 11:24:38 -04:00
MacChaeger
84381c2bf2 Arceus/Silvally should have standard type mechanics when transformed (#4700) 2018-08-22 14:19:46 -04:00
littlefoot22
58e9a8923e Fix Rollout / Ice Ball target locking (#4796) 2018-08-07 21:54:35 -04:00
MacChaeger
82c792f82c Update to TypeScript 3.0.1 (#4710) 2018-08-07 03:27:28 +09:00
Marty-D
f259d43987 Fix Nightmare removal properly 2018-06-09 18:17:58 -04:00
Marty-D
ea75aa39dd Fix Nightmare removal 2018-06-08 23:05:20 -04:00
MacChaeger
22ad90d3ff Camomons: Modify the template unless the Pokemon is transforming (#4688) 2018-05-25 19:27:47 -04:00
MacChaeger
08ba5bc831 Make formeChange handle relevant messages and ability changes (#4654) 2018-05-23 19:55:05 -04:00
MacChaeger
e3174ebc02 Fix type display in Gen 7 metas (#4655) 2018-05-21 17:27:23 -05:00
Marty-D
8cb12f547e
Fix Truant interaction with recharge turns 2018-05-18 08:33:59 -04:00
Andi Wang
6621b84efa Gen IV: Fix Disable/Encore interaction with switching effects (#4519)
Specifically, Healing Wish/Lunar Dance/Baton Pass/U-turn.
2018-03-27 22:30:23 -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
Marty-D
5ddfe6e8ae
Fix Instruct's interaction with stalling moves 2018-03-23 10:15:05 -04:00
Marty-D
c678014580
Update Choice locking for USUM
They fixed it so that ignoring the item allows other moves to be used. However, using another move, even one that isn't part of the moveset, before you've locked yourself into a move, locks you into that move until move selection happens again. For example, a Choice Specs Oricorio choosing to use Hurricane turn 1 but getting outsped by a Quiver Dance has it use Quiver Dance, then Hurricane fails (even if it doesn't know Quiver Dance). If it does know Quiver Dance it becomes locked into it, otherwise it can choose any move for use since the Choice lock breaks at move selection if you don't have that move anymore.
2018-03-08 10:44:14 -05:00
Matthew Glazar
df5988bacf Refactor some code to use randomChance
Mechanically refactor code which uses PRNG#random for booleans to use
PRNG#randomChance instead.

Take advantage of the following properties:

    random(x) < y        is equivalent to   randomChance(y, x)
    random(x) <= y       is equivalent to   random(x) < (y + 1), i.e. randomChance(y + 1, x)
    random(x) >= y       is equivalent to   !(random(x) < y), i.e. !randomChance(y, x)
    random(x) > y        is equivalent to   random(x) >= (y + 1), i.e. !randomChance(y + 1, 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)
    Boolean(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
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
MacChaeger
8d571be74e Fix certain Abilities not being overwritten by most forme changes (#4245) 2017-12-14 11:45:12 -05:00
MacChaeger
801883c53a Implement Stomping Tantrum (#4175) 2017-12-07 18:36:19 -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
Guangcong Luo
108eab72f0 Battles: Refactor futuremove
We're now passing a real Move object.
2017-12-01 08:01:11 -06:00
Marty-D
a8413731dd Fix Choice-lock before attempting a move 2017-09-24 12:13:30 -04:00
urkerab
c28347edda Fix choice lock for the combined Pledge move (#3993) 2017-09-17 19:47:35 -04:00
urkerab
0ed87b755d Remove some ability effects to improve compatibility with Instruct (#3905) 2017-08-23 22:45:54 -07:00
Jacob McLemore
51eb475f34 Fix Unaware Confusion interaction (#3530) 2017-06-13 21:40:37 -05:00
Guangcong Luo
6dd58b40d3 Refactor simulator into new sim/ directory
This is a surprisingly minor refactor considering how many files it
touches, but most of this is only renames.

In terms of file renames:
- `tools.js` is now `sim/dex.js`
- `battle-engine.js` is now `sim/index.js` and its three classes are
  in `sim/battle.js`, `sim/side.js`, and `sim/pokemon.js`
- `prng.js` is now `sim/prng.js`

In terms of variable renames:
- `Tools` is now `Dex`
- `BattleEngine` is now `Sim`
- `BattleEngine.Battle` is now `Sim.Battle`
- `BattleEngine.BattleSide` is now `Sim.Side`
- `BattleEngine.BattlePokemon` is now `Sim.Pokemon`
2017-05-05 16:48:38 -05:00
Marty-D
0789cdb4b3 Fix Struggle while Choice-locked 2017-03-07 10:37:37 -05:00
Marty-D
7f96110699 Update Choice-lock mechanics
Presumably because of Dancer's existence, attempting to use another move
besides the Choice-locked move now results in the move being used but
failing immediately, with no PP loss. This applies even during Magic
Room, etc.
2017-03-04 16:23:55 -05:00
Marty-D
3c9d6c2687 Correct crit ratio boosting Z-Effect 2016-12-18 11:06:55 -05:00
urkerab
c1829acf64 Z-Memento and Z-Parting Shot should tell the client about the Z-power (#3029) 2016-12-16 18:23:54 -08:00
Ivo Julca
78972c41f0 Revert "Confusion still has a 50% self-hit chance"
This reverts commit 7d1ee5fecd.

There is even stronger evidence, from a trusted source, that the chance is now 1/3.
https://twitter.com/pokemon_PhD/status/788827888028151808
2016-12-06 23:50:07 -05:00
Ivo Julca
7d1ee5fecd Confusion still has a 50% self-hit chance
Hypothesis of chance=1/3 can be rejected at a 0.0005 significance level.
2016-11-27 19:11:58 -05:00
urkerab
3046638c30 Remove line left over from Destiny Bond fix (#2953) 2016-11-26 17:20:39 -05:00
urkerab
a580d7706f Add various Z-move messages (#2947) 2016-11-25 20:24:35 -05:00