the-game-domain
Version:
Complete domain layer for 'The Game' card game with rich business entities, automatic persistence, action tracking, and advanced game mechanics. Features Game, Player, Card, Deck, Pile entities with repository pattern, turn management, victory/defeat dete
47 lines • 2.31 kB
TypeScript
export type GameActionType = 'GAME_CREATED' | 'CARD_PLAYED' | 'TURN_CHANGED' | 'GAME_FINISHED' | 'GAME_WON' | 'GAME_LOST' | 'CARDS_DRAWN' | 'PLAYER_NAME_CHANGED' | 'GAME_RESTARTED';
export interface IGameActionData {
id: string;
gameId: string;
type: GameActionType;
description: string;
playerId?: string | undefined;
playerName?: string | undefined;
cardValue?: number | undefined;
pileNumber?: number | undefined;
timestamp: Date;
}
export declare class GameAction {
private readonly _id;
private readonly _gameId;
private readonly _type;
private readonly _description;
private readonly _playerId?;
private readonly _playerName?;
private readonly _cardValue?;
private readonly _pileNumber?;
private readonly _timestamp;
constructor(gameId: string, type: GameActionType, description: string, playerId?: string | undefined, playerName?: string | undefined, cardValue?: number | undefined, pileNumber?: number | undefined, id?: string, timestamp?: Date);
get id(): string;
get gameId(): string;
get type(): GameActionType;
get description(): string;
get playerId(): string | undefined;
get playerName(): string | undefined;
get cardValue(): number | undefined;
get pileNumber(): number | undefined;
get timestamp(): Date;
equals(other: GameAction): boolean;
toString(): string;
toJSON(): IGameActionData;
static fromJSON(data: IGameActionData): GameAction;
static gameCreated(gameId: string, numberOfPlayers: number): GameAction;
static cardPlayed(gameId: string, playerId: string, playerName: string, cardValue: number, pileNumber: number): GameAction;
static turnChanged(gameId: string, playerId: string, playerName: string): GameAction;
static gameFinished(gameId: string, winnerName?: string): GameAction;
static cardsDrawn(gameId: string, playerId: string, playerName: string, cardCount: number): GameAction;
static playerNameChanged(gameId: string, playerId: string, oldName: string, newName: string): GameAction;
static gameWon(gameId: string): GameAction;
static gameLost(gameId: string, playerName: string): GameAction;
static gameRestarted(gameId: string, numberOfPlayers: number): GameAction;
}
//# sourceMappingURL=GameAction.d.ts.map