summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rules.js51
1 files changed, 24 insertions, 27 deletions
diff --git a/rules.js b/rules.js
index b7de0e4..8399cad 100644
--- a/rules.js
+++ b/rules.js
@@ -9595,34 +9595,38 @@ exports.setup = function (seed, scenario, options) {
// ACTION HANDLERS
function clear_undo() {
- if (game.undo.length > 0)
+ if (game.undo && game.undo.length > 0)
game.undo.length = 0
}
function push_undo() {
- let copy = {}
- for (let k in game) {
- let v = game[k]
- if (k === "undo") continue
- else if (k === "log") v = v.length
- else if (k === "retro_foul_weather") v = 1
- else if (typeof v === "object" && v !== null) v = object_copy(v)
- copy[k] = v
+ if (game.undo) {
+ let copy = {}
+ for (let k in game) {
+ let v = game[k]
+ if (k === "undo") continue
+ else if (k === "log") v = v.length
+ else if (k === "retro_foul_weather") v = 1
+ else if (typeof v === "object" && v !== null) v = object_copy(v)
+ copy[k] = v
+ }
+ game.undo.push(copy)
}
- game.undo.push(copy)
}
function pop_undo() {
- let save_log = game.log
- let save_undo = game.undo
- let save_retro_fw = game.retro_foul_weather
- game = save_undo.pop()
- save_log.length = game.log
- game.log = save_log
- game.undo = save_undo
- if (game.retro_foul_weather)
- game.retro_foul_weather = save_retro_fw
- update_active_aliases()
+ if (game.undo) {
+ let save_log = game.log
+ let save_undo = game.undo
+ let save_retro_fw = game.retro_foul_weather
+ game = save_undo.pop()
+ save_log.length = game.log
+ game.log = save_log
+ game.undo = save_undo
+ if (game.retro_foul_weather)
+ game.retro_foul_weather = save_retro_fw
+ update_active_aliases()
+ }
}
function gen_action_undo() {
@@ -9715,13 +9719,6 @@ exports.query = function (state, current, q) {
return null
}
-exports.is_checkpoint = function (a, b) {
- let x = b.log[b.log.length-2]
- if (x === ".h2 Britain") return true
- if (x === ".h2 France") return true
- return false
-}
-
function inactive_prompt(name, who, where) {
view.prompt = `Waiting for ${game.active} \u2014 ${name}...`
if (who)