diff options
-rw-r--r-- | rules.js | 22 | ||||
-rw-r--r-- | tools/gendata.js | 21 |
2 files changed, 28 insertions, 15 deletions
@@ -2400,7 +2400,7 @@ function goto_take_action(c, ix) { game.action = ix switch (a.type) { case "Attack": - if (card_has_rule(game.selected, "attack_choose_target")) + if (a.choice) goto_attack_choose_target() else goto_attack(find_target_of_attack(c, a)) @@ -2436,7 +2436,16 @@ function find_target_of_attack(c, a) { } function find_target_of_counterattack(a) { - // Note: only used for no-choice counterattacks + for (let t of a.target_list) { + if (set_has(game.front[0], t)) + return t + if (set_has(game.front[1], t)) + return t + } + return -1 +} + +function find_target_of_absorb(a) { for (let t of a.target_list) { if (set_has(game.front[0], t)) return t @@ -3036,8 +3045,13 @@ function can_take_reaction(c, a, wild) { case "Absorb": // if attack target is listed on absorb action - if (!a.target_list.includes(game.target)) - return false + if (a.choice) { + if (!a.target_list.includes(game.target)) + return false + } else { + if (find_target_of_absorb(a) !== game.target) + return false + } break } diff --git a/tools/gendata.js b/tools/gendata.js index 1740f70..0a8ab7c 100644 --- a/tools/gendata.js +++ b/tools/gendata.js @@ -356,23 +356,22 @@ function process_card(c, ix) { a.target_list = null else a.target_list = tname.split(/, | OR | or | and /).map(name => find_card(c.scenario, name)) - - // Hohenfriedberg invisible charles last target in list! - if (c.number === "267A" || c.number === "268A" || c.number === "269A") - a.target_list.push(find_card(c.scenario, "Charles")) - } - - if (a.type === "Counterattack") { - if (/, /.test(a.target)) - a.choice = 0 - else - a.choice = 1 } if (a.type === "Absorb") { a.target_list = a.target_list.filter(x => x !== ix) // never absorb for self } + + if (/, /.test(a.target) || !a.target_list || a.target_list.length < 2) + a.choice = 0 + else + a.choice = 1 } + + // Hohenfriedberg invisible charles last target in list! + if (c.number === "267A" || c.number === "268A" || c.number === "269A") + c.actions[0].target_list.push(find_card(c.scenario, "Charles")) + if (c.rules) { for (let key in c.rules) { let val = c.rules[key] |