diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-05-26 00:05:21 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-05-30 21:59:25 +0200 |
commit | 97523a133617a632c9d688b2813388e9ac2a13f9 (patch) | |
tree | ce8cdc40075b64afad1a8a5a07020cc2f531813e | |
parent | a2d8f09c71c67507f1761e29f084571fb059d819 (diff) | |
download | friedrich-97523a133617a632c9d688b2813388e9ac2a13f9.tar.gz |
count entire stack for add new troop / remove troop events
-rw-r--r-- | rules.js | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -80,7 +80,7 @@ function find_city_list(names) { return list } -let suit_name = [ "\u2660", "\u2663", "\u2665", "\u2666", "\u2641" ] +let suit_name = [ "\u2660", "\u2663", "\u2665", "\u2666", "R" ] const P_PRUSSIA = 0 const P_HANOVER = 1 @@ -3420,6 +3420,13 @@ function if_hildburghausen_has_lost_a_battle_this_turn_prussia_may_move_him_2_ci resume_start_turn() } +function can_add_troop_to_stack(s) { + for (let p of all_generals) + if (game.pos[p] === s && game.troops[p] < 8) + return true + return false +} + function goto_receive_a_new_troop(power, list) { set_active_to_power(power) @@ -3430,7 +3437,7 @@ function goto_receive_a_new_troop(power, list) { game.selected = [] for (let p of list) - if (game.pos[p] < ELIMINATED && game.troops[p] < 8) + if (game.pos[p] < ELIMINATED && can_add_troop_to_stack(game.pos[p])) game.selected.push(p) if (game.selected.length > 0) { @@ -3452,12 +3459,19 @@ states.receive_a_new_troop = { } } +function can_remove_troop_from_stack(s) { + for (let p of all_generals) + if (game.pos[p] === s && game.troops[p] > 1) + return true + return false +} + function goto_lose_one_troop(power, list) { set_active_to_power(power) game.selected = [] for (let p of list) - if (game.pos[p] < ELIMINATED && game.troops[p] > 1) + if (game.pos[p] < ELIMINATED && can_remove_troop_from_stack(game.pos[p])) game.selected.push(p) if (game.selected.length > 0) { |