summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js55
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
+}