summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2025-04-30 00:40:08 +0200
committerTor Andersson <tor@ccxvii.net>2025-04-30 00:40:08 +0200
commita29b0162503248109344009351041dffa80d3418 (patch)
tree3f79b406ee8d5a4da6ef982f9793e96abfc2abe0
parentdd7f78c09e681b5f71366ec36b0c12f7b232772b (diff)
downloadrichard-iii-a29b0162503248109344009351041dffa80d3418.tar.gz
Multi-active instead of Both.HEADmaster
-rw-r--r--rules.js25
1 files changed, 13 insertions, 12 deletions
diff --git a/rules.js b/rules.js
index 54cc05f..8e86356 100644
--- a/rules.js
+++ b/rules.js
@@ -25,7 +25,10 @@ const LANCASTER = "Lancaster"
const YORK = "York"
const ENEMY = { Lancaster: "York", York: "Lancaster" }
const OBSERVER = "Observer"
-const BOTH = "Both"
+
+const MA_BOTH = [ "Lancaster", "York" ]
+const MA_LANCASTER = [ "Lancaster" ]
+const MA_YORK = [ "York" ]
const PLAYER_ID = { "": 0, Lancaster: 1, York: 2 }
const ID_PLAYER = [ "", "Lancaster", "York" ]
@@ -177,8 +180,12 @@ function print_turn_log(text) {
delete game.turn_log
}
+function is_active_player(current) {
+ return (game.active === current) || (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 remove_from_array(array, item) {
@@ -1438,18 +1445,18 @@ function goto_card_phase() {
game.y_card = 0
game.show_cards = false
game.state = 'play_card'
- game.active = BOTH
+ game.active = MA_BOTH
}
function resume_play_card() {
if (game.l_card > 0 && game.y_card > 0)
reveal_cards()
else if (game.l_card > 0)
- game.active = YORK
+ game.active = MA_YORK
else if (game.y_card > 0)
- game.active = LANCASTER
+ game.active = MA_LANCASTER
else
- game.active = BOTH
+ game.active = MA_BOTH
}
states.play_card = {
@@ -3517,12 +3524,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