summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2025-05-07 01:12:46 +0200
committerTor Andersson <tor@ccxvii.net>2025-05-07 01:12:46 +0200
commit0aa07ecfd55d48ed9089d6edf58aa287f36ba9b9 (patch)
treef0f936503b85a26f813ef6ed8e0c007cb70533a7
parentf330f88d68f12782772fa24f2861fccdc75df9cf (diff)
downloadwilderness-war-0aa07ecfd55d48ed9089d6edf58aa287f36ba9b9.tar.gz
Highlight (and one-click use) response cards.
-rw-r--r--play.css4
-rw-r--r--rules.js77
2 files changed, 59 insertions, 22 deletions
diff --git a/play.css b/play.css
index badc1e4..1992323 100644
--- a/play.css
+++ b/play.css
@@ -115,11 +115,11 @@ aside { min-width: 220px; }
}
.card.highlight {
- box-shadow: 0 0 0 2px yellow;
+ box-shadow: 0 0 0 3px yellow;
}
.card.selected {
- box-shadow: 0 0 0 2px white;
+ box-shadow: 0 0 0 3px white;
}
.card.enabled {
diff --git a/rules.js b/rules.js
index 681de95..ff15988 100644
--- a/rules.js
+++ b/rules.js
@@ -2974,7 +2974,7 @@ states.siege_or_move = {
if (is_assault_possible(where)) {
if (player.hand.includes(SURRENDER)) {
view.prompt = `You may assault at ${space_name(where)}, play "Surrender!", or move.`
- gen_action('play_event', SURRENDER)
+ gen_action_response(SURRENDER)
} else {
view.prompt = `You may assault at ${space_name(where)} or move.`
}
@@ -3003,6 +3003,9 @@ states.siege_or_move = {
log_force_with(game.move.moving)
goto_assault(moving_piece_space())
},
+ card(c) {
+ this.play_event(c)
+ },
play_event(c) {
push_undo()
game.siege_where = moving_piece_space()
@@ -3501,7 +3504,7 @@ states.move = {
}
if (game.active === BRITAIN && player.hand.includes(GEORGE_CROGHAN)) {
if (force_has_drilled_troops(who))
- gen_action('play_event', GEORGE_CROGHAN)
+ gen_action_response(GEORGE_CROGHAN)
}
if (piece_can_naval_move_from(who, from)) {
@@ -3514,7 +3517,7 @@ states.move = {
for (let card = first_amphib_card; card <= last_amphib_card; ++card) {
if (player.hand.includes(card)) {
has_amphib = true
- gen_action('play_event', card)
+ gen_action_response(card)
}
}
if (has_amphib)
@@ -3549,6 +3552,9 @@ states.move = {
view.actions.drop_off = 1
}
},
+ card(c) {
+ this.play_event(c)
+ },
play_event(card) {
push_undo()
play_card_for_response(card)
@@ -3678,7 +3684,7 @@ states.foul_weather = {
view.where = moving_piece_space()
if (player.hand.includes(FOUL_WEATHER)) {
view.prompt = `${piece_name_and_place(p)} to move. You may play "Foul Weather".`
- gen_action('play_event', FOUL_WEATHER)
+ gen_action_response(FOUL_WEATHER)
} else {
view.prompt = `${piece_name_and_place(p)} to move. You don't have "Foul Weather".`
}
@@ -3687,6 +3693,9 @@ states.foul_weather = {
view.actions.pass_fw_action = 1
view.actions.pass = 1
},
+ card(c) {
+ this.play_event(c)
+ },
play_event(c) {
if (game.options.retroactive) {
// console.log("RETRO STAY")
@@ -3739,12 +3748,15 @@ states.lake_schooner = {
view.where = to
if (player.hand.includes(LAKE_SCHOONER)) {
view.prompt = `${piece_name(who)} to move from ${space_name(from)} to ${space_name(to)}. You may play "Lake Schooner".`
- gen_action('play_event', LAKE_SCHOONER)
+ gen_action_response(LAKE_SCHOONER)
} else {
view.prompt = `${piece_name(who)} to move from ${space_name(from)} to ${space_name(to)}. You don't have "Lake Schooner".`
}
view.actions.pass = 1
},
+ card(c) {
+ this.play_event(c)
+ },
play_event(c) {
play_card_for_response(c)
let who = moving_piece()
@@ -4799,11 +4811,11 @@ states.attacker_events = {
if (can_play_ambush_in_attack()) {
let x = false
if (player.hand.includes(AMBUSH_1)) {
- gen_action('play_event', AMBUSH_1)
+ gen_action_response(AMBUSH_1)
x = true
}
if (player.hand.includes(AMBUSH_2)) {
- gen_action('play_event', AMBUSH_2)
+ gen_action_response(AMBUSH_2)
x = true
}
if (x)
@@ -4813,7 +4825,7 @@ states.attacker_events = {
}
if (can_play_coehorns_in_attack()) {
if (player.hand.includes(COEHORNS)) {
- gen_action('play_event', COEHORNS)
+ gen_action_response(COEHORNS)
have.push('"Coehorns"')
} else {
dont_have.push('"Coehorns"')
@@ -4822,11 +4834,11 @@ states.attacker_events = {
if (can_play_fieldworks_in_attack()) {
let x = false
if (player.hand.includes(FIELDWORKS_1)) {
- gen_action('play_event', FIELDWORKS_1)
+ gen_action_response(FIELDWORKS_1)
x = true
}
if (player.hand.includes(FIELDWORKS_2)) {
- gen_action('play_event', FIELDWORKS_2)
+ gen_action_response(FIELDWORKS_2)
x = true
}
if (x)
@@ -4844,6 +4856,9 @@ states.attacker_events = {
view.prompt += " You have no more response events."
view.actions.end_response = 1
},
+ card(c) {
+ this.play_event(c)
+ },
play_event(c) {
push_undo()
play_card_for_response(c)
@@ -4875,11 +4890,11 @@ states.defender_events = {
if (can_play_ambush_in_defense()) {
let x = false
if (player.hand.includes(AMBUSH_1)) {
- gen_action('play_event', AMBUSH_1)
+ gen_action_response(AMBUSH_1)
x = true
}
if (player.hand.includes(AMBUSH_2)) {
- gen_action('play_event', AMBUSH_2)
+ gen_action_response(AMBUSH_2)
x = true
}
if (x)
@@ -4889,7 +4904,7 @@ states.defender_events = {
}
if (can_play_coehorns_in_defense()) {
if (player.hand.includes(COEHORNS)) {
- gen_action('play_event', COEHORNS)
+ gen_action_response(COEHORNS)
have.push('"Coehorns"')
} else {
dont_have.push('"Coehorns"')
@@ -4898,11 +4913,11 @@ states.defender_events = {
if (can_play_fieldworks_in_defense()) {
let x = false
if (player.hand.includes(FIELDWORKS_1)) {
- gen_action('play_event', FIELDWORKS_1)
+ gen_action_response(FIELDWORKS_1)
x = true
}
if (player.hand.includes(FIELDWORKS_2)) {
- gen_action('play_event', FIELDWORKS_2)
+ gen_action_response(FIELDWORKS_2)
x = true
}
if (x)
@@ -4920,6 +4935,9 @@ states.defender_events = {
view.prompt += " You have no more response events."
view.actions.end_response = 1
},
+ card(c) {
+ this.play_event(c)
+ },
play_event(c) {
push_undo()
play_card_for_response(c)
@@ -6044,12 +6062,15 @@ states.siege_coehorns_attacker = {
prompt() {
if (player.hand.includes(COEHORNS)) {
view.prompt = `Siege at ${space_name(game.siege_where)}. You may play "Coehorns & Howitzers".`
- gen_action('play_event', COEHORNS)
+ gen_action_response(COEHORNS)
} else {
view.prompt = `Siege at ${space_name(game.siege_where)}. You don't have "Coehorns & Howitzers".`
}
view.actions.pass = 1
},
+ card(c) {
+ this.play_event(c)
+ },
play_event(c) {
play_card_for_response(c)
game.events.coehorns = game.active
@@ -6073,12 +6094,15 @@ states.siege_coehorns_defender = {
prompt() {
if (player.hand.includes(COEHORNS)) {
view.prompt = `Siege at ${space_name(game.siege_where)}. You may play "Coehorns & Howitzers".`
- gen_action('play_event', COEHORNS)
+ gen_action_response(COEHORNS)
} else {
view.prompt = `Siege at ${space_name(game.siege_where)}. You don't have "Coehorns & Howitzers".`
}
view.actions.pass = 1
},
+ card(c) {
+ this.play_event(c)
+ },
play_event(c) {
play_card_for_response(c)
game.events.coehorns = game.active
@@ -6106,12 +6130,15 @@ states.siege_surrender = {
prompt() {
if (player.hand.includes(SURRENDER)) {
view.prompt = `Siege at ${space_name(game.siege_where)}. You may play "Surrender!"`
- gen_action('play_event', SURRENDER)
+ gen_action_response(SURRENDER)
} else {
view.prompt = `Siege at ${space_name(game.siege_where)}. You don't have "Surrender!"`
}
view.actions.pass = 1
},
+ card(c) {
+ this.play_event(c)
+ },
play_event(c) {
play_card_for_response(c)
goto_surrender()
@@ -6380,13 +6407,16 @@ states.raid_blockhouses = {
prompt() {
if (player.hand.includes(BLOCKHOUSES)) {
view.prompt = `Raid at ${space_name(game.raid.where)}. You may play "Blockhouses".`
- gen_action('play_event', BLOCKHOUSES)
+ gen_action_response(BLOCKHOUSES)
} else {
view.prompt = `Raid at ${space_name(game.raid.where)}. You don't have "Blockhouses".`
}
view.actions.pass_bh_season = 1
view.actions.pass = 1
},
+ card(c) {
+ this.play_event(c)
+ },
play_event(c) {
play_card_for_response(c)
game.events.blockhouses = game.active
@@ -7313,12 +7343,15 @@ states.massacre_1 = {
prompt() {
if (player.hand.includes(MASSACRE)) {
view.prompt = `You may play "Massacre!"`
- gen_action('play_event', MASSACRE)
+ gen_action_response(MASSACRE)
} else {
view.prompt = `You don't have "Massacre!"`
}
view.actions.pass = 1
},
+ card(c) {
+ this.play_event(c)
+ },
play_event(c) {
flush_summary()
play_card_for_response(c)
@@ -10120,6 +10153,10 @@ function gen_action(action, argument) {
}
}
+function gen_action_response(c) {
+ gen_action('card', c)
+}
+
function gen_action_space(s) {
gen_action('space', s)
}