Commit Graph

170 Commits

Author SHA1 Message Date
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
Ivo Julca
318ca6ae9f Fix Destiny Bond 2016-11-25 15:38:25 -05:00
Ivo Julca
a0601bdb73 Add MoveAborted event, to be run when move execution stops on BeforeMove 2016-11-25 15:23:52 -05:00
Ivo Julca
a09c0110b8 Destiny Bond: Add tests for exclusive counter and a minimal implementation 2016-11-19 14:17:08 -05:00
Guangcong Luo
8f7d189838 Implement Z-moves 2016-11-18 02:44:29 -05:00
Marty-D
ceca7aaa2d Implement Silvally's type changing
Plus add support for Z-Crystals working with Multitype and Fling powers
with Memories.
2016-11-17 11:06:13 -06:00
Marty-D
18270f72c4 Add burn damage change 2016-11-17 11:06:12 -06:00
Marty-D
52184167b7 Implement new moves 2016-11-17 11:06:12 -06:00
Marty-D
83acbc578d Add preliminary Gen 7 changes 2016-11-17 11:06:12 -06:00
urkerab
74aa31dcf1 Use TryAddVolatile for confusion rather than a custom event (#2641) 2016-08-07 12:11:58 -04:00
Marty-D
98667e8dd5 Correct Wonder Guard message
- Also remove its very unnecessary reimplementation in `futuremove`
2016-06-23 14:34:50 -04:00
Marty-D
5ec02741ff Fix partial-trapping persistence
- Previously, the user could switch out and come back in during the same
turn and have the effect continue.
2016-06-12 14:52:38 -04:00
Guangcong Luo
6eb6c8be55 Fix ability activation for Flame Body etc 2016-02-15 19:48:19 -05:00
Marty-D
b38b43c37e Make sure partial trapping does not happen if the user is inactive 2016-01-08 15:44:33 -05:00
Konrad Borowski
81f602b8d8 Always use trailing comma for multiline objects 2016-01-01 00:20:07 +01:00
Marty-D
235e470553 Merge pull request #2339 from ascriptmaster/trapping
Trapping refactor
2015-12-28 12:10:52 -05:00
Kevin Lau
567b070cda Refactor trapping mechanics out of ModifyPokemon event
Trapping is now checked within Battle#nextTurn as a new TrapPokemon event.
All relevant abilities/items/moves have been adjusted to use it.
2015-12-21 14:56:22 -08:00
Marty-D
82f63b04e3 Fix Infiltrator's interaction with Doom Desire/Future Sight
And correct the Wonder Guard gen check
2015-12-16 12:54:02 -05:00
Guangcong Luo
39281f6995 Fix many bugs in Doom Desire/Future Sight
- Doom Desire/Future Sight now calculate accuracy when hit, not when
  the move is used
- Doom Desire/Future Sight are now limit 1 per defender slot, not 1
  per attacker slot
- Doom Desire/Future Sight in gen 4 and earlier now have their damage
  calculated on use, rather than on hit
- Doom Desire/Future Sight in gen 4 and earlier now deal typeless
  damage, and are not subject to STAB, weakness, resistance, or
  immunity
- Doom Desire/Future Sight in gen 4 and earlier now can't critical
  hit
- Doom Desire is now Physical in gen 3
2015-12-02 00:38:30 -05:00