From a29b0162503248109344009351041dffa80d3418 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 30 Apr 2025 00:40:08 +0200 Subject: Multi-active instead of Both. --- rules.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'rules.js') 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 -- cgit v1.2.3