Case Battles involves users opening cases against each other. The user with the highest total item value wins the entire pot (in standard 1v1 mode).
Events
Client -> Server
battles:create
Creates a new battle lobby.
Payload:
{"gamemode":"1v1",// "1v1", "1v1v1", "1v1v1v1", "2v2""cases":["case-id-1","case-id-2"],"isBot":false,// true to fill empty spots with bots"isPrivate":false,"isReversed":false// If true, lowest total wins}
Response (Emits Back): battles:create event with { status: true, gameID: "uuid-string" }, and user is joined to that socket room with roomId as the gameId.
battles:join
Joins an existing battle lobby or adds a bot to a specific spot (if the creator).
Payload:
{"gameID":"uuid-string","spot":1,// Optional: specific spot index"addingBot":false// Optional: true if the creator is adding a bot to 'spot'}
Response (Emits Back): battles:join event with { status: true } or { status: false, message: "..." }.
battles:games
Requests the list of active, public battles.
Payload: None
Response (Emits Back): battles:games event with an array of active game objects, sorted by most recent first. Filters out private games and games with incompatible balance types.
battles:details
Joins the socket room for a specific battle and requests its current details.
Payload:
Response (Emits Back): battles:details event with the public data of the requested game.
battles:sponsor
Allows the creator of a game to pay for (sponsor) a specific spot, allowing another player to join that spot for free.
Payload:
Response (Emits Back): battles:sponsor event with { status: true } or { status: false, message: "..." }. Also broadcasts battles:details to all users in the related game room.
Server -> Client
battles:games
Emitted in response to a client's battles:games request.
Payload:
battles:details
Emitted to the entire room (or directly to a user) whenever a game lobby updates state. This happens when a player joins, a bot is added, details are explicitly requested, or a spot is sponsored.
Payload:
battles:pf
Emitted when the game starts, sharing Provably Fair data.
Payload:
battles:spin
Emitted for every round of opening cases.
Payload:
Game Logic details
Creation: Validates cases, costs, and user balance.
Bots: If isBot is true, the game automatically fills with bots and starts after creation.
Provably Fair:
Generates a serverSeed.
Uses a publicSeed
Calculates ticket for each slot to determine the item.
Spinning:
The server calculates the result for a round.
Emits battles:spin with the target item (via forces index) and the visual pool.
Waits for client animation (approx 4.3s) before processing the next round.
Result:
Once all rounds are done, the server calculates the earnings.
Determines winner based on gamemode (Standard vs Reversed, Team 2v2).
{
"id": "game-id",
"round": 2,
"itemPools": [[...], [...]], // Visual items for the spinner
"forces": [[...], [...]], // The index where the spinner stops
"items": [[...], [...]], // The actual winning items for this round
"status": "in-game",
// ... other game state data
}