diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-01-02 19:39:47 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-02-18 12:42:59 +0100 |
commit | 756f8097d6225b3618c783cae68382d0569ac4c8 (patch) | |
tree | 8004f924e150013b949660b791274520bcb62289 /rules.js | |
parent | bd6d271455760a427d553ad4018b3f380dafc952 (diff) | |
download | 300-earth-and-water-756f8097d6225b3618c783cae68382d0569ac4c8.tar.gz |
Stable undo and fixes for replay.
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -258,7 +258,7 @@ function clear_undo() { function push_undo() { game.undo.push(JSON.stringify(game, (k,v) => { - if (k === 'undo') return undefined; + if (k === 'undo') return 0; if (k === 'log') return v.length; return v; })); @@ -267,7 +267,7 @@ function push_undo() { function pop_undo() { let save_undo = game.undo; let save_log = game.log; - Object.assign(game, JSON.parse(save_undo.pop())); + game = JSON.parse(save_undo.pop()); game.undo = save_undo; save_log.length = game.log; game.log = save_log; @@ -3362,7 +3362,7 @@ exports.action = function (state, current, action, arg) { S[action](arg, current); else throw new Error("Invalid action: " + action); - return state; + return game; } exports.resign = function (state, current) { @@ -3378,9 +3378,11 @@ exports.resign = function (state, current) { else game.result = PERSIA; } - return state; + return game; } +exports.checkpoints = [ "campaign" ]; + exports.view = function(state, current) { game = state; |