summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2025-04-30 00:33:56 +0200
committerTor Andersson <tor@ccxvii.net>2025-04-30 00:33:56 +0200
commit9885a38b819dcd4201315ca44d7be988f8043831 (patch)
tree9ae1da00652baab5eeea7eec81e531bf00156b16
parent1efca1b4e306eee5276ead51393ae6b2b310cbc6 (diff)
downloadcrusader-rex-9885a38b819dcd4201315ca44d7be988f8043831.tar.gz
Multi-active instead of Both.
-rw-r--r--rules.js25
1 files changed, 13 insertions, 12 deletions
diff --git a/rules.js b/rules.js
index fafb124..0884dba 100644
--- a/rules.js
+++ b/rules.js
@@ -24,7 +24,10 @@ const { CARDS, BLOCKS, TOWNS, PORTS, ROADS, SHIELDS, block_index, town_index } =
const FRANKS = "Franks"
const SARACENS = "Saracens"
const OBSERVER = "Observer"
-const BOTH = "Both"
+
+const MA_FRANKS = [ "Franks" ]
+const MA_SARACENS = [ "Saracens" ]
+const MA_BOTH = [ "Franks", "Saracens" ]
const NOWHERE = 0
const DEAD = 1
@@ -217,8 +220,12 @@ function enemy(p) {
return null
}
+function is_active_player(current) {
+ return current === game.active || (Array.isArray(game.active) && game.active.includes(current))
+}
+
function is_inactive_player(current) {
- return current === OBSERVER || (game.active !== current && game.active !== BOTH)
+ return !is_active_player(current)
}
function is_winter() {
@@ -1233,18 +1240,18 @@ function goto_card_phase() {
game.s_card = 0
game.show_cards = false
game.state = 'play_card'
- game.active = BOTH
+ game.active = MA_BOTH
}
function resume_play_card() {
if (game.s_card && game.f_card)
reveal_cards()
else if (game.f_card)
- game.active = SARACENS
+ game.active = MA_SARACENS
else if (game.s_card)
- game.active = FRANKS
+ game.active = MA_FRANKS
else
- game.active = BOTH
+ game.active = MA_BOTH
}
states.play_card = {
@@ -3981,12 +3988,6 @@ function observer_hand() {
return hand
}
-exports.dont_snap = function(state) {
- if (state.state === "play_card" && state.active !== BOTH)
- return true
- return false
-}
-
exports.view = function(state, current) {
game = state