UNPKG

@gamepark/rules-api

Version:

API to implement the rules of a board game

20 lines 861 B
import { MoveKind } from '../MoveKind'; import { ItemMoveType } from './ItemMoveType'; /** * Type guard to test if a {@link MaterialMove} is a {@link SelectItem} move * @param move Move to test * @returns true if move is a {@link SelectItem} */ export function isSelectItem(move) { return move.kind === MoveKind.ItemMove && move.type === ItemMoveType.Select; } /** * Function to get a type guard for a {@link SelectItem} move for specific item types. * @param type Item type to test * @param index Optional itemIndex to test along the item type * @returns a type guard similar as {@link isSelectItem} but that also verify the item type. */ export function isSelectItemType(type, index) { return (move) => isSelectItem(move) && move.itemType === type && (index === undefined || move.itemIndex === index); } //# sourceMappingURL=SelectItem.js.map