Commit Graph

1264 Commits

Author SHA1 Message Date
Kirk Scheibelhut
272700f2b2 Fix crash from Gen 4 Custap Berry + Trump Card interaction (#5395)
Fixes #5393
2019-04-04 01:20:11 +08:00
Slayer95
6384964a10 Sim: Z Moves may only be disabled when all base moves are (#5387) 2019-03-30 18:14:53 -04:00
MacChaeger
b8aa1048e2 Don't display "But it failed!" on a success (#5386) 2019-03-30 15:38:48 -04:00
Kirk Scheibelhut
19bde75842 canZMove should not be set for disabled moves (#5384)
Fixes #5383
2019-03-31 00:24:56 +08:00
Slayer95
694cd47e7b Fix target resolution (#5363) 2019-03-30 22:34:44 +08:00
MacChaeger
5a4578420b Fix attacks failing if only their effect fails (#5373) 2019-03-29 22:48:15 +08:00
MacChaeger
905ed1e95c Fix multihit moves continuing after a KO (#5360) 2019-03-28 19:02:37 +08:00
Ivo Julca
ac4b94876b Sim: Refactor to use Battle#getAllPokemon() and Battle#getAllActive() 2019-03-26 23:18:19 -05:00
MacChaeger
6adc779a19 Fix doubled recoil (#5358) 2019-03-27 11:15:57 +08:00
MacChaeger
9a7ce3dedf Put side conditions on p1 and p2 in multi battles (#5341) 2019-03-27 11:00:36 +08:00
MacChaeger
860900ac57 Fix AfterDamage event running on secondary effects (#5350) 2019-03-26 15:29:46 +09:00
Kirk Scheibelhut
9f5a727ad1 Pull Field out of Battle (#5333) 2019-03-23 02:52:12 +09:00
MacChaeger
a44f16c6e3 Fix pivot moves vs. Substitute (#5314) 2019-03-19 11:50:27 +09:00
MacChaeger
6c486409f4 Fix spread move effect order (#5216) 2019-03-17 23:30:08 +09:00
Guangcong Luo
125ffcc633 Add NOT_FAIL, FAIL, SILENT_FAIL to battle
This replaces battle.NOT_FAILURE. The others aren't used anywhere yet,
but should in theory provide more readability than `null` and `false`.
2019-03-13 11:25:23 +09:00
Kirk Scheibelhut
a8903d2563 Cleanup stat naming and types (storedStats, StatNameExceptHP) (#5274) 2019-03-09 09:53:11 -06: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
MacChaeger
2a60ad7589 Fix stomping tantrum vs. only Protect (#5081) 2019-01-15 22:03:54 -06:00
Russell Jones
d35aeb0b23 Trying another fix for Fake Out (#5103) 2019-01-14 09:52:04 -06:00
MacChaeger
313d7f8621 Submoves lose their inherent Mold-Breaking properties, if any (#5049) 2018-12-27 11:08:51 -08:00
urkerab
23bf166b61 Use -fail instead of -notarget in Gen 5 or later (#5033) 2018-12-16 13:57:03 -06:00
Alexander B
337534e290 Fix Roar failure message (#5031) 2018-12-16 11:28:18 -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
Guangcong Luo
c752b327ca Fix no-target charge moves 2018-11-27 23:25:29 -06:00
urkerab
5d259fe6ac Fix charge moves without target (#4974) 2018-11-19 17:09:56 -06:00
Guangcong Luo
3a8add5c4b Remove [msg] parameter of -immune
(It's unnecessary, being the default message for it.)
2018-11-10 12:31:21 -06:00
Alexander B
34c3096d6b "But it failed!" messages should not reveal the target (#4944) 2018-11-01 09:41:04 -04:00
Guangcong Luo
24571ea603 Fix misc errors found by LGTM 2018-10-28 05:04:30 -05:00
Guangcong Luo
e3ebf2b3c1 Fix Z-caller Weather Ball interaction 2018-10-11 12:54:45 -05:00
Guangcong Luo
affcad7873 Improve documentation of isZ vs isZPowered
move.zPowered is renamed move.isZPowered. It's now documented in JSDoc
exactly how it differs from move.isZ.

This commit includes several minor refactors to Z-move mechanics,
including a bug fix: Z-boosted called Weather Ball is now correctly
typed.
2018-10-10 18:44:05 -05:00
Guangcong Luo
ecb27edb4d
Introduce ActiveMove; make some types read-only (#4902)
The types Template, Move, Ability, and Item are now read-only. This
should guard against accidental writing to types that shouldn't be
written to.

A new type, ActiveMove, has been introduced. Like it sounds, it's
used for moves that are currently actively being used. A lot of
attributes that are only relevant to active moves, such as
`hasBounced`, are now only available on ActiveMove, not on Move.
ActiveMoves are mutable, unlike Moves.

getMoveCopy has been renamed getActiveMove, to better reflect its
role. `isCopy` has been deprecated, and distinguishing Moves from
ActiveMoves is now done by `typeof move.hit === 'number'` where
necessary.

ActiveMoves now internally track which hit of a multihit move
they're on, in move.hit, so move.hit doesn't need to be manually
incremented by Triple Kick and Parental Bond anymore.

move.hasParentalBond has been replaced by a more generic
move.multihitType.
2018-10-10 16:04:35 -05:00
Quinton Lee
94016f6218 Update Typescript to 3.1 (#4879) 2018-10-05 04:02:54 -05:00
Marty-D
8e4f83778f Gen VI-VII: Update breaking protection 2018-09-24 13:56:59 -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
urkerab
62911d3035 Make Dancer copy the called Dance move (#4807) 2018-08-12 21:15:02 -04:00
MacChaeger
82c792f82c Update to TypeScript 3.0.1 (#4710) 2018-08-07 03:27:28 +09:00
Marty-D
538ac5ca55 Fix protection interaction with Z-Powered Z-Moves 2018-06-30 16:34:35 -04:00
Marty-D
d46abff4da
Make sure AfterMove effects use the correct move 2018-06-27 15:41:30 +00:00
MacChaeger
08ba5bc831 Make formeChange handle relevant messages and ability changes (#4654) 2018-05-23 19:55:05 -04:00
MacChaeger
1be208916a Improve Stomping Tantrum interaction with Protect (#4680) 2018-05-21 22:39:30 -04:00
Marty-D
2ab375f3cc Implement Truant correctly 2018-05-17 20:31:19 -04:00
MacChaeger
3b54f1d0c1 Fix Baton Pass fail message (#4637) 2018-05-02 18:47:54 -05:00
Guangcong Luo
8636ab1840 Remove eslint no-undef-init rule 2018-04-27 22:03:00 -05:00
MacChaeger
c6806c84ff Fix Defog and Splash-likes being erroneously counted as failures (#4627) 2018-04-27 21:59:52 -05:00
MacChaeger
711a0d4ce4 Check semi-invulnerability before immunities (#4574) 2018-04-14 10:27:45 -04:00
Ivo Julca
da4a8b72ce Fix: Preserve pranksterBoosted for Status moves overriden into other moves
So if a Prankster-mon chooses in two successive turns an attacking move and an Status move,
and this Pokémon is encored into the attacking move before the Status move proceeds,
the attacking move will be used and it won't affect a Dark-type target.
2018-04-06 05:09:47 -05:00
MacChaeger
054c545c05 Fix Prankster interaction with bounced/encored moves (#4533) 2018-04-01 22:23:43 -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
81208685d1 Refactor some code to use sample
Mechanically refactor code which uses PRNG#random to calculate a random
array index to use PRNG#sample instead.
2018-03-12 05:53:33 +09:00
urkerab
46f3683a3a Fix Z-Power behaviour while Transformed into Ultra (#4479) 2018-03-11 00:01:50 +08: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
Marty-D
055666dc02 Fix recoil damage source 2018-02-16 22:02:35 -05:00
urkerab
30cd0b4125 Make Pressure work in Shared Power (#4398) 2018-02-02 23:15:05 -05:00
urkerab
ef005d3076 Fix Protective Pads interaction with Spectral Thief (#4389)
Specifically, stat boosts gained are from the user, not the target.
2018-01-30 14:46:11 -05:00
urkerab
396fda7adf Fix Z-Power interaction with called Status moves (#4291)
Latest research (http://www.smogon.com/forums/posts/7625046/) shows that although Z-Synthesis bypasses Heal Block, using Z-Copycat to copy Synthesis does not. (Z-Copycat on a damaging move does of course turn into a damaging Z-Move.)
2018-01-17 08:57:37 -05:00
Marty-D
2c9f8ba45f Fix multi-hit Mind Blown again
Went missing in
801883c53a
2017-12-19 09:51:40 -05:00
Marty-D
3ff22dcf2f
Fix Mega Evolution behaviour 2017-12-14 12:43:39 -05:00
MacChaeger
8d571be74e Fix certain Abilities not being overwritten by most forme changes (#4245) 2017-12-14 11:45:12 -05:00
MacChaeger
fae30ca078 Dancer shouldn't activate after the battle has ended (#4240) 2017-12-11 16:21:01 -05:00
urkerab
dc3945ff86 Protect should not affect Clangorous Soulblaze's other target (#4237)
Closes #4232
2017-12-11 09:02:24 -05:00
Guangcong Luo
958c5087fc Revert "Protect should not affect Clangorous Soulblaze's other target (#4230)"
This reverts commit e8a7fa98d5.
2017-12-10 02:26:29 -05:00
urkerab
e8a7fa98d5 Protect should not affect Clangorous Soulblaze's other target (#4230) 2017-12-09 21:09:11 -06:00
MacChaeger
801883c53a Implement Stomping Tantrum (#4175) 2017-12-07 18:36:19 -06:00
Guangcong Luo
53ee56ff3b Fix Mega Rayquaza mega evolution 2017-12-06 20:09:13 -06:00
Marty-D
f443d1a213
Fix Mega Evolution for Rayquaza 2017-12-06 17:57:10 -05: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
08d079037d Pass source effect of switches to client
We are now tracking source effects for switch actions, if they're
initiated by effects such as U-turn or Baton Pass. This will lead
to better messages client-side.
2017-12-04 19:14:13 -06:00
Guangcong Luo
f3dbfbe685 Refactor Decision -> Action
"Decision" and "Choice" were always kind of unclear, so Decision is now
Action. It should now be a lot clearer.

Actions are also now strongly typed.
2017-12-02 11:34:55 -06:00
Guangcong Luo
1ac2745c3e Refactor Pursuit hack
Pursuit no longer uses `moveThisTurn`, but rather `willMove`, which
involves significantly fewer Pursuit hacks.
2017-12-01 15:59:13 -06:00
urkerab
cebac2b5bb Dancer should activate during other two-turn moves (#4186) 2017-11-26 17:13:17 -05:00
Marty-D
f849ea0415 Fix Mind Blown again 2017-11-21 09:32:06 -05:00
Guangcong Luo
cfcbbf19b6 Battles: |-mega| before |detailschange|
This mostly makes the mega evolution message more readable, especially
in Fast replays.
2017-11-21 07:49:05 -05:00
MacChaeger
4d95bb2ed9 Dancer shouldn't copy moves that did nothing (#4101) 2017-11-17 17:41:34 -06:00
Marty-D
33be9cc5a5 Fix spread moves' self-boost behaviour 2017-11-17 18:13:19 -05:00
Marty-D
ee18392b57
Swap Ultra Burst messages 2017-11-17 13:37:50 -05:00
Marty-D
91712024ff Fix Mind Blown behaviour when multi-hit or multi-target 2017-11-17 11:00:58 -05:00
Guangcong Luo
e716e9edc7 Implement Ultra Burst 2017-11-17 00:01:09 -06:00
MacChaeger
06e03e3431 Parting Shot shouldn't switch if it doesn't change stats (#4105) 2017-11-13 22:23:20 -05:00
urkerab
c352ea70b2 Dancer should not activate while semi-invulnerable (#4137) 2017-11-09 22:55:25 -06:00
Guangcong Luo
246dfa1da3 Refactor in-object-literal to array-includes (#4079)
Previously, if we wanted to test if A was either 'B' or 'C', we would use
the pattern:

    A in {B:1, C:1}

I actually don't know how common this pattern is; I just started using
it because I was tired of typing `A === 'B' || A === 'C'` all the time.
I never really liked it, though; the `:1` part made it kind of
blatantly a hack.

I did some testing and `['B', 'C'].includes(A)` is overall faster.

(A switch statement is around 20x faster still, but who wants to type
that much code?)

Anyway, the new standard is

    ['B', 'C'].includes(A)

Something something progress!
2017-10-23 09:19:15 -05:00
Marty-D
934fc5b40d Fix Z-Power behaviour while Transformed into Mega/Primal 2017-10-21 15:04:44 -04:00
Ridaz
8aef13ae18 Update Encore & Fake Out move animations (#4035) 2017-10-03 18:57:05 -05:00
MacChaeger
05cdd33542 Fix Dancer activation order (#4009) 2017-09-23 20:17:00 -04:00
Guangcong Luo
0646743a6d Sim: Check Protect/etc before type immunities in gen 7
TryHit effects, like Protect, Lightningrod, Magic Bounce, etc now
activate before type immunities, rather than after.
2017-09-05 09:36:18 -04:00
Guangcong Luo
6921390955 Fix Z-Instruct
The moves it calls shouldn't be Z-moves.

https://www.youtube.com/watch?v=FRI5PSekhR4
https://www.youtube.com/watch?v=57leF8RuGOg
2017-09-05 06:09:10 -04:00
urkerab
0ed87b755d Remove some ability effects to improve compatibility with Instruct (#3905) 2017-08-23 22:45:54 -07:00
Guangcong Luo
3b4d8b3ff0 Split random-teams.js out of scripts.js
Random team generation scripts are no longer in scripts.js, but instead
in a new file random-teams.js.

The scripts are now also no longer run from inside battles, but in a
new team generator object. This makes it easier for external scripts
to generate random teams by running Dex.generateTeam(format).
2017-07-25 02:59:59 -04:00
The Immortal
d36ba3bf36 Random Battle: Shuffle Pokemon 2017-07-24 17:20:51 +04:00
Guangcong Luo
d79e348ebc Refactor banlistTable -> ruleTable
PS's rule table has been renamed from banlistTable, and works a bit
differently now. It's a Map instead of an object now, and the keys
work a bit differently.

The original banlistTable was designed to store bans, and later
additions shoved rules and then unbans in there. The new table is
designed to support all of these.
2017-07-20 12:50:41 -05:00
HoeenHero
ee0e086c0e Dont use Dex in mods (#3803) 2017-07-19 16:58:18 -05:00
LegoFigure11
a7dbe96127 BSSF: Fix bug where Piloswine is named "Mamoswine" (#3780) 2017-07-14 01:50:00 -10:00
Kevin Lau
24a945efca Random Battle: Add possibility for Fly-Z or Bounce-Z (#3730)
* Random Battle: Add possibility for Fly-Z or Bounce-Z

This involves adding Fly to some Flying Pokemon without a good Flying
STAB. (This also makes sure Fly is not their only STAB, and only exists
with setup.)

* Update scripts.js
2017-07-13 01:42:35 +04:00
Kevin Lau
b167065d53 Random Battle: Update Swanna and Comfey (#3723)
Swanna has no use for Surf if it has Scald, even in Rain sets.

Triage and Draining Kiss should always be together. Give Triage a
rejection condition.
2017-07-05 01:17:00 +04:00
LegoFigure11
b0f82869e0 BSS Factory: Fix Weather restriction and update some sets (#3711)
Set alterations:
* Change SubCM Raikou EV spread from 4 HP / 252 SpA / 252 Spe to 220 HP
/ 52 SpA / 236 Spe
* Change LO Pheromosa from Hasty to Lonely
* Remove Hydro Pump from Scarf Greninja

Scripts alterations:
* Fix Weather restriction
* Remove unused resistance abilities
2017-06-30 20:52:35 +04:00
Kevin Lau
ebbb72d4de Random Battle: Update Armaldo, A-Dugtrio (#3628)
Armaldo is far too slow to utilize Swords Dance well, and only works on
dedicated Rain teams (which are very uncommon in Randoms).

Update item selection for Substitute and Reversal in combination.
2017-06-25 07:15:25 +04:00
Marty-D
88e03486a8 Update Sheer Cold mechanics 2017-06-21 19:25:53 -04:00
Bär Halberkamp
961ffc3f9b Upgrade eslint to 4.x (#3657) 2017-06-18 22:37:43 -07:00
The Immortal
a1348e2f04 Random Battle: Prevent Scarf on weak Pokemon 2017-06-18 18:20:42 +04:00
LegoFigure11
39d8197458 BSSF: Minor Set updates, code cleanup (#3625)
* Magnet Pull Magnzone now gets HP Fire 100% of the time
* Change Ditto's IVs to allow players to know it's Hidden Power at Team
Preview
* Dittos are now Sassy to give a better download matchup in the case of
a 'double down" - mirror matchup remains unchanged
* Removed weather restriction on Chlorophyll to bump up Venusaur usage
* Removed unused weather abilities

Also updated the link to the VR thread in the BSS format description
2017-06-12 19:30:03 +04:00