UNPKG

shoehive

Version:

WebSocket-based multiplayer game framework for real-time, event-driven gameplay

74 lines (73 loc) 2.51 kB
import { Player } from '../../core/Player'; import { ServerTransportModule } from '../ServerTransportModule'; /** * A basic in-memory implementation of the ServerTransportModule. * This is provided as an example and for testing - in a real application, * you would likely connect to an external service or database. */ export declare class BasicServerTransportModule implements ServerTransportModule { private playerBalances; private bets; /** * Get the current balance for a player * @param player The player to check balance for * @returns A promise that resolves to the player's balance */ getPlayerBalance({ player }: { player: Player; }): Promise<number>; /** * Set a player's balance to a specific amount * @param playerId The ID of the player * @param amount The amount to set the balance to */ setPlayerBalance({ playerId, amount }: { playerId: string; amount: number; }): void; /** * Create a bet for a player * @param player The player making the bet * @param amount The amount of the bet * @param metadata Any additional information about the bet * @returns A promise that resolves to a bet ID if successful */ createBet({ player, amount, metadata, }: { player: Player; amount: number; metadata?: Record<string, unknown>; }): Promise<string>; /** * Mark a bet as won and award the player * @param betId The ID of the bet to mark as won * @param winAmount The amount the player won * @param metadata Any additional information about the win * @returns A promise that resolves to true if successful */ markBetWon({ betId, winAmount, metadata, }: { betId: string; winAmount: number; metadata?: Record<string, unknown>; }): Promise<boolean>; /** * Mark a bet as lost * @param betId The ID of the bet to mark as lost * @param metadata Any additional information about the loss * @returns A promise that resolves to true if successful */ markBetLost({ betId, metadata, }: { betId: string; metadata?: Record<string, unknown>; }): Promise<boolean>; /** * Get all bets for a player * @param playerId The ID of the player * @returns An array of bets for the player */ getPlayerBets({ playerId }: { playerId: string; }): Array<{ id: string; bet: unknown; }>; }