UNPKG

@runox-game/game-engine

Version:
49 lines (48 loc) 2.02 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.RemovePlayerCommand = void 0; var game_command_1 = require("./game.command"); var command_result_1 = require("./command-result"); var log_levels_enum_1 = require("../log/log-levels.enum"); /** * Players to remove a player from the game */ var RemovePlayerCommand = /** @class */ (function (_super) { __extends(RemovePlayerCommand, _super); /** * Class that allows removing a player to remove from the game state * * @param players - player to remove from the game */ function RemovePlayerCommand(player) { var _this = _super.call(this) || this; _this.player = player; return _this; } RemovePlayerCommand.prototype.execute = function (state) { state.log("Jugadores: " + this.player, log_levels_enum_1.LogLevel.USER); state.playersGroup.removePlayer(this.player); state.events.dispatchStateChanged(state); }; RemovePlayerCommand.prototype.validate = function (state) { if (!this.player) { return new command_result_1.CommandValidation(false, 'Hubo un inconveniente con los jugadores a remover'); } return new command_result_1.CommandValidation(true); }; return RemovePlayerCommand; }(game_command_1.GameCommand)); exports.RemovePlayerCommand = RemovePlayerCommand;