summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2021-07-02 13:55:02 +0200
committerTor Andersson <tor@ccxvii.net>2022-11-16 19:08:56 +0100
commit31ad77310f0f0e92635d1d4ce16889b7f225ce09 (patch)
tree8ccb9d456a14352a7cbe218e47a65817cba21044
parentf20c5cc5fb0526b5bb9f74393582301ecaebefab (diff)
downloadjulius-caesar-31ad77310f0f0e92635d1d4ce16889b7f225ce09.tar.gz
Improve logging of block retreats.
Print which block retreats during the round. Print summary of retreat destinations at the end of the round.
-rw-r--r--rules.js31
1 files changed, 17 insertions, 14 deletions
diff --git a/rules.js b/rules.js
index 1e48f53..7caad70 100644
--- a/rules.js
+++ b/rules.js
@@ -74,11 +74,10 @@ function log_levy(where) {
game.turn_log.push([where]);
}
-function print_turn_log(verb) {
+function print_turn_log_no_active(text) {
function print_move(last) {
return "\n" + n + " " + last.join(" \u2192 ");
}
- let text = game.active + " " + verb + ":";
game.turn_log.sort();
let last = game.turn_log[0];
let n = 0;
@@ -98,6 +97,10 @@ function print_turn_log(verb) {
delete game.turn_log;
}
+function print_turn_log(verb) {
+ print_turn_log_no_active(game.active + " " + verb + ":");
+}
+
function is_active_player(current) {
return (current == game.active) || (game.active == BOTH && (current == CAESAR || current == POMPEIUS));
}
@@ -1697,14 +1700,6 @@ function resume_battle() {
pump_battle_round();
}
-function end_battle() {
- game.flash = "";
- game.battle_round = 0;
- reset_road_limits();
- game.moved = {};
- goto_regroup();
-}
-
function disrupt_attacking_reserves() {
for (let b in BLOCKS)
if (game.location[b] == game.where && block_owner(b) == game.attacker[game.where])
@@ -1722,6 +1717,10 @@ function bring_on_reserves() {
function start_battle_round() {
if (++game.battle_round <= 4) {
+ if (game.turn_log && game.turn_log.length > 0)
+ print_turn_log_no_active("Retreats from " + game.where + ":");
+ game.turn_log = [];
+
reset_road_limits();
game.moved = {};
@@ -1807,6 +1806,8 @@ function pump_battle_round() {
}
function end_battle() {
+ if (game.turn_log && game.turn_log.length > 0)
+ print_turn_log_no_active("Retreats from " + game.where + ":");
if (game.surprise == game.where)
game.surprise = 0;
game.flash = "";
@@ -2029,9 +2030,10 @@ states.retreat = {
game.sea_retreated = true;
game.state = 'sea_retreat';
} else {
- logp("retreats to " + to + ".");
move_to(game.who, from, to);
- game.flash = block_name(game.who) + " retreats to " + to + ".";
+ game.flash = block_name(game.who) + " retreats.";
+ log_battle(game.flash);
+ game.turn_log.push([game.active, to]);
game.moved[game.who] = true;
resume_battle();
}
@@ -2064,8 +2066,9 @@ states.sea_retreat = {
},
space: function (to) {
let from = game.location[game.who];
- logp("sea retreats to " + to + ".");
- game.flash = block_name(game.who) + " sea retreats to " + to + ".";
+ game.flash = block_name(game.who) + " retreats by sea.";
+ log_battle(game.flash);
+ game.turn_log.push([game.active, from, to]);
move_to(game.who, from, to);
game.moved[game.who] = true;
resume_battle();