@gamepark/rules-api
Version:
API to implement the rules of a board game
25 lines • 842 B
JavaScript
/**
* 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
*/
export function isCompetitive(rules) {
return isCompetitiveScore(rules) || isCompetitiveRank(rules);
}
/**
* 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
*/
export function isCompetitiveScore(rules) {
return typeof rules.getScore === 'function';
}
/**
* 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)
*/
export function isCompetitiveRank(rules) {
return typeof rules.rankPlayers === 'function';
}
//# sourceMappingURL=Competitive.js.map