summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-12-13 00:38:41 +0100
committerTor Andersson <tor@ccxvii.net>2024-01-08 16:36:48 +0100
commit47b91ab24f6476aea134fff4516e7510e8fdefba (patch)
tree250b1740cc8a36ffb45f5603aff5b79de4ff2bdc /rules.js
parent4844a32353f470fadc3052113c09c9b2603f9d5c (diff)
downloadtable-battles-47b91ab24f6476aea134fff4516e7510e8fdefba.tar.gz
attack_choose_target
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js42
1 files changed, 39 insertions, 3 deletions
diff --git a/rules.js b/rules.js
index 3f20f9b..5ae8fcb 100644
--- a/rules.js
+++ b/rules.js
@@ -1383,7 +1383,10 @@ function goto_take_action(c, ix) {
game.action = ix
switch (a.type) {
case "Attack":
- goto_attack()
+ if (card_has_rule(game.selected, "attack_choose_target"))
+ goto_attack_choose_target()
+ else
+ goto_attack(find_target_of_attack(a))
break
case "Bombard":
game.state = "bombard"
@@ -1449,7 +1452,38 @@ states.bombard = {
},
}
-function goto_attack() {
+function goto_attack_choose_target() {
+ let a = current_action()
+ let candidates = []
+ for (let c of a.target_list) {
+ if (set_has(game.front[0], c))
+ candidates.push(c)
+ if (set_has(game.front[1], c))
+ candidates.push(c)
+ }
+ if (candidates.length > 1)
+ game.state = "attack_choose_target"
+ else
+ goto_attack(candidates[0])
+}
+
+states.attack_choose_target = {
+ prompt() {
+ view.prompt = "Choose the target of your attack."
+ let a = current_action()
+ for (let c of a.target_list) {
+ if (set_has(game.front[0], c))
+ gen_action_card(c)
+ if (set_has(game.front[1], c))
+ gen_action_card(c)
+ }
+ },
+ card(c) {
+ goto_attack(c)
+ },
+}
+
+function goto_attack(target) {
let a = current_action()
let take_from = card_has_rule(game.selected, "take_from")
@@ -1459,7 +1493,7 @@ function goto_attack() {
}
game.state = "attack"
- game.target = find_target_of_attack(a)
+ game.target = target
game.hits = get_attack_hits(game.selected, a)
game.self = get_attack_self(game.selected, a)
@@ -1902,6 +1936,7 @@ function get_attack_hits(c, a) {
throw new Error("invalid attack effect: " + a.effect)
case "1 hit.":
case "1 hit. Warwick Retires upon completing this Attack Action.":
+ case "1 hit. You CHOOSE the target.":
case "1 hit. 1 self per action.":
return 1
case "1 hit per die.":
@@ -1923,6 +1958,7 @@ function get_attack_self(c, a) {
throw new Error("invalid attack effect: " + a.effect)
case "1 hit.":
case "1 hit. Warwick Retires upon completing this Attack Action.":
+ case "1 hit. You CHOOSE the target.":
case "1 hit per die.":
case "1 hit per die. Ignore first target until it comes out of Reserve.":
case "1 hit per pair.":