UNPKG

@gamepark/rules-api

Version:

API to implement the rules of a board game

35 lines 1.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isShuffleRandomized = exports.isShuffleItemType = exports.isShuffle = void 0; var ItemMoveType_1 = require("./ItemMoveType"); var MoveKind_1 = require("../MoveKind"); /** * Type guard to test if a {@link MaterialMove} is a {@link Shuffle} move * @param move Move to test * @returns true if move is a {@link Shuffle} */ function isShuffle(move) { return move.kind === MoveKind_1.MoveKind.ItemMove && move.type === ItemMoveType_1.ItemMoveType.Shuffle; } exports.isShuffle = isShuffle; /** * Function to get a type guard for a {@link Shuffle} move for specific item types. * @param type Item type to test * @returns a type guard similar as {@link isShuffle} but that also verify the item type. */ function isShuffleItemType(type) { return function (move) { return isShuffle(move) && move.itemType === type; }; } exports.isShuffleItemType = isShuffleItemType; /** * Type guard to test if a {@link MaterialMove} is a {@link ShuffleRandomized} move * @param move Move to test * @returns true if move is a {@link ShuffleRandomized} */ function isShuffleRandomized(move) { return isShuffle(move) && Array.isArray(move.newIndexes); } exports.isShuffleRandomized = isShuffleRandomized; //# sourceMappingURL=Shuffle.js.map