diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-03-28 00:45:31 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-02-18 11:54:52 +0100 |
commit | 1152edf9b51d381a8dc21712b1a731d73a46def2 (patch) | |
tree | 337a498231611db581d3224238ca26731dad10d5 | |
parent | 5dc6a538bd9e966b3b4e090ac8dcdb566a96b97a (diff) | |
download | wilderness-war-1152edf9b51d381a8dc21712b1a731d73a46def2.tar.gz |
Don't print empty summaries and clean up some messages.
-rw-r--r-- | rules.js | 40 |
1 files changed, 18 insertions, 22 deletions
@@ -278,6 +278,14 @@ function push_summary(summary, p) { summary[s].push(piece_name(p)); } +function print_plain_summary(verb, list) { + if (game.summary) { + if (game.summary[list].length > 0) + log(verb + "\n" + game.summary[list].sort((a,b)=>a-b).map(piece_name).join(",\n") + "."); + delete game.summary[list]; + } +} + function print_summary(summary, verb) { for (let s in summary) log(verb + space_name(Number(s)) + "\n" + summary[s].join(",\n") + "."); @@ -2690,7 +2698,7 @@ function describe_force(force, verbose) { }); return desc; } else { - return piece_name_and_place(force); + return verbose ? piece_name_and_place(force) : piece_name(force); } } @@ -3298,10 +3306,7 @@ states.drop_off = { }, next() { push_undo(); - if (game.summary) { - log("Dropped off\n" + game.summary.drop_off.sort((a,b)=>a-b).map(piece_name).join(",\n") + "."); - delete game.summary.drop_off; - } + print_plain_summary("Dropped off", 'drop_off'); resume_move(); }, demolish_fort: goto_demolish_fort, @@ -3800,13 +3805,10 @@ states.designate_inside = { }, next() { clear_undo(); - if (game.summary) { - if (is_fortress(moving_piece_space())) - log("Withdrew into fortress with\n" + game.summary.inside.sort((a,b)=>a-b).map(piece_name).join(",\n") + "."); - else - log("Withdrew into fort with\n" + game.summary.inside.sort((a,b)=>a-b).map(piece_name).join(",\n") + "."); - delete game.summary.inside; - } + if (is_fortress(moving_piece_space())) + print_plain_summary("Withdrew into fortress", 'inside'); + else + print_plain_summary("Withdrew into fort", 'inside'); set_active_enemy(); goto_avoid_battle(); }, @@ -3882,12 +3884,12 @@ function attempt_avoid_battle() { // 6.8 Exception: Auxiliary and all-Auxiliary forces automatically succeed. if (is_wilderness_or_mountain(from) && force_has_only_auxiliary_units(who)) { - log("Avoided battle from " + spaces[from].type + "\n" + describe_force(who, false) + "."); + log("Auxiliaries avoided battle\n" + describe_force(who, false) + "."); game.state = 'avoid_to'; return; } - let die = roll_die("to avoid battle with\n" + describe_force(who, false)); + let die = roll_die("to avoid battle\n" + describe_force(who, false)); if (is_leader(who)) die = modify(die, leader_tactics(who), "leader tactics"); if (die >= 4) { @@ -4225,10 +4227,7 @@ states.militia_in_battle = { log(`Deployed ${piece_name(p)}.`); }, next() { - if (game.summary) { - log("Deployed\n" + game.summary.deploy.sort((a,b)=>a-b).map(piece_name).join(",\n") + "."); - delete game.summary.deploy; - } + print_plain_summary("Deployed", 'deploy'); clear_undo(); goto_battle_sortie(); }, @@ -4292,10 +4291,7 @@ states.sortie = { }, next() { clear_undo(); - if (game.summary) { - log("Sortied with\n" + game.summary.sortie.sort((a,b)=>a-b).map(piece_name).join(",\n") + "."); - delete game.summary.inside; - } + print_plain_summary("Sortied", 'sortie'); goto_battle_attacker_events(); }, } |