Case Battles

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"], // checkout cases api routes doc to show users cases to select and send the selected IDs.
        "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.

  • Payload:

    {
        "gameID": "uuid-string",
        "spot": 1 // Optional: specific spot index
    }

Server -> Client

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

  1. Creation: Validates cases, costs, and user balance.

  2. Bots: If isBot is true, the game automatically fills with bots and starts after creation.

  3. Provably Fair:

    • Generates a serverSeed.

    • Uses a publicSeed

    • Calculates ticket for each slot to determine the item.

  4. 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.

  5. Result:

    • Once all rounds are done, the server calculates the earnings.

    • Determines winner based on gamemode (Standard vs Reversed, Team 2v2).

    • Distributes winnings.

Last updated