diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-04-19 23:59:09 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-04-19 23:59:09 +0200 |
commit | 1080f804ea5f8fcb5fca4e4b9026185677de1b7a (patch) | |
tree | 36bf56eab0dc5cf33fa5f8faa956fc874f64b6ab /rules.ts | |
parent | 8629acc5a2471a30ae29df679268437e73ebf721 (diff) | |
download | plantagenet-1080f804ea5f8fcb5fca4e4b9026185677de1b7a.tar.gz |
Move lord_has_capability_card to LORD section.
Diffstat (limited to 'rules.ts')
-rw-r--r-- | rules.ts | 67 |
1 files changed, 34 insertions, 33 deletions
@@ -7,12 +7,13 @@ /* TODO + EVENTS and CAPABILITIES trigger - Pass instead of Done + + handle both lords at same sea... + NAVAL BLOCKADE - for Tax and Tax Collectors Y15 LONDON FOR YORK - except by Event exception - scenario card lists - number of roses in data - Scenario special rules. Review all undo steps. @@ -1208,6 +1209,36 @@ function set_lord_capability(lord: Lord, n: 0 | 1, x: Card) { map2_set(game.pieces.capabilities, lord, n, x) } +function lord_has_capability_card(lord: Lord, c: Card) { + if (get_lord_capability(lord, 0) === c) + return true + if (get_lord_capability(lord, 1) === c) + return true + return false +} + +function lord_has_capability(lord: Lord, card_or_list: Card | Card[]) { + if (Array.isArray(card_or_list)) { + for (let card of card_or_list) + if (lord_has_capability_card(lord, card)) + return true + return false + } + return lord_has_capability_card(lord, card_or_list) +} + +function lord_already_has_capability(lord: Lord, c: Card) { + // compare capabilities by name... + let name = data.cards[c].capability + let c1 = get_lord_capability(lord, 0) + if (c1 >= 0 && data.cards[c1].capability === name) + return true + let c2 = get_lord_capability(lord, 1) + if (c2 >= 0 && data.cards[c2].capability === name) + return true + return false +} + function get_lord_assets(lord: Lord, n: Asset): number { return map_get_pack4(game.pieces.assets, lord, n) } @@ -3219,36 +3250,6 @@ function can_add_transport(who: Lord, what: Asset) { // === 3.4.6 LEVY CAPABILITY === -function lord_has_capability_card(lord: Lord, c: Card) { - if (get_lord_capability(lord, 0) === c) - return true - if (get_lord_capability(lord, 1) === c) - return true - return false -} - -function lord_has_capability(lord: Lord, card_or_list: Card | Card[]) { - if (Array.isArray(card_or_list)) { - for (let card of card_or_list) - if (lord_has_capability_card(lord, card)) - return true - return false - } - return lord_has_capability_card(lord, card_or_list) -} - -function lord_already_has_capability(lord: Lord, c: Card) { - // compare capabilities by name... - let name = data.cards[c].capability - let c1 = get_lord_capability(lord, 0) - if (c1 >= 0 && data.cards[c1].capability === name) - return true - let c2 = get_lord_capability(lord, 1) - if (c2 >= 0 && data.cards[c2].capability === name) - return true - return false -} - function can_add_lord_capability(lord: Lord) { if (get_lord_capability(lord, 0) < 0) return true |