summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2021-07-31 21:16:57 +0200
committerTor Andersson <tor@ccxvii.net>2022-11-16 19:08:56 +0100
commit490ba87ad66b69697eda6a793563cede5aa31660 (patch)
tree736f47e9a4c44dc9414c23d21893bf90b4b8749a
parent73c284a5b23b34312ffed427bc56ddbf9a645d91 (diff)
downloadjulius-caesar-490ba87ad66b69697eda6a793563cede5aa31660.tar.gz
caesar: More undo.
Allow undo back to movement phase from levy phase. Allow undo in the middle of a sea retreat.
-rw-r--r--rules.js17
1 files changed, 5 insertions, 12 deletions
diff --git a/rules.js b/rules.js
index 87811f0..bab18a1 100644
--- a/rules.js
+++ b/rules.js
@@ -1317,6 +1317,7 @@ states.move_who = {
game.state = 'move_where';
},
pass: function () {
+ push_undo();
end_movement();
},
undo: pop_undo,
@@ -1540,8 +1541,6 @@ function end_movement() {
game.moves = 0;
game.state = 'levy';
game.turn_log = [];
-
- clear_undo();
}
states.levy = {
@@ -2022,6 +2021,7 @@ states.retreat = {
space: function (to) {
let from = game.location[game.who];
if (is_sea(to) && !is_navis(game.who)) {
+ push_undo();
move_to(game.who, from, to);
game.sea_retreated = true;
game.state = 'sea_retreat';
@@ -2034,10 +2034,6 @@ states.retreat = {
resume_battle();
}
},
- pass: function () {
- eliminate_block(game.who);
- resume_battle();
- },
block: function () {
resume_battle();
},
@@ -2057,10 +2053,10 @@ states.sea_retreat = {
if (is_friendly_city(to))
gen_action(view, 'space', to);
}
- // TODO: check if there are any valid destinations before going to this state
- gen_action_pass(view, "Eliminate army");
+ gen_action(view, 'undo');
},
space: function (to) {
+ clear_undo();
let from = game.location[game.who];
game.flash = block_name(game.who) + " retreats.";
log_battle(game.flash);
@@ -2069,10 +2065,7 @@ states.sea_retreat = {
game.moved[game.who] = true;
resume_battle();
},
- pass: function () {
- eliminate_block(game.who);
- resume_battle();
- }
+ undo: pop_undo,
}
function goto_regroup() {