shoehive
Version:
WebSocket-based multiplayer game framework for real-time, event-driven gameplay
88 lines (87 loc) • 2.44 kB
TypeScript
import { Card } from './types';
import { Deck } from './Deck';
/**
* A hand of [Card](/api/interfaces/card/)s.
*
* ✅ Attribute Support
*
* This class manages a player's hand of cards, including their cards and attributes.
* It provides methods for adding and removing cards, clearing the hand, and managing hand attributes.
*/
export declare class Hand {
private cards;
private id;
private attributes;
constructor(id?: string);
/**
* Adds a card to the hand.
*
* @param card The card to add.
*/
addCard(card: Card): void;
/**
* Removes a card from the hand.
*
* @param index The index of the card to remove.
* @returns The removed card or null if the index is out of bounds.
*/
removeCard(index: number): Card | null;
/**
* Gets all cards in the hand.
*
* @returns A copy of the cards in the hand.
*/
getCards(): Card[];
/**
* Gets all visible cards in the hand.
*
* @returns A copy of the visible cards in the hand.
*/
getVisibleCards(): Card[];
/**
* Gets all hidden cards in the hand.
*
* @returns A copy of the hidden cards in the hand.
*/
getHiddenCards(): Card[];
/**
* Clears the hand.
*
* @param deck Optional deck to discard cards to when clearing the hand
*/
clear(deck?: Deck): void;
/**
* Gets the ID of the hand.
*
* @returns The ID of the hand.
*/
getId(): string;
/**
* Sets an attribute on the hand.
*
* @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 hand.
*
* @param key The key of the attribute to get.
* @returns The value of the attribute or null if the attribute does not exist.
*/
getAttribute(key: string): any;
/**
* Checks if the hand has an attribute.
*
* @param key The key of the attribute to check.
* @returns True if the attribute exists, false otherwise.
*/
hasAttribute(key: string): boolean;
/**
* Returns a representation of the hand that is safe to send to clients.
* Only includes visible cards and attributes.
*
* @returns A representation of the hand that is safe to send to clients.
*/
getVisibleState(): any;
}