diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-12-15 18:19:30 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-01-08 16:36:48 +0100 |
commit | 508efabb4e9aa56aadb1f11d8590a87cd4fbde3e (patch) | |
tree | 69099a7a419adfe3022eea44bad02199ab72e826 | |
parent | cbfbf1e584bade8b681b1e460321b72fd667f809 (diff) | |
download | table-battles-508efabb4e9aa56aadb1f11d8590a87cd4fbde3e.tar.gz |
move sticks
-rw-r--r-- | rules.js | 31 |
1 files changed, 19 insertions, 12 deletions
@@ -521,6 +521,16 @@ function set_sticks(c, n) { map_set(game.sticks, c, n) } +function move_sticks(from, to, n) { + log("moved N sticks") + set_sticks(from, get_sticks(from) - n) + set_sticks(to, get_sticks(to) + n) +} + +function move_all_sticks(from, to) { + move_sticks(from, to, get_sticks(from)) +} + function get_shift_sticks(c) { if (game.shift) return map_get(game.shift, c, 0) @@ -1643,8 +1653,9 @@ states.s41_clerambault = { }, card(c) { if (c === S41_BLENHEIM_CARD) - set_sticks(S41_BLENHEIM_CARD, get_sticks(S41_BLENHEIM_CARD) + get_sticks(S41_CLERAMBAULT)) - set_sticks(S41_CLERAMBAULT, 0) + move_all_sticks(S41_CLERAMBAULT, S41_BLENHEIM_CARD) + else + set_sticks(S41_CLERAMBAULT, 0) if (c === S41_CLERAMBAULT) { rout_card(S41_CLERAMBAULT) game.morale[0]++ @@ -2233,8 +2244,7 @@ states.shift_to = { }, card(c) { game.target2 = c - set_sticks(game.selected, get_sticks(game.selected) - 1) - set_shift_sticks(game.target2, get_shift_sticks(game.target2) + 1) + move_sticks(game.selected, game.target2, 1) if (get_sticks(game.selected) === 1) this.next() }, @@ -2263,8 +2273,7 @@ states.s40_cassines = { }, card(c) { log(game.selected + " moved one stick from " + c) - set_sticks(c, get_sticks(c) - 1) - set_sticks(game.selected, get_sticks(game.selected) + 1) + move_sticks(c, game.selected, 1) end_action_phase() }, } @@ -2285,8 +2294,7 @@ states.s41_prince_eugene = { card(c) { game.target2 = c log(game.target2 + " moved one stick from " + game.selected) - set_sticks(game.selected, get_sticks(game.selected) - 1) - set_sticks(game.target2, get_sticks(game.target2) + 1) + move_sticks(game.selected, game.target2, 1) if (--game.self === 0) { pay_for_action(game.selected) end_action_phase() @@ -2307,8 +2315,7 @@ states.s42_marlborough = { }, card(c) { log(game.selected + " moved 4 sticks to " + c) - set_sticks(c, get_sticks(c) + 4) - set_sticks(S42_MARLBOROUGH, get_sticks(S42_MARLBOROUGH) - 4) + move_sticks(S42_MARLBOROUGH, c, 4) pay_for_action(S42_MARLBOROUGH) if (get_sticks(S42_MARLBOROUGH) === 0) remove_card(S42_MARLBOROUGH) @@ -3354,12 +3361,12 @@ function goto_routing() { if (is_card_in_play(S2_RUPERTS_LIFEGUARD)) { if (should_rout_card(S2_NORTHERN_HORSE)) { log("Rupert's Lifeguard added to Northern Horse.") - set_sticks(S2_NORTHERN_HORSE, 1) + move_all_sticks(S2_RUPERTS_LIFEGUARD, S2_NORTHERN_HORSE) remove_card(S2_RUPERTS_LIFEGUARD) } if (should_rout_card(S2_BYRON)) { log("Rupert's Lifeguard added to Byron.") - set_sticks(S2_BYRON, 1) + move_all_sticks(S2_RUPERTS_LIFEGUARD, S2_BYRON) remove_card(S2_RUPERTS_LIFEGUARD) } } |