UNPKG

@gamepark/rules-api

Version:

API to implement the rules of a board game

31 lines 1.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isCompetitiveRank = exports.isCompetitiveScore = exports.isCompetitive = void 0; /** * Type guard to identify if a game's Rule is Competitive or not. * @param rules game's Rule * @returns true if the game is competitive */ function isCompetitive(rules) { return isCompetitiveScore(rules) || isCompetitiveRank(rules); } exports.isCompetitive = isCompetitive; /** * Type guard to identify if a game's Rule provide scores for players. * @param rules game's Rule * @returns true if the game is competitive with scores */ function isCompetitiveScore(rules) { return typeof rules.getScore === 'function'; } exports.isCompetitiveScore = isCompetitiveScore; /** * Type guard to identify if a game's Rule can rank the players. * @param rules game's Rule * @returns true if the game is competitive with ranking (used when scores are not available) */ function isCompetitiveRank(rules) { return typeof rules.rankPlayers === 'function'; } exports.isCompetitiveRank = isCompetitiveRank; //# sourceMappingURL=Competitive.js.map