Docs/Games/Fight Arena
Games

Fight Arena

Real-time, 1v1 up to 3v3. Architecturally different from every other game documented here — no discrete moves, no turn order. The server runs a fixed-rate simulation; you stream continuous input and receive continuous state.

Real-time tick loop1v1 – 3v3Hosted: socket + REST
If you've only read the turn-based games' pages, don't assume game:move exists here — it doesn't. This game speaks game:input and realtime:snapshot instead, shared with any future real-time game on this platform, not Fight Arena specific event names.

Session creation

json
{ "game": "fight-arena", "matchType": "matchmaking", "players": [{ "id": "user_1" }] }

Team size (1–3 per side, 2 teams) comes from matchConfig at the platform level, not a fight-arena-specific field — see the Sessions page.

Types

ts
interface FightArenaInput {
  moveX: number;   // -1 to 1
  moveY: number;   // -1 to 1
  firing: boolean;
}

interface FightArenaConfig {
  bounds: { width: number; height: number };   // 800×450, fixed
  friendlyFire: boolean;                        // off by default
}

The input/snapshot loop

Send input continuously — every frame, or on every meaningful change. The server ticks at a fixed rate and broadcasts a full state snapshot each tick.

js
// Client → server, as often as your input actually changes
socket.emit('game:input', {
  roomId,
  input: { moveX: 0.8, moveY: 0, firing: true },
});

// Server → client, every tick
socket.on('realtime:snapshot', (state) => {
  // full simulation state — positions, health, everything
  renderFrame(state);
});

Socket events

EventDirectionPayload
fight:startclient → servernone — signals readiness once connected
fight:startedserver → client{ roomId, waiting: boolean }
game:inputclient → server{ roomId, input: FightArenaInput }
realtime:snapshotserver → clientFull state snapshot — sent every server tick, not on demand
game:stateserver → clientSent on discrete state changes, distinct from the per-tick snapshot above
player:hitserver → client{ byId, targetId, damage, targetHealthAfter }
player:disconnectedserver → client{ socketId }
player:reconnectedserver → client{ playerId }
game:reconnectclient → server{ playerId }
game:reconnectedserver → clientFull current simulation state, to rehydrate after reconnecting
game:overserver → clientResult object, same shape as the game.ended webhook

No AFK timeout

Real-time rooms don't run the turn-based AFK system — there's no "turn" to time out. A disconnected player is handled purely through player:disconnected / reconnection, not a forfeit timer.

Hosted matchmaking

Supports hosted matchmaking via both direct socket events and the REST endpoints. One addition specific to Fight Arena's variable team size:

js
socket.emit('hosted:rebalance_pool');
socket.on('hosted:pool_rebalanced', ({ groups }) => { /* ... */ });

Rebalances currently-staged players into valid team groups on demand — useful when players are trickling into a lobby and team sizes aren't fixed in advance.