Commit Graph

570 Commits

Author SHA1 Message Date
Ivo Julca
55641c2635 Fix regressions in random team generation and improve comments
The regressions affected information handling
- Seeds used for random teams were no longer being logged.
- The seed used for generating p2's team was also used for the battle itself.
2017-02-24 20:18:59 -05:00
Dan Pantry
56ba782966 refactor PRNG to its own class
This removes the 'deterministic test' tools by preventing action at a
distance (namely, preventing the modification of the `init` method in
`Battle` during tests). This action at a distance is incredibly
confusing.

All this action at a distance did was discard any parameters that were
passed to `Battle` that weren't the first three (which was probably a
mistake by the original author) and also hard code `this.seed` and
`this.startingSeed` in `Battle`.

This functionality has now been moved to the `PRNG` class, so instead
users should pass a `PRNG` to `Battle` as the 5th constructor argument.
Users can also pass one as the third argument to `common.createBattle`
or use `common.createBattleWithPRNG` with the PRNG as the first
argument.

The PRNG is just an encapsulation of the pseudo-random algorithm in a
class. It is stateful, so make sure to take a `clone()` of the PRNG if
you want to re-use it.
2017-02-22 20:44:20 -05:00
Guangcong Luo
2d6bd87c0b Improve Hidden Power validator
Now that we now store Hidden Power type separately from IVs, we can
make some major changes to how Hidden Power is validated.

Instead of Hidden Power type being calculated from the IVs, it's now
sent separately as part of the set. This allows us to warn in the
validator if the Hidden Power type specified by the moveset is
different from the one calculated from the IVs, and give a validation
error if so.

