Added functionality for setAbility to send End events to abilities.
Fixed bug with Mold Breaker negating all Battle#singleEvent ability calls,
even those that don't involve damage calculation.
Fixed Skill Swap to now use End and Start events in the right order:
send the End events, then change the abilities, then send Start events.
If the same ability is swapped, don't send End events (the game simply
re-activates the abilities in question)
Moved SwitchOut/Faint events from weather to ability so the weather
can interact properly with Cloud Nine or Air Lock.
Primal weathers persist if a Pokemon with the relevant ability is
on-field, even if the originator switches out.
- Pokémon affected by Imprison -or Telepathy in NEXT- will now have a special flag 'maybeDisabled' in move requests if they are the last active pokémon.
- If a Pokémon having this flag attacks, the player will not be able to cancel their decision.
- Refactor Battle#parseChoice: Move decisions will now be parsed based on all the moves a pokémon knows after LockedMove, rather than only on validMoves. Any request to use a disabled move or a move with 0 PP will now be replied with a message in the form |callback|cant|[pokemon]|[sourceEffect]|[move], unless the pokémon has no valid moves, in which case it will use Struggle. The check for lockedMove in choice parsing is now performed as the first action after checking that the pokémon is not fainted. This prevents pokémon from Shifting to the center in Triples while being locked into a move.
- Don't report moves' being disabled to the client in requests if they are disabled due to Imprison or Telepathy. Instead, their being disabled will be reported using the mechanism described above.
- Implement BattlePokemon#isLastActive to do the check for whether this is the last non-fainted active pokémon in a team.
- BattlePokemon#tryTrap now accepts an argument that, if true, will hide the fact that a pokémon is trapped.
- This should revert an small (annoying) change in the UI for locked moves introduced as a secondary effect in 8afc588e4.
- NEXT: Shadow Tag shouldn't activate the 'maybeTrapped' flag after the suspected Shadow Tagger has made a move.
- Implement BattlePokemon#runEffectiveness, accounting for battle events.
- Refactor Tools#getEffectiveness accordingly.
- Remove Inverse mod. It's now implemented using the global event 'Effectiveness', and with a few changes in the base data for hazards and Arena Trap.
- NEXT: Fix Filter and Solid Rock not accounting for the special effects of Freeze Dry and Flying Press.
The noAssist table wasn't working because of a bug in ae6da14ca0
namely that the .moves array wasn't toId'd.
Come to think of it, there's no reason for .moves to exist at
all anymore. We should probably just refactor it out.
`|split` order used to be p1/p2/spectator/replay. It is now
spectator/p1/p2/replay.
Since the spectator version is the default, it makes a lot more
sense to have the default in index 0 (and more importantly
prepares it for an upcoming refactor).
The model is now:
- Gen 1: fainting ends the turn
- Gen 2-3: fainted mon is immediately switched, and the turn continues
- Gen 4-6: fainted mon is switched at the end of the turn
JSHint is now a fair bit stricter, and is now correctly checking
files in `mods/`.
The code has been fixed to match the new stricter standards.
JSHint has now caught its second actual bug: Gen 5 Pinap Berry
was Ice instead of Grass.
I used a hack to make the multiple declaration errors go away,
so all that remained in jsHint were actual errors, which I've
now mostly fixed.
All this linting ended up uncovering one actual bug: Uproar's
message not showing. It's a very minor bug in a move no one uses,
so I'm going to fold it into this commit.
This happens in Doubles or Triples if, in a single turn, more pokemon faint than can switch in.
This commit introduces two changes. Namely:
- If more pokemon faint in a single turn than can switch in, those with the higher positions now can have switch flags on.
- Passing a switch is now a valid decision that gets added to battle queue with maximum priority and disables the pokemon's switch flag.
As a side effect, this also allows running the battle engine in JS strict mode.
- Recoil for Parental Bond Double Edge, etc should happen after all the hits have finished.
- Also removed the event 'Secondary', currently unused in the codebase.
This has been overlooked for a while.
Directly calling sugar.js strings' escapeHTML method to avoid further crashes if Tools.escapeHTML is missing for any reason.