This fixes its interaction with Clear Smog because Hit handlers for
moves always activate before all other global event handlers.
Removed the Hit event from the list of events stopped by Mold Breaker
variants as there are no abilities that would be negated by it that
use that handler.
The ModifyMove singleEvent for moves always runs before the
larger event that triggers an ability's event handler and
take precedence over Normalize, so we code exceptions in
Normalize to not change the type in those situations.
Conveniently, all the moves that change type right now are
defaulted to Normal-type, and since Normalize technically
won't change the type of any Normal-type move, we're using
that as the guideline for our exception.
BattlePokemon#runImmunity is now two functions, runImmunity and
runStatusImmunity.
The split is helpful because: 1. NegateImmunity only applies to type
immunities, and 2. Immunity only applies to status immunities and
Ground immunities.
Ground immunities are now entirely handled hardcoded in isGrounded.
This overall doesn't have a noticeable impact on performance, but
it makes certain things behave more predictably, and correctly
shows the ability activation for Levitate, so I assume that means it's
a net positive. I hope I at least improved readability...
pokemon.update() used to be called after pretty much everything, but
now that we've refactored pretty much everything out of it, it's no
longer necessary for most of the situations we call it for.
It currently only updates pokemon.speed, so I've renamed it updateSpeed
for clarity.
We now only update pokemon.speed on switch-in, right before the
residual event, and at the beginning of every turn. This gives
something like a 30% speed-up.
- Reverted 6603f97 (fixes interaction with Shield Dust)
- Moved Hit handler that changed the secondaries to ModifyMove for
proper interaction with Serene Grace when terrains are present
- Add behavior in Parental Bond to prevent Secret Power from activating
its secondary on the first hit
Now that nodejs/node#3072 is mostly fixed, we can finally start using
Node 4+ features.
This refactor:
- uses arrow functions where appropriate
Note that arrow functions still aren't used in Mocha, where `this`
is sometimes meaningful.
This also removes the need for .bind() nearly everywhere, as well
as the `self = this` trick.
- refactors Validator and Connection into ES6 classes
- no longer uses Array#forEach for iterating arrays
We strongly prefer for (let i = 0; i < arr.length; i++) because of
performance reasons. Most forEaches have been replaced with for..of,
though, which is 5x slower than the long-form loop but 2x faster
than forEach, which is good enough outside of most inner loops.
The only exception is tournaments, which is due for a more invasive
refactor soon anyway.
In-game, you can see your opponent's pokemon represented as balls, with
statused pokemon being dark balls. Because of this, light balls are
clearly not statused, which allows you to know when a pokemon has
Natural Cure.
The only exception is in Doubles/Triples, where multiple pokemon that
are statused but could have Natural Cure switch out at the same time,
but not all of them have Natural Cure: it's not possible to know which
pokemon had Natural Cure.
This exception is now handled correctly.
Fixes#1452
Since Gen 5, the effects of Thief and Knock Off (among other things)
happen after the target has fainted, so it's possible to remove a
Pokemon with Sticky Hold's item at this point since Abilities don't
'exist' once inactive.
Stat boosts/unboosts caused by abilities now send:
|-ability|POKEMON|ABILITY|boost
|-boost|etc
|-boost|etc
|-unboost|etc
Before, they were pretty inconsistent.
Implemented a new priorityEvent function that is set to abort when any
event handler returns a non-undefined result, unlike runEvent which waits
until all event handlers have run. Set RedirectTarget to use this event.
Changed ability/move priorities for RedirectTarget handlers to fit under
this new paradigm.
Added new Lightning Rod and Storm Drain tests to ensure proper behavior.