UNPKG

@gamepark/rules-api

Version:

API to implement the rules of a board game

60 lines 3.15 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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); 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.hideFrontToOthers = exports.hideItemIdToOthers = exports.SecretMaterialRules = void 0; var HiddenMaterialRules_1 = require("./HiddenMaterialRules"); /** * Implement SecretMaterialRules when you want to use the {@link MaterialRules} approach with {@link SecretInformation}. * Using some {@link HidingSecretsStrategy} allows to enforce the security of a game with secret information easily. * If the game has only hidden information (all players have the same information), then you must implement {@link HiddenMaterialRules} instead. */ var SecretMaterialRules = /** @class */ (function (_super) { __extends(SecretMaterialRules, _super); function SecretMaterialRules() { return _super !== null && _super.apply(this, arguments) || this; } /** * With the material approach, we can offer a default working implementation for {@link SecretInformation.getPlayerView} */ SecretMaterialRules.prototype.getPlayerView = function (player) { return this.getView(player); }; /** * With the material approach, we can offer a default working implementation for {@link SecretInformation.getPlayerMoveView} */ SecretMaterialRules.prototype.getPlayerMoveView = function (move, player) { return this.getMoveView(move, player); }; return SecretMaterialRules; }(HiddenMaterialRules_1.HiddenMaterialRules)); exports.SecretMaterialRules = SecretMaterialRules; /** * Hide the item id to all players except the player that is equal to item.location.player. * Used to hide cards in a player's hand from others for instance. * @param item The item to hide information from * @param player The player to hide information to (or the spectator) */ var hideItemIdToOthers = function (item, player) { return item.location.player === player ? [] : ['id']; }; exports.hideItemIdToOthers = hideItemIdToOthers; /** * Hide the item.id.front to all players except the player that is equal to item.location.player. * @param item The item to hide information from * @param player The player to hide information to (or the spectator) */ var hideFrontToOthers = function (item, player) { return item.location.player === player ? [] : ['id.front']; }; exports.hideFrontToOthers = hideFrontToOthers; //# sourceMappingURL=SecretMaterialRules.js.map