summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-12-03 13:44:15 +0100
committerTor Andersson <tor@ccxvii.net>2023-12-03 13:44:24 +0100
commit04001db84cb251da84a9d6c4711258d447730d67 (patch)
tree247decfc7ae372941f2e3e7c2980bb0b9d8c7f8d
parent03af1575dad9e7aad2f92f932be2115adffb7d2a (diff)
downloadjulius-caesar-04001db84cb251da84a9d6c4711258d447730d67.tar.gz
Keep hands sorted.
-rw-r--r--rules.js22
1 files changed, 11 insertions, 11 deletions
diff --git a/rules.js b/rules.js
index 983749d..bac424f 100644
--- a/rules.js
+++ b/rules.js
@@ -225,7 +225,7 @@ function deal_cards(deck, n) {
if (events < max_events || deck[c] > 7) {
if (deck[c] <= 7)
++events
- hand.push(deck[c])
+ set_add(hand, deck[c])
deck.splice(c, 1)
}
}
@@ -957,35 +957,35 @@ states.discard_and_play_card = {
game.c_discard = c
else
game.c_card = c
- remove_from_array(game.c_hand, c)
+ set_delete(game.c_hand, c)
}
if (current === POMPEIUS) {
if (!game.p_discard)
game.p_discard = c
else
game.p_card = c
- remove_from_array(game.p_hand, c)
+ set_delete(game.p_hand, c)
}
resume_discard_and_play_card()
},
undo: function (_, current) {
if (current === CAESAR) {
if (game.c_discard) {
- game.c_hand.push(game.c_discard)
+ set_add(game.c_hand, game.c_discard)
game.c_discard = 0
}
if (game.c_card) {
- game.c_hand.push(game.c_card)
+ set_add(game.c_hand, game.c_card)
game.c_card = 0
}
}
if (current === POMPEIUS) {
if (game.p_discard) {
- game.p_hand.push(game.p_discard)
+ set_add(game.p_hand, game.p_discard)
game.p_discard = 0
}
if (game.p_card) {
- game.p_hand.push(game.p_card)
+ set_add(game.p_hand, game.p_card)
game.p_card = 0
}
}
@@ -1067,11 +1067,11 @@ states.play_card = {
},
card: function (card, current) {
if (current === CAESAR) {
- remove_from_array(game.c_hand, card)
+ set_delete(game.c_hand, card)
game.c_card = card
}
if (current === POMPEIUS) {
- remove_from_array(game.p_hand, card)
+ set_delete(game.p_hand, card)
game.p_card = card
}
resume_play_card()
@@ -1079,13 +1079,13 @@ states.play_card = {
undo: function (_, current) {
if (current === CAESAR) {
if (game.c_card) {
- game.c_hand.push(game.c_card)
+ set_add(game.c_hand, game.c_card)
game.c_card = 0
}
}
if (current === POMPEIUS) {
if (game.p_card) {
- game.p_hand.push(game.p_card)
+ set_add(game.p_hand, game.p_card)
game.p_card = 0
}
}