summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rules.js37
1 files changed, 24 insertions, 13 deletions
diff --git a/rules.js b/rules.js
index 8a4ec9b..dd34543 100644
--- a/rules.js
+++ b/rules.js
@@ -508,14 +508,21 @@ function set_dice_value(d, v) {
// === HOW TO WIN ===
-function is_card_in_front(c) {
+function is_card_in_play(c) {
return (
set_has(game.front[0], c) ||
set_has(game.front[1], c)
)
}
-function is_card_in_play(c) {
+function is_card_in_reserve(c) {
+ return (
+ set_has(game.reserve[0], c) ||
+ set_has(game.reserve[1], c)
+ )
+}
+
+function is_card_in_play_or_reserve(c) {
return (
set_has(game.front[0], c) ||
set_has(game.front[1], c) ||
@@ -525,15 +532,19 @@ function is_card_in_play(c) {
}
function is_routed(c) {
- return !is_card_in_play(c)
+ return !is_card_in_play_or_reserve(c)
}
-function is_card_attack_with_target_in_play(c) {
+function card_has_attack_with_valid_target(c) {
for (let a of data.cards[c].actions) {
if (a.type === "Attack") {
- for (let t of a.target_list)
+ let attack_reserve = card_has_rule("attack_reserve")
+ for (let t of a.target_list) {
if (is_card_in_play(t))
return true
+ if (attack_reserve && is_card_in_reserve(t))
+ return true
+ }
}
}
return false
@@ -542,7 +553,7 @@ function is_card_attack_with_target_in_play(c) {
function is_impossible_to_attack() {
let p = player_index()
for (let c of game.front[p])
- if (is_card_attack_with_target_in_play(c))
+ if (card_has_attack_with_valid_target(c))
return false
return true
}
@@ -1486,7 +1497,7 @@ function can_take_any_action() {
return false
}
-function count_cards_in_play_from_wing(w) {
+function count_cards_remaining_from_wing(w) {
let n = 0
for (let c of game.front[0])
if (data.cards[c].wing === w)
@@ -1511,7 +1522,7 @@ function goto_start_turn() {
// Rout Stony Hill at start of Union turn if it is the only Blue card left.
if (player_index() === 1) {
if (is_card_in_play(S25_STONY_HILL)) {
- if (count_cards_in_play_from_wing(BLUE) === 1) {
+ if (count_cards_remaining_from_wing(BLUE) === 1) {
game.state = "s25_stony_hill"
return
}
@@ -1936,7 +1947,7 @@ states.command = {
if (game.scenario === S4_BOSWORTH_FIELD) {
if (c === S4_THE_STANLEYS) {
- if (is_card_in_play(S4_NORTHUMBERLAND)) {
+ if (is_card_in_play_or_reserve(S4_NORTHUMBERLAND)) {
log("The Stanleys rout Northumberland.")
map_set(game.sticks, S4_NORTHUMBERLAND, 0)
}
@@ -2377,7 +2388,7 @@ function should_rout_card(c) {
let rout_with = card_has_rule(c, "rout_with")
if (rout_with) {
for (let other of rout_with)
- if (is_card_in_play(other))
+ if (!is_routed(other))
return false
return true
}
@@ -2396,7 +2407,7 @@ function should_remove_card(c) {
let remove_with = card_has_rule(c, "remove_with")
if (remove_with) {
for (let other of remove_with)
- if (is_card_in_play(other))
+ if (!is_routed(other))
return false
return true
}
@@ -2407,14 +2418,14 @@ function should_retire_card(c) {
let retire_with = card_has_rule(c, "retire_with")
if (retire_with) {
for (let other of retire_with)
- if (is_card_in_play(other))
+ if (!is_routed(other))
return false
return true
}
if (game.scenario === S25_WHEATFIELD) {
if (c === S25_ZOOK || c === S25_KELLY) {
- if (is_card_in_front(S25_WOFFORD))
+ if (is_card_in_play(S25_WOFFORD))
return true
}
}