UNPKG

@gamepark/rules-api

Version:

API to implement the rules of a board game

27 lines 1.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isMoveItemType = exports.isMoveItem = void 0; var MoveKind_1 = require("../MoveKind"); var ItemMoveType_1 = require("./ItemMoveType"); /** * Type guard to test if a {@link MaterialMove} is a {@link MoveItem} move * @param move Move to test * @returns true if move is a {@link MoveItem} */ function isMoveItem(move) { return move.kind === MoveKind_1.MoveKind.ItemMove && move.type === ItemMoveType_1.ItemMoveType.Move; } exports.isMoveItem = isMoveItem; /** * Function to get a type guard for a {@link MoveItem} 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 isMoveItem} but that also verify the item type. */ function isMoveItemType(type, index) { return function (move) { return isMoveItem(move) && move.itemType === type && (index === undefined || move.itemIndex === index); }; } exports.isMoveItemType = isMoveItemType; //# sourceMappingURL=MoveItem.js.map