diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-08-21 01:31:06 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-08-21 01:34:31 +0200 |
commit | 601c2f14aedd9ac91af4a1d953afe0bd57ee8ee2 (patch) | |
tree | b3c5942774900b5a95a359393aee726cbcb18072 | |
parent | ab77b0db66ee1583fe86d62eff337665a40b08aa (diff) | |
download | washingtons-war-601c2f14aedd9ac91af4a1d953afe0bd57ee8ee2.tar.gz |
fix game over prompt
-rw-r--r-- | rules.js | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -4471,6 +4471,7 @@ function automatic_victory() { game.active = "None" game.result = P_BRITAIN game.state = "game_over" + log("=! Game Over") log(game.victory) return true } @@ -4479,6 +4480,7 @@ function automatic_victory() { game.active = "None" game.result = P_AMERICA game.state = "game_over" + log("=! Game Over") log(game.victory) return true } @@ -4496,6 +4498,7 @@ function norths_government_falls() { else game.result = P_BRITAIN + log("=! Game Over") game.victory = "North's Government Falls: " + game.result + " Victory!" game.active = "None" game.state = "game_over" @@ -4539,10 +4542,10 @@ exports.setup = function (seed, scenario, options) { return game } -exports.action = function (state, current, action, arg) { +exports.action = function (state, player, action, arg) { game = state - if (current === game.active) { + if (player === game.active) { let S = states[game.state] if (action in S) { S[action](arg) @@ -4557,7 +4560,7 @@ exports.action = function (state, current, action, arg) { return game } -exports.view = function (state, current) { +exports.view = function (state, player) { game = state view = { @@ -4583,20 +4586,22 @@ exports.view = function (state, current) { move: game.move, } - if (current === P_AMERICA) + if (player === P_AMERICA) view.hand = game.a_hand - else if (current === P_BRITAIN) + else if (player === P_BRITAIN) view.hand = game.b_hand else view.hand = [] - if (current === game.active) { + if (game.active === player) { view.actions = {} states[game.state].prompt() if (game.undo && game.undo.length > 0) view.actions.undo = 1 else view.actions.undo = 0 + } else if (game.active === "None") { + view.prompt = game.victory } else { let inactive = states[game.state].inactive if (typeof inactive !== "string") |