@gamepark/rules-api
Version:
API to implement the rules of a board game
26 lines • 1.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isDeleteItemTypeAtOnce = exports.isDeleteItemsAtOnce = void 0;
var MoveKind_1 = require("../MoveKind");
var ItemMoveType_1 = require("./ItemMoveType");
/**
* Type guard to test if a {@link MaterialMove} is a {@link DeleteItemsAtOnce} move
* @param move Move to test
* @returns true if move is a {@link DeleteItemsAtOnce}
*/
function isDeleteItemsAtOnce(move) {
return move.kind === MoveKind_1.MoveKind.ItemMove && move.type === ItemMoveType_1.ItemMoveType.DeleteAtOnce;
}
exports.isDeleteItemsAtOnce = isDeleteItemsAtOnce;
/**
* Function to get a type guard for a {@link DeleteItemsAtOnce} move for specific item types.
* @param type Item type to test
* @returns a type guard similar as {@link isDeleteItemsAtOnce} but that also verify the item type.
*/
function isDeleteItemTypeAtOnce(type) {
return function (move) {
return isDeleteItemsAtOnce(move) && move.itemType === type;
};
}
exports.isDeleteItemTypeAtOnce = isDeleteItemTypeAtOnce;
//# sourceMappingURL=DeleteItemsAtOnce.js.map