@runox-game/game-engine
Version:
RunoX game engine
41 lines (40 loc) • 1.33 kB
TypeScript
import { IGameState } from '../models/game-state.model';
import { CommandValidation } from './command-result';
import { GameEvents } from '../events/game-events';
/**
* Abstract class that serves as the basis for all game engine commands
*/
export declare abstract class GameCommand {
/**
* Game events
*/
protected readonly events: GameEvents;
constructor();
/**
* Executes a command that makes changes to the internal game state
*
* @remarks
* This method does not perform validations on models because it always assumes
* that the validate() method was previously called
*
* @param state - Current game state
* @returns void
*/
abstract execute(state: IGameState): void;
/**
* Validates that the state is in optimal conditions to be able to execute the command
*
* @remarks
* This method must always be invoked before the execute() method
*
* @param state - Current game state
* @returns object with validation result
*/
abstract validate(state: IGameState): CommandValidation;
toString(): string;
/**
* Punish those who did not yell UNO
* @param state
*/
protected checkForPlayersWhoShouldHaveYelledUno(state: IGameState): void;
}