TapIn Pokémon

Battle events

How a battle travels over the socket, turn by turn.

A battle is a short conversation between the client and the server.

Lifecycle

  1. The server sends encounter (a wild battle, with display set to fullscreen or panel) or battle-start (every other kind) with a BattleView. When the battle has a turn timer, deadline is the Unix time in milliseconds when the turn ends.

  2. The client sends battle-action with the battleId, the current turn and one BattleAction:

    { "t": "battle-action", "battleId": "…", "turn": 3, "action": { "kind": "move", "slot": 0 } }

    Actions are move (slot 0 to 3), switch (party index), item (item id, target party index, optional move index), run and forfeit. Only actions listed in the view's legalActions are accepted.

  3. When both sides have chosen (or the timer has run out), the server resolves the turn and sends battle-update with the new BattleView, the turn's events and the next deadline.

  4. The last update is battle-end, with the final events and rewards (money, points, experience, level-ups, new moves, a caught Pokémon, a badge, new Pokédex entries) or null for battles without rewards.

An action for an old turn is rejected with stale-turn; an action when nothing is needed with not-your-turn. Battles are pushed to every open tab of the trainer.

Events

events is an ordered list. Play them back in order to animate the turn; the BattleView that comes with them is the state after the last one.

EventMeaning
turnA new turn number begins.
textA line for the text box, already written ("Wild Rattata used Tackle!").
send-out / withdrawA Pokémon enters or leaves the field.
use-moveA Pokémon uses a move: name and type, for the animation.
missThe move missed.
damageHP lost, new HP, effectiveness, whether it was critical, and the source (move, status, recoil, confusion, Leech Seed, trap, Struggle).
healHP restored.
statusA major status was set or cured.
volatileA volatile effect started or ended (confusion, Leech Seed, Substitute…).
stat-stageA stat stage changed, with the new stage.
faintA Pokémon fainted.
itemAn item was used from the bag.
held-itemA held item or berry activated, and whether it was used up.
ball-throwA ball was thrown: which ball, 0 to 3 shakes, caught or not.
runAn escape attempt and whether it worked.
transformTransform copied another species.
weatherThe weather started, changed or ended.
endThe battle is over, with the winner and the reason.

Every narrative line arrives as a text event, so a client can show the battle with nothing but the text box. The structured events exist for animation and never need to be turned into words.

Reasons a battle ends

faint (one side has no Pokémon left), run, catch, forfeit, timeout, turn-limit (tournament matches after 60 turns, decided by remaining HP) and flee (the wild Pokémon left, for example after Whirlwind or Roar).

TapIn Pokémon is an unofficial fan project. Pokémon and all related names and artwork are trademarks and © of Nintendo, Game Freak and Creatures. Legal

On this page