From 490ba87ad66b69697eda6a793563cede5aa31660 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 31 Jul 2021 21:16:57 +0200 Subject: caesar: More undo. Allow undo back to movement phase from levy phase. Allow undo in the middle of a sea retreat. --- rules.js | 17 +++++------------ 1 file 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() { -- cgit v1.2.3