UNPKG

shoehive

Version:

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

118 lines (117 loc) 3.42 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 | 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: 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: 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?: 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?: 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: string, value: any): 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: string): any; /** * 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: string): boolean; /** * Gets all attributes from the seat. * * @returns A record of all attributes. */ getAttributes(): Record<string, any>; /** * Sets multiple attributes on the seat. * * @param attributes A record of attributes to set. */ setAttributes(attributes: Record<string, any>): void; /** * Removes an attribute from the seat. * * @param key The key of the attribute to remove. */ removeAttribute(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: string): boolean; }