summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js29
1 files changed, 22 insertions, 7 deletions
diff --git a/rules.js b/rules.js
index e1574a6..fbd3c74 100644
--- a/rules.js
+++ b/rules.js
@@ -999,7 +999,7 @@ function is_mandatory_reaction(c, a) {
function can_take_action(c, a) {
if (a.type === "Attack" && find_target_of_attack(a) < 0)
return false
- if (a.type === "Command" && find_target_of_command(a) < 0)
+ if (a.type === "Command" && find_first_target_of_command(a) < 0)
return false
// TODO: 38B Clinton (can only attack if other cards have dice)
@@ -1147,7 +1147,7 @@ function find_target_of_attack(a) {
return -1
}
-function find_target_of_command(a) {
+function find_first_target_of_command(a) {
for (let c of a.target_list) {
if (set_has(game.reserve[0], c))
return c
@@ -1156,6 +1156,17 @@ function find_target_of_command(a) {
}
}
+function find_all_targets_of_command(a) {
+ let list = []
+ for (let c of a.target_list) {
+ if (set_has(game.reserve[0], c))
+ list.push(c)
+ if (set_has(game.reserve[1], c))
+ list.push(c)
+ }
+ return list
+}
+
states.bombard = {
prompt() {
view.prompt = "Bombard."
@@ -1220,17 +1231,21 @@ function resume_attack() {
states.command = {
prompt() {
- let t = find_target_of_command(current_action())
- view.prompt = "Bring " + card_name(t) + " out of reserve."
- gen_action_card(t)
+ let list = find_all_targets_of_command(current_action())
+ view.prompt = "Bring " + list.map(c => card_name(c)).join(" and ") + " out of reserve."
+ for (let t of list)
+ gen_action_card(t)
},
card(c) {
log(card_name(game.selected) + " commanded " + card_name(c) + " out of reserve.")
let p = player_index()
set_delete(game.reserve[p], c)
set_add(game.front[p], c)
- pay_for_action(game.selected)
- end_action_phase()
+
+ if (find_first_target_of_command(current_action() < 0)) {
+ pay_for_action(game.selected)
+ end_action_phase()
+ }
},
}