From 3646c0abaaf69b1453663313c0faf4499548bec4 Mon Sep 17 00:00:00 2001 From: iainp5 Date: Fri, 20 Sep 2024 14:20:46 +0100 Subject: Fix for remove_x_infl --- rules.js | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index 2b541da..25fc3d3 100644 --- a/rules.js +++ b/rules.js @@ -4160,20 +4160,41 @@ function vm_do_remove_infl(space) { function vm_do_remove_x_infl(space) { push_undo() const clicked_space = find_space_index(space) - log(`Removed ${game.vm_available_ops} influence from %${clicked_space}.`) if (game.remove_opponent_infl) { if (game.active === COM) { + if (game.pieces[clicked_space].demInfl >= game.vm_available_ops) { game.pieces[clicked_space].demInfl -= game.vm_available_ops + } else { + game.vm_available_ops = game.pieces[clicked_space].demInfl + game.pieces[clicked_space].demInfl -= game.vm_available_ops + } } else { - game.pieces[clicked_space].comInfl -= game.vm_available_ops + if (game.pieces[clicked_space].comInfl >= game.vm_available_ops) { + game.pieces[clicked_space].comInfl -= game.vm_available_ops + } else { + game.vm_available_ops = game.pieces[clicked_space].comInfl + game.pieces[clicked_space].comInfl -= game.vm_available_ops + } } } else { if (game.active === COM) { - game.pieces[clicked_space].comInfl -= game.vm_available_ops + if (game.pieces[clicked_space].comInfl >= game.vm_available_ops) { + game.pieces[clicked_space].comInfl -= game.vm_available_ops + } else { + game.vm_available_ops = game.pieces[clicked_space].comInfl + game.pieces[clicked_space].comInfl -= game.vm_available_ops + } } else { - game.pieces[clicked_space].demInfl -= game.vm_available_ops + if (game.pieces[clicked_space].demInfl >= game.vm_available_ops) { + game.pieces[clicked_space].demInfl -= game.vm_available_ops + } else { + game.vm_available_ops = game.pieces[clicked_space].demInfl + game.pieces[clicked_space].demInfl -= game.vm_available_ops + } } + + log(`Removed ${game.vm_available_ops} influence from %${clicked_space}`) } check_control_change(clicked_space) @@ -4957,6 +4978,7 @@ function vm_the_tyrant_is_gone() { game.playable_cards[41].playable = 0 game.playable_cards[101].playable = 0 game.playable_cards[107].playable = 0 + console.log('game.vm_event', game.vm_event) game.state = 'vm_the_tyrant_is_gone' } @@ -6805,6 +6827,7 @@ states.vm_the_tyrant_is_gone = { }, infl(space) { push_undo() + log(`The Ceausescus flee to %${space}`) game.persistent_events['the_tyrant_is_gone'] = find_space_index(space) }, done () { -- cgit v1.2.3