diff options
-rw-r--r-- | rules.js | 25 |
1 files changed, 13 insertions, 12 deletions
@@ -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 |