@gamepark/rules-api
Version:
API to implement the rules of a board game
20 lines • 861 B
JavaScript
import { ItemMoveType } from './ItemMoveType';
import { MoveKind } from '../MoveKind';
/**
* Type guard to test if a {@link MaterialMove} is a {@link DeleteItem} move
* @param move Move to test
* @returns true if move is a {@link DeleteItem}
*/
export function isDeleteItem(move) {
return move.kind === MoveKind.ItemMove && move.type === ItemMoveType.Delete;
}
/**
* Function to get a type guard for a {@link DeleteItem} 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 isDeleteItem} but that also verify the item type.
*/
export function isDeleteItemType(type, index) {
return (move) => isDeleteItem(move) && move.itemType === type && (index === undefined || move.itemIndex === index);
}
//# sourceMappingURL=DeleteItem.js.map