summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js11
1 files changed, 6 insertions, 5 deletions
diff --git a/rules.js b/rules.js
index e28b9fa..75f2329 100644
--- a/rules.js
+++ b/rules.js
@@ -165,7 +165,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;
}));
@@ -174,7 +174,7 @@ function push_undo() {
function pop_undo() {
let undo = game.undo;
let save_log = game.log;
- Object.assign(game, JSON.parse(undo.pop()));
+ game = JSON.parse(undo.pop());
game.undo = undo;
save_log.length = game.log;
game.log = save_log;
@@ -3737,7 +3737,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) {
@@ -3750,7 +3750,7 @@ exports.resign = function (state, current) {
game.victory = current + " resigned.";
game.result = enemy(current);
}
- return state;
+ return game;
}
function make_siege_view() {
@@ -3768,6 +3768,8 @@ function observer_hand() {
return hand;
}
+exports.is_checkpoint = (a, b) => a.turn !== b.turn;
+
exports.view = function(state, current) {
game = state;
@@ -3786,7 +3788,6 @@ exports.view = function(state, current) {
location: game.location,
castle: game.castle,
steps: game.steps,
- reserves: game.reserves1.concat(game.reserves2),
moved: game.moved,
sieges: make_siege_view(),
battle: null,