diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-10-25 01:51:24 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-10-27 15:48:54 +0200 |
commit | e813dffc26d4ccd5d33a03e7f109e7348c9c03a6 (patch) | |
tree | 8c269a670b9ab115db4dd4c17fd90db6a1f66774 /rules.js | |
parent | 99679c974ef3658243b604b7096751f0367c3b2f (diff) | |
download | votes-for-women-e813dffc26d4ccd5d33a03e7f109e7348c9c03a6.tar.gz |
Add skeleton.
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/rules.js b/rules.js new file mode 100644 index 0000000..3486699 --- /dev/null +++ b/rules.js @@ -0,0 +1,55 @@ +"use strict" + +var game +var view +var states + +const SUF = "Suffragist" +const OPP = "Opposition" + +exports.scenarios = [ "Standard" ] +exports.roles = [ SUF, OPP ] + +exports.setup = function (seed, scenario, options) { + game = { + seed: seed, + log: [], + undo: [], + active: null, + state: null, + } + return game +} + +exports.action = function (state, current, action, arg) { + game = state + let S = states[game.state] + if (action in S) + S[action](arg, current) + else + throw new Error("Invalid action: " + action) + return game +} + +exports.resign = function (state, current) { + game = state + if (game.state !== "game_over") { + if (current === SUF) + goto_game_over(OPP, "Suffragist resigned.") + if (current === OPP) + goto_game_over(SUF, "Opposition resigned.") + } + return game +} + +exports.view = function(state, current) { + game = state + + let view = { + log: game.log, + prompt: null, + actions: null, + } + + return view +} |