summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-01-20 21:06:28 +0100
committerTor Andersson <tor@ccxvii.net>2023-02-18 11:54:52 +0100
commit1d683c967dbf1cb9e7933c5055504a36678f28fc (patch)
tree128fc011d4166bf66247fa1c9d433c009fa5280b
parentf9839449611cd12874764a031223bafc0d49a5d7 (diff)
downloadwilderness-war-1d683c967dbf1cb9e7933c5055504a36678f28fc.tar.gz
Voluntary demolition of fortifications.
Can play before a card and after all movement.
-rw-r--r--rules.js78
1 files changed, 75 insertions, 3 deletions
diff --git a/rules.js b/rules.js
index b674057..1be8da8 100644
--- a/rules.js
+++ b/rules.js
@@ -1415,10 +1415,16 @@ function find_enemy_commanding_leader_in_space(space) {
function award_vp(n) {
if (game.active === FRANCE) {
- log(`France gains ${n} VP.`);
+ if (n < 0)
+ log(`France loses ${-n} VP.`);
+ else
+ log(`France gains ${n} VP.`);
game.tracks.vp += n;
} else {
- log(`Britain gains ${n} VP.`);
+ if (n < 0)
+ log(`Britain loses ${-n} VP.`);
+ else
+ log(`Britain gains ${n} VP.`);
game.tracks.vp -= n;
}
}
@@ -1431,6 +1437,10 @@ function remove_friendly_fort_uc(space) {
remove_from_array(player.forts_uc, space);
}
+function remove_friendly_fort(space) {
+ remove_from_array(player.forts, space);
+}
+
function remove_enemy_fort_uc(space) {
remove_from_array(enemy_player.forts_uc, space);
}
@@ -2034,6 +2044,10 @@ states.action_phase = {
gen_card_menu(player.hand[i]);
if (player.hand.length === 1 && !player.held)
gen_action_pass();
+ gen_action('demolish');
+ },
+ demolish() {
+ goto_demolition();
},
play_event(card) {
push_undo();
@@ -2196,7 +2210,9 @@ states.activate_campaign = {
function goto_pick_move() {
if (game.activation.list.length === 0) {
delete game.activation;
- end_action_phase();
+ // TODO: demolish here or by clicking button before ending move
+ goto_demolition_after_move();
+ // end_action_phase();
} else if (game.activation.list.length === 1) {
pick_move(game.activation.list.pop());
} else {
@@ -4024,6 +4040,62 @@ states.raiders_go_home = {
}
}
+// DEMOLITION
+
+function goto_demolition() {
+ push_undo();
+ game.state = 'demolition';
+}
+
+function goto_demolition_after_move() {
+ game.state = 'demolition_after_move';
+}
+
+function demolition_prompt() {
+ view.prompt = "You may demolish any friendly unbesieged fortification."
+ for (let s of player.stockades)
+ if (is_space_unbesieged(s))
+ gen_action_space(s);
+ for (let s of player.forts_uc)
+ if (is_space_unbesieged(s))
+ gen_action_space(s);
+ for (let s of player.forts)
+ if (is_space_unbesieged(s))
+ gen_action_space(s);
+ gen_action_next();
+}
+
+function demolition_space(s) {
+ push_undo();
+ if (has_friendly_stockade(s)) {
+ log(`Demolishes stockade at ${space_name(s)}.`);
+ remove_friendly_stockade(s);
+ } else if (has_friendly_fort_uc(s)) {
+ log(`Demolishes fort U/C at ${space_name(s)}.`);
+ remove_friendly_fort_uc(s);
+ } else if (has_friendly_fort(s)) {
+ log(`Demolishes fort at ${space_name(s)}.`);
+ award_vp(-1);
+ remove_friendly_fort(s);
+ }
+}
+
+states.demolition = {
+ prompt: demolition_prompt,
+ space: demolition_space,
+ next() {
+ game.state = 'action_phase';
+ }
+}
+
+states.demolition_after_move = {
+ prompt: demolition_prompt,
+ space: demolition_space,
+ next() {
+ end_action_phase();
+ }
+}
+
// CONSTRUCTION
function format_remain(n) {