UNPKG

shoehive

Version:

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

141 lines (140 loc) 3.77 kB
import { Player } from './Player'; import { Hand } from './card'; /** * Represents a seat at a table. * * ✅ Attribute Support * * This class manages a player's seat at a table, including their hands and attributes. * It provides methods for setting and getting player information, adding and removing hands, * clearing hands, and managing seat attributes. */ export declare class Seat { private player; private hands; private attributes; /** * Creates a new seat with a main hand by default. */ constructor(); /** * Sets the player for the seat. * * @param player The player to set for the seat. */ setPlayer({ player }: { player: Player | null; }): void; /** * Gets the player for the seat. * * @returns The player for the seat or null if no player is set. */ getPlayer(): Player | null; /** * Adds a hand to the seat. * * @param handId The ID of the hand to add. * @returns True if the hand was added, false if it already exists. */ addHand({ handId }: { handId: string; }): boolean; /** * Removes a hand from the seat. * * @param handId The ID of the hand to remove. * @returns True if the hand was removed, false if it does not exist. */ removeHand({ handId }: { handId: string; }): boolean; /** * Gets a hand from the seat. * * @param handId The ID of the hand to get. * @returns The hand or null if it does not exist. */ getHand({ handId }?: { handId?: string; }): Hand | null; /** * Gets all hands from the seat. * * @returns A map of all hands. */ getAllHands(): Map<string, Hand>; /** * Clears a hand from the seat. * * @param handId The ID of the hand to clear. * @returns True if the hand was cleared, false if it does not exist. */ clearHand({ handId }?: { handId?: string; }): boolean; /** * Clears all hands from the seat. */ clearAllHands(): void; /** * Sets an attribute on the seat. * * @param key The key of the attribute to set. * @param value The value of the attribute to set. */ setAttribute({ key, value }: { key: string; value: unknown; }): void; /** * Gets an attribute from the seat. * * @param key The key of the attribute to get. * @returns The value of the attribute or null if it does not exist. */ getAttribute({ key }: { key: string; }): unknown; /** * Checks if the seat has an attribute. * * @param key The key of the attribute to check. * @returns True if the attribute exists, false otherwise. */ hasAttribute({ key }: { key: string; }): boolean; /** * Gets all attributes from the seat. * * @returns A record of all attributes. */ getAttributes(): Record<string, unknown>; /** * Sets multiple attributes on the seat. * * @param attributes A record of attributes to set. */ setAttributes({ attributes }: { attributes: Record<string, unknown>; }): void; /** * Removes an attribute from the seat. * * @param key The key of the attribute to remove. */ removeAttribute({ key }: { key: string; }): void; /** * Checks if a player can modify a seat. This enforces * that only the player who owns the seat can modify it. * * @param playerId The ID of the player to check. * @returns True if the player can modify the seat, false otherwise. */ canPlayerModify({ playerId }: { playerId: string; }): boolean; }