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.
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.
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.
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).
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.
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.
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.
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.
- 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.
- 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.