@runox-game/game-engine
Version:
RunoX game engine
41 lines (40 loc) • 1.73 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GameCommand = void 0;
var game_events_1 = require("../events/game-events");
var log_levels_enum_1 = require("../log/log-levels.enum");
var after_take_cards_event_1 = require("../events/after-take-cards.event");
var constants_1 = require("../constants");
/**
* Abstract class that serves as the basis for all game engine commands
*/
var GameCommand = /** @class */ (function () {
function GameCommand() {
/**
* Game events
*/
this.events = game_events_1.GameEvents.getInstance();
}
GameCommand.prototype.toString = function () {
var _a;
return (_a = this.constructor) === null || _a === void 0 ? void 0 : _a.name;
};
/**
* Punish those who did not yell UNO
* @param state
*/
GameCommand.prototype.checkForPlayersWhoShouldHaveYelledUno = function (state) {
var _this = this;
var playersWhoShouldHaveYelled = state.getPlayersWhoShouldHaveYelled();
state.log(playersWhoShouldHaveYelled
.map(function (x) { return x.name; })
.join(', ') + " deber\u00EDan haber cantado UNO", log_levels_enum_1.LogLevel.ALL);
playersWhoShouldHaveYelled.forEach(function (player) {
var newCards = state.giveCards(constants_1.Constants.COUNT_CARD_TO_TAKE_WHO_SHOULD_YELL_UNO, player);
state.log(player.name + " toma dos cartas", log_levels_enum_1.LogLevel.ALL);
_this.events.dispatchAfterTakeCards(new after_take_cards_event_1.AfterTakeCardsEvent(newCards, player));
});
};
return GameCommand;
}());
exports.GameCommand = GameCommand;