@runox-game/game-engine
Version:
RunoX game engine
59 lines (58 loc) • 2.93 kB
JavaScript
;
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.SwitchHandsCommand = 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");
/**
* Class that allows switch hands between two players
*/
var SwitchHandsCommand = /** @class */ (function (_super) {
__extends(SwitchHandsCommand, _super);
/**
* Class that allows switch hands between two players
* @param players1 player one
* @param players1 player two
*/
function SwitchHandsCommand(player1, player2) {
var _this = _super.call(this) || this;
_this.player1 = player1;
_this.player2 = player2;
return _this;
}
SwitchHandsCommand.prototype.execute = function (state) {
state.log("Se han intercambiado dos manos", log_levels_enum_1.LogLevel.USER);
var cards1 = this.player1.hand.cards;
var cards2 = this.player2.hand.cards;
state.log("Cartas de " + this.player1 + " : " + this.player1.hand.cards.map(function (x) { return x.sprite; }), log_levels_enum_1.LogLevel.ALL);
state.log("Cartas de " + this.player2 + " : " + this.player2.hand.cards.map(function (x) { return x.sprite; }), log_levels_enum_1.LogLevel.ALL);
this.player1.hand.cards = cards2;
this.player2.hand.cards = cards1;
state.log("Cartas de " + this.player1 + " : " + this.player1.hand.cards.map(function (x) { return x.sprite; }), log_levels_enum_1.LogLevel.ALL);
state.log("Cartas de " + this.player2 + " : " + this.player2.hand.cards.map(function (x) { return x.sprite; }), log_levels_enum_1.LogLevel.ALL);
};
SwitchHandsCommand.prototype.validate = function (state) {
if (!state.gameModes.crazyCommands) {
return new command_result_1.CommandValidation(false, 'Modo Crazy no está permitido');
}
if (!this.player1 || !this.player1) {
return new command_result_1.CommandValidation(false, 'Hubo un inconveniente con los jugadores ingresados');
}
return new command_result_1.CommandValidation(true);
};
return SwitchHandsCommand;
}(game_command_1.GameCommand));
exports.SwitchHandsCommand = SwitchHandsCommand;