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