UNPKG

@sillyal/dominion

Version:

Representation of Dominion, a deck-building card game created by Donald X. Vaccarino and published by Rio Grande Games.

54 lines 1.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var card_1 = require("./card"); var Game = /** @class */ (function () { function Game(players, piles) { this.trash = []; this.players = players; this.piles = piles; } Game.prototype.ended = function () { var cards = this.piles .filter(function (pile) { return pile.count === 0; }) .map(function (pile) { return pile.card; }); return cards.indexOf(card_1.Province) > -1 || cards.length >= 3; }; Game.prototype.trashACard = function (player, card) { var toTrash = player.trashACard(card); if (toTrash) { this.trash = this.trash.concat([toTrash]); } }; Game.prototype.buyACard = function (player, card) { var piles = this.piles.filter(function (pile) { return pile.card === card && pile.count > 0; }); if (piles && piles.length) { player.buyACard(piles[0].card); piles[0].count -= 1; } }; Game.prototype.gainACard = function (player, card) { var piles = this.piles.filter(function (pile) { return pile.card === card && pile.count > 0; }); if (piles && piles.length) { player.gainACard(piles[0].card); piles[0].count -= 1; } }; Game.prototype.gainACardToHand = function (player, card) { var piles = this.piles.filter(function (pile) { return pile.card === card && pile.count > 0; }); if (piles && piles.length) { player.gainACardToHand(piles[0].card); piles[0].count -= 1; } }; return Game; }()); exports.Game = Game; var Pile = /** @class */ (function () { function Pile(card, count) { this.card = card; this.count = count; } return Pile; }()); exports.Pile = Pile; //# sourceMappingURL=game.js.map