This also allows us to validate the Hidden Power type (pre-bottle-cap
IVs) separately from the set IVs (post-bottle-cap IVs) when doing
event validation, which fixes some validation issues relating to
Hidden Power.
2017-02-22 04:39:03 -06:00
Guangcong Luo
e99104b064 Refactor Hidden Power calculation to Tools
Hidden Power was previously in BattlePokemon's constructor, but it's
been moved to Tools where the calculation can be accessed externally
(relevant for team-validator).
2017-02-22 02:59:51 -06:00
Guangcong Luo
6611c9c9ed Fix Seed activation on double-Surge
Terrain seeds weren't activating correctly on the first Surge of two
Surge ability activations turn 1. This fixes it by allowing Update to
run on inactive Pokémon, allowing a Pokémon's item to activate onUpdate
before their own ability activation.
2017-02-14 22:14:15 -06:00
urkerab
5008d3fecc ModifyPriority should run on the Z move if relevant (#3211) 2017-02-06 20:52:48 -04:00
Marty-D
385394bab4 Fix the first hit's effectiveness against Disguise 2017-01-27 11:05:46 -05:00
Marty-D
54ae472b75 Fix Gem interaction with selfdestruct moves 2017-01-23 20:06:20 -05:00
Marty-D
1200dfa4f4 Update check for Z-Moves against protection 2017-01-09 22:40:15 -05:00
Guangcong Luo
ef3b4965ea Fix Z-move priority interaction
Priority Z-moves exist (namely, Gale Wings Supersonic Skystrike).

Quick Guard now partially protects against priority Z-moves.

Psychic Terrain now fully protects against priority Z-moves.
2017-01-08 01:44:35 -05:00
Marty-D
a96703d19e Fix Klutz interaction with EV items 2017-01-02 20:08:40 -05:00
urkerab
5509ae3ce6 Z-Powered Focus Punch shouldn't have special Focus Punch behaviour (#3057) 2016-12-29 21:14:59 -05:00
Guangcong Luo
bf4e3df3b8 Deprecate decision.targetSide/targetPosition
These are no longer used; we now only use targetLoc.
2016-12-26 17:12:40 -05:00
Guangcong Luo
b931969e11 Fix Z move and target tracking issues
Encore and Disable now fail when used against Z-moves.

Encore and Disable now no longer prevent Z-moves from being used.

Instruct now repeats the selected target location.

Instruct Pursuit now repeats the switched out target location, if
activated.

This refactor also simplifies some previously unnecessarily-complicated
code.
2016-12-26 16:53:10 -05:00
Guangcong Luo
0b887560cd Fix Z-status targeting
Z-status moves weren't targeting correctly. This fixes that and also
simplifies some code.
2016-12-26 16:48:15 -05:00
Guangcong Luo
81ab10d121 Refactor resolvePriority 2016-12-21 20:08:20 -08:00
Guangcong Luo
598da66921 Fix Mega decision priority recalculation 2016-12-21 20:07:33 -08:00
Guangcong Luo
4fc03700fb Fix Mega Pursuit
Previously, if a pokemon mega evolved and used Pursuit, and the foe
switched on the next turn, it would use Pursuit again on the next turn,
in addition to its usual decision.

This is a hack to fix it; a full fix is pending a rewrite of the
decision structure.
2016-12-21 19:37:48 -08:00
urkerab
6167af398a Fainted Pokemon shouldn't be able to use an item (#3035) 2016-12-17 20:02:54 -08:00
Guangcong Luo
1e6b3f5cb1 Fix Hidden Power type detection in VGC 2016-12-15 15:19:49 -08:00
Guangcong Luo
5e7a685e6f Fix crash when fainted Pokemon tries to trap foe 2016-12-06 20:31:06 -06:00
urkerab
77dd7554fb Send residual upkeep message so that pseudo weather updates correctly (#2994) 2016-12-06 12:32:03 -06:00
urkerab
76dd2f9493 Simplify Mold Breaker clones by getting the move to ignore abilities (#2996) 2016-12-06 12:29:39 -06:00
Marty-D
019a139956 Implement Comatose properly 2016-12-03 20:19:18 -05:00
Guangcong Luo
ae6de6b91b Fix zMove target resolving 2016-11-30 03:46:23 -06:00
The Immortal
4e796e3f42 Fix Hidden Power mechanics 2016-11-29 16:29:57 +04:00
Guangcong Luo
83b9e82fc7 Support calling Z moves
Z status moves like Z-Metronome and Z-Nature Power now correctly
transform called Physical/Special moves into the corresponding
Z move.
2016-11-28 20:26:28 -06:00
Ivo Julca
c743797efc Fix targetting of status Z-Moves 2016-11-27 20:15:56 -05:00
Marty-D
f4dda34a08 Update Z-Moves interaction with protection 2016-11-27 11:58:38 -05:00
Ivo Julca
7ea4eeac5b Z-Moves: Various decisions fixes
- Z-Moves are always single-target, even if based on spread moves.
- Z-Moves cannot be selected if the base move has no PP.
- Z-Moves can be selected if the base move is disabled.
2016-11-27 00:27:49 -05:00
Ivo Julca
2604dd1939 Trim megaOrZ argument of BattleSide#chooseMove() 2016-11-27 00:23:19 -05:00
urkerab
a580d7706f Add various Z-move messages (#2947) 2016-11-25 20:24:35 -05:00
Ivo Julca
e45d4bbdac Fix turn order to account for abilities traced by Mega Evolutions 2016-11-24 22:44:27 -05:00
Marty-D
70b7416ce4 Prevent some effects from occurring upon battle completion 2016-11-24 17:03:24 -05:00
Marty-D
35021489ae Support Mold Breaker-resistant Abilities 2016-11-22 17:57:16 -05:00
Kevin Lau
7963c97894 Fix priority issues with Z-Moves (#2930) 2016-11-21 14:32:31 -05:00
urkerab
0e413e3633 Burn Up should change the user's type to ??? if it can (#2897) 2016-11-20 10:22:36 -05:00
Guangcong Luo
f079e50470 Make Battle#random more readable 2016-11-19 22:17:58 -05:00
Ivo Julca
5a537ff9c5 Fix overriding z-move decisions 2016-11-19 17:13:21 -05:00
Marty-D
ac2d5a1cb0 Fix Z-Move PP when in a normal moveslot 2016-11-19 13:55:17 -05:00
Ivo Julca
8d03df9141 Forbid multiple mega and z-moves on the decider level
- This fixes potential issues in Doubles created by the new turn order mechanics.
- Note that this implementation doesn't impact OMs such as Mix and Mega -at least in Singles.
2016-11-18 20:18:57 -05:00
Ivo Julca
bf04094f08 Update BattlePokemon#formeChange to use Tools#spreadModify 2016-11-18 19:26:54 -05:00
Guangcong Luo
4abd4dac39 Remove Z-Move button from locked moves 2016-11-18 17:19:16 -05:00
Guangcong Luo
847373001d Fix Gen 7 Hidden Power 2016-11-18 13:18:20 -05:00
Ivo Julca
ccccd1afa0 Implement Arceus' type-change immunities into Silvally
Tentative, based on http://www.smogon.com/forums/threads/3586701/page-37#post-7089082
2016-11-18 11:47:08 -05:00
Guangcong Luo
5981e2a78b Stub gen 7 Hidden Power implementation 2016-11-18 03:52:42 -05:00
Guangcong Luo
224cf25e46 Fix bugs in Z-moves 2016-11-18 01:46:56 -06:00
Guangcong Luo
8f7d189838 Implement Z-moves 2016-11-18 02:44:29 -05:00
Guangcong Luo
acfeb39e7e Stub Z-move implementation
This is only the |request| half.
2016-11-17 23:41:11 -05:00
Ivo Julca
a1405e9c43 Gen 7: Turn order is decided by the ability and stats of the mega forme 2016-11-17 21:00:48 -05:00