The heuristic of checking pokemon.lastMove is -in addition to hacky- wrong, as a pokémon can in fact switch-out by "normal methods" after using U-turn and triggering foe's Eject Button.
Replay showing false positive for U-turn : http://replay.pokemonshowdown.com/ou-209269750
To fix this, the message displayed on switch-out POKEMON went back to PLAYER! should rely on a server message.
The heuristic of checking
pokemon.lastMove
is -in addition to hacky- wrong, as a pokémon can in fact switch-out by "normal methods" after using U-turn and triggering foe's Eject Button. Replay showing false positive for U-turn : http://replay.pokemonshowdown.com/ou-209269750To fix this, the message displayed on switch-out
POKEMON went back to PLAYER!
should rely on a server message.Other issues relevant to switching protocol: Zarel/Pokemon-Showdown-Client#314 https://github.com/Zarel/Pokemon-Showdown/issues/1452