UNPKG

@gamepark/rules-api

Version:

API to implement the rules of a board game

34 lines 1.73 kB
import { HiddenMaterialRules } from './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. */ export class SecretMaterialRules extends HiddenMaterialRules { /** * With the material approach, we can offer a default working implementation for {@link SecretInformation.getPlayerView} */ getPlayerView(player) { return this.getView(player); } /** * With the material approach, we can offer a default working implementation for {@link SecretInformation.getPlayerMoveView} */ getPlayerMoveView(move, player) { return this.getMoveView(move, player); } } /** * 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) */ export const hideItemIdToOthers = (item, player) => item.location.player === player ? [] : ['id']; /** * 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) */ export const hideFrontToOthers = (item, player) => item.location.player === player ? [] : ['id.front']; //# sourceMappingURL=SecretMaterialRules.js.map