summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js31
1 files changed, 19 insertions, 12 deletions
diff --git a/rules.js b/rules.js
index 7cd1d5d..f3ff4b2 100644
--- a/rules.js
+++ b/rules.js
@@ -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)
}
}