Previously, battle queue stuff was just strewn around `battle.ts`.
This gives it a new home: `battle-queue.ts`.
This was intended to make `battle.ts` slightly more tractable, although
the difference is so small that maybe I shouldn't bother. Oh, well,
every little bit helps.
This is a really hacky implementation of Emergency Exit, but Emergency
Exit itself is a huge mess on cart, too.
Our previous implementation:
- activated Emergency Exit at AfterMoveSecondary timing for move damage
- activated Emergency Exit immediately after dealing any other damage
This new one:
- activates Emergency Exit only in three situations:
- right after AfterMoveSecondary timing, for move damage
- right after DamagingHit timing, for DamagingHit residual damage
(Rough Skin, Iron Barbs, Rocky Helmet)
- right after the switch update, for switch-hazard residual damage
(Stealth Rock, Spikes)
- does not otherwise activate (so Substitute, Hail, Toxic, etc no
longer activate Emergency Exit)
This should much accurately simulate Emergency Exit behavior, including
most famously timing it after healing berries after hazards, as
documented in:
https://www.smogon.com/forums/threads/pokemon-sun-moon-battle-mechanics-research.3586701/#post-7075354Fixes#6309
Fixes#6346
The `AfterDamage` event has been replaced with `DamagingHit`, which
which happens for damaging moves after secondaries.
The `AfterHit` event has also been moved after `DamagingHit`, to make
sure Knock Off still procs after Rocky Helmet.
`AfterHit` is no longer a valid event on `secondary` and `self` blocks,
because it's meaningless in those blocks, anyway. All `self.onAfterHit`
and `secondary.onAfterHit` handlers have been moved to `onHit`, which
should have the same timing in practice.