@gamepark/rules-api
Version:
API to implement the rules of a board game
27 lines • 1 kB
JavaScript
import { ItemMoveType } from './ItemMoveType';
import { MoveKind } from '../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}
*/
export function isShuffle(move) {
return move.kind === MoveKind.ItemMove && move.type === ItemMoveType.Shuffle;
}
/**
* 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.
*/
export function isShuffleItemType(type) {
return (move) => isShuffle(move) && move.itemType === type;
}
/**
* 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}
*/
export function isShuffleRandomized(move) {
return isShuffle(move) && Array.isArray(move.newIndexes);
}
//# sourceMappingURL=Shuffle.js.map