shoehive
Version:
WebSocket-based multiplayer game framework for real-time, event-driven gameplay
56 lines (55 loc) • 2.21 kB
TypeScript
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): 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: 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: Player, amount: number, metadata?: Record<string, any>): 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: string, winAmount: number, metadata?: Record<string, any>): 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: string, metadata?: Record<string, any>): 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: string): Array<{
id: string;
bet: any;
}>;
}