From 522e1dc7f325e7f174980a5dcb114e1fa07fd254 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 18 Aug 2024 23:53:06 +0200 Subject: Fix some "may" events to make momentum changes optional. --- rules.js | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 4 deletions(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index de5f33e..a96cbf3 100644 --- a/rules.js +++ b/rules.js @@ -2758,6 +2758,20 @@ function vm_decrease_prussian_collaboration() { vm_next() } +function vm_may_decrease_revolutionary_momentum() { + if (game.red_momentum > 0) + game.state = "vm_may_decrease_revolutionary_momentum" + else + vm_next() +} + +function vm_may_decrease_prussian_collaboration() { + if (game.blue_momentum > 0) + game.state = "vm_may_decrease_prussian_collaboration" + else + vm_next() +} + function vm_operand_spaces(x) { let s = vm_operand(x) if (typeof s === "number") @@ -2995,6 +3009,40 @@ states.vm_decrease_prussian_collaboration = { }, } +states.vm_may_decrease_revolutionary_momentum = { + inactive: "decrease Revolutionary Momentum", + prompt() { + event_prompt("Decrease Revolutionary Momentum.") + view.actions.red_momentum = 1 + view.actions.pass = 1 + }, + red_momentum() { + push_undo() + decrease_revolutionary_momentum() + }, + pass() { + push_undo() + vm_next() + }, +} + +states.vm_may_decrease_prussian_collaboration = { + inactive: "decrease Prussian Collaboration", + prompt() { + event_prompt("Decrease Prussian Collaboration.") + view.actions.blue_momentum = 1 + view.actions.pass = 1 + }, + blue_momentum() { + push_undo() + decrease_prussian_collaboration() + }, + pass() { + push_undo() + vm_next() + }, +} + function can_vm_place() { for (let s of game.vm.spaces) if (can_place_cube(s, game.vm.removed)) @@ -4292,9 +4340,9 @@ CODE[39] = [ // Léon Gambetta [ vm_prompt, "Replace up to 1 in Institutional." ], [ vm_replace_up_to, 1, INSTITUTIONAL ], [ vm_if, ()=>(game.active === COMMUNE) ], - [ vm_decrease_prussian_collaboration ], + [ vm_may_decrease_prussian_collaboration ], [ vm_else ], - [ vm_decrease_revolutionary_momentum ], + [ vm_may_decrease_revolutionary_momentum ], [ vm_endif ], [ vm_return ], ] @@ -4458,9 +4506,9 @@ CODE[52] = [ // Rise of Republicanism CODE[53] = [ // Legitimacy [ vm_ops, 3, POLITICAL ], [ vm_if, ()=>(game.active === COMMUNE) ], - [ vm_increase_revolutionary_momentum ], + [ vm_may_increase_revolutionary_momentum ], [ vm_else ], - [ vm_increase_prussian_collaboration ], + [ vm_may_increase_prussian_collaboration ], [ vm_endif ], [ vm_return ], ] -- cgit v1.2.3