UNPKG

@runox-game/game-engine

Version:
49 lines (48 loc) 2.05 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.AddPlayersCommand = 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 add into the game */ var AddPlayersCommand = /** @class */ (function (_super) { __extends(AddPlayersCommand, _super); /** * Class that allows adding players to the game state * * @param players - players to add into the game */ function AddPlayersCommand(players) { var _this = _super.call(this) || this; _this.players = players; return _this; } AddPlayersCommand.prototype.execute = function (state) { state.log("Jugadores: " + this.players.map(function (x) { return x.name; }).join(', '), log_levels_enum_1.LogLevel.USER); state.playersGroup.addPlayers(this.players); state.events.dispatchStateChanged(state); }; AddPlayersCommand.prototype.validate = function (state) { if (!this.players || !this.players.length) { return new command_result_1.CommandValidation(false, 'Hubo un inconveniente con los jugadores ingresados'); } return new command_result_1.CommandValidation(true); }; return AddPlayersCommand; }(game_command_1.GameCommand)); exports.AddPlayersCommand = AddPlayersCommand;