Skip to main content

Overview

The Side class represents one player’s side in a Pokemon battle. It manages the player’s team, active Pokemon, and side-wide conditions.
// Access sides from battle
const p1 = battle.p1;
const p2 = battle.p2;

Key Properties

Identity

id
SideID
Side identifier: ‘p1’, ‘p2’, ‘p3’, or ‘p4’
name
string
Player name
avatar
string
Player avatar identifier
n
number
Side number (0-3)
foe
Side
The opposing side (in singles)
allySide
Side | null
Allied side in doubles/triples

Team

pokemon
Pokemon[]
Array of all Pokemon on this side
active
Pokemon[]
Array of currently active Pokemon (1-3 depending on format)
pokemonLeft
number
Number of unfainted Pokemon remaining

Side Conditions

sideConditions
{[id: string]: any}
Active side conditions (Stealth Rock, Reflect, etc.)
slotConditions
any[]
Conditions on specific field positions

Battle State

activeRequest
ChoiceRequest | null
Current request for player input
choice
Choice
Parsed player choice
lastMove
Move | null
Last move used by this side

Core Methods

addSideCondition()

Add a side condition like Stealth Rock or Reflect.
side.addSideCondition('stealthrock');
side.addSideCondition('reflect');
status
string
required
Condition ID
source
Pokemon | null
Source Pokemon
effect
Effect | null
Causing effect
return
boolean
True if condition was added successfully

removeSideCondition()

Remove a side condition.
side.removeSideCondition('reflect');

getSideCondition()

Get data for a specific side condition.
const rocks = side.getSideCondition('stealthrock');

addSlotCondition()

Add a condition to a specific field position.
side.addSlotCondition(pokemon, 'futuresight', source);

getChoice()

Get the current parsed choice.
const choice = side.getChoice();

chooseMove()

Make a move choice.
side.chooseMove('thunderbolt'); // Use move by name
side.chooseMove(1); // Use move by slot number
side.chooseMove('move 1 mega'); // Use move and mega evolve
move
string | number
required
Move ID or slot number
targetLoc
number
Target location (for doubles/triples)
megaOrZ
string
‘mega’, ‘zmove’, or ‘ultra’ for special mechanics

chooseSwitch()

Make a switch choice.
side.chooseSwitch(2); // Switch to Pokemon in slot 2
slot
number | string
required
Target Pokemon slot or species name

chooseTeam()

Choose team order during Team Preview.
side.chooseTeam('123456'); // Reorder team
team
string
required
Team order as a string of positions

chooseShift()

Shift the active Pokemon’s position.
side.chooseShift();

clearChoice()

Clear the pending choice.
side.clearChoice();

Request Methods

emitRequest()

Generate and emit a choice request to the player.
side.emitRequest(request);

getRequestData()

Get data for generating a choice request.
const requestData = side.getRequestData();

emitChoiceError()

Send an error message about an invalid choice.
side.emitChoiceError('Invalid move selection');

Utility Methods

isChoiceDone()

Check if the side has made all required choices.
if (side.isChoiceDone()) {
  // Ready to proceed
}

faintedLastTurn()

Check if a Pokemon fainted last turn.
if (side.faintedLastTurn()) {
  // Handle faint logic
}

faintedThisTurn()

Check if a Pokemon fainted this turn.
if (side.faintedThisTurn()) {
  // Replacement needed
}

getTeamPreviewSort()

Get team preview sort order.
const order = side.getTeamPreviewSort();

destroy()

Clean up side resources.
side.destroy();

Choice Request Structure

When a player needs to make a choice, they receive a request:
interface ChoiceRequest {
  requestType: 'move' | 'switch' | 'team';
  active?: ActivePokemon[];
  side?: SidePokemon[];
  forceSwitch?: boolean[];
  wait?: boolean;
}

interface ActivePokemon {
  moves: MoveOption[];
  maybeDisabled?: boolean;
  maybeTrapped?: boolean;
  canMegaEvo?: boolean;
  canZMove?: MoveOption[];
  canDynamax?: boolean;
}

interface MoveOption {
  move: string;
  id: string;
  pp: number;
  maxpp: number;
  target: string;
  disabled?: boolean | string;
}

Example Usage

// Access side
const side = battle.p1;

console.log(`${side.name}'s team:`);
for (const pokemon of side.pokemon) {
  const status = pokemon.fainted ? 'Fainted' : `${pokemon.hp}/${pokemon.maxhp} HP`;
  console.log(`  ${pokemon.name}: ${status}`);
}

// Check active Pokemon
const active = side.active[0];
if (active) {
  console.log(`Active: ${active.name}`);
}

// Check side conditions
if (side.getSideCondition('stealthrock')) {
  console.log('Stealth Rock is active');
}

// Make choices
if (side.activeRequest) {
  if (side.activeRequest.requestType === 'move') {
    side.chooseMove(1); // Use first move
  } else if (side.activeRequest.requestType === 'switch') {
    side.chooseSwitch(2); // Switch to second Pokemon
  }
}

// Count remaining Pokemon
console.log(`Pokemon remaining: ${side.pokemonLeft}`);

Battle

Battle class

Pokemon

Pokemon class

Choice Requests

Request protocol

Battle Protocol

Battle messages

Build docs developers (and LLMs) love