diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-09-25 14:23:01 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-02-18 11:54:52 +0100 |
commit | 5a84afa4f4ae02dcc38cc752be4c2a7b801c7c4d (patch) | |
tree | 3f284a1b9bc81f105e8e8affba179076ea6220bc /rules.js | |
parent | f6f01f7536b21bdea793de78238f4deebc48572c (diff) | |
download | wilderness-war-5a84afa4f4ae02dcc38cc752be4c2a7b801c7c4d.tar.gz |
Space tool tips in log.
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 155 |
1 files changed, 81 insertions, 74 deletions
@@ -292,7 +292,7 @@ function print_plain_summary(verb, list) { function print_summary(summary, verb) { for (let s in summary) - log(verb + space_name(Number(s)) + "\n" + summary[s].join(",\n") + ".") + log(verb + "%" + s + "\n" + summary[s].join(",\n") + ".") } function flush_summary() { @@ -341,10 +341,10 @@ function push_go_home_summary(p, s) { if (game.summary) { if (!(s in game.summary.go_home)) game.summary.go_home[s] = [] - game.summary.go_home[s].push(piece_name_and_place(p)) + game.summary.go_home[s].push(log_piece_name_and_place(p)) } else { - // log(piece_name_and_place(p) + " went home to " + space_name(s) + ".") - log(piece_name_and_place(p) + " home to " + space_name(s) + ".") + // log(log_piece_name_and_place(p) + " went home to %" + s + ".") + log(log_piece_name_and_place(p) + " home to %" + s + ".") } } @@ -933,8 +933,13 @@ function piece_name(p) { return pieces[p].nb_desc } +function log_piece_name_and_place(p) { + // return piece_name(p) + " at %" + piece_space(p) + return piece_name(p) + " (%" + piece_space(p) + ")" +} + function piece_name_and_place(p) { - // return piece_name(p) + " at " + space_name(piece_space(p)) + // return piece_name(p) + " at %" + space_name(piece_space(p)) return piece_name(p) + " (" + space_name(piece_space(p)) + ")" } @@ -1132,20 +1137,20 @@ function has_fieldworks(s) { } function place_fieldworks(s) { - log(`Placed fieldworks at ${space_name(s)}.`) + log(`Placed fieldworks at %${s}.`) set_add(game.fieldworks, s) } function remove_fieldworks(s) { if (set_has(game.fieldworks, s)) { - // log(`Fieldworks (${space_name(s)}) removed.`) - log(`Removed fieldworks at ${space_name(s)}.`) + // log(`Fieldworks (%${s}) removed.`) + log(`Removed fieldworks at %${s}.`) set_delete(game.fieldworks, s) } } function place_friendly_raided_marker(s) { - log(`Placed raided marker at ${space_name(s)}.`) + log(`Placed raided marker at %${s}.`) set_add(player.raids, s) } @@ -1742,8 +1747,8 @@ function restore_unit(p) { if (game.summary && game.summary.restored) push_summary(game.summary.restored, p) else - // log(`Restored ${piece_name_and_place(p)}.`) - log(`${piece_name_and_place(p)} restored.`) + // log(`Restored ${log_piece_name_and_place(p)}.`) + log(`${log_piece_name_and_place(p)} restored.`) } function reduce_unit(p, verbose=true) { @@ -1754,8 +1759,8 @@ function reduce_unit(p, verbose=true) { if (game.summary && game.summary.reduced) push_summary(game.summary.reduced, p) else if (verbose) - // log(`Reduced ${piece_name_and_place(p)}.`) - log(`${piece_name_and_place(p)} reduced.`) + // log(`Reduced ${log_piece_name_and_place(p)}.`) + log(`${log_piece_name_and_place(p)} reduced.`) else // log(`Reduced ${piece_name(p)}.`) log(`${piece_name(p)} reduced.`) @@ -1767,8 +1772,8 @@ function eliminate_piece(p, verbose=true) { if (game.summary && game.summary.eliminated) push_summary(game.summary.eliminated, p) else if (verbose) - // log(`Eliminated ${piece_name_and_place(p)}.`) - log(`${piece_name_and_place(p)} eliminated.`) + // log(`Eliminated ${log_piece_name_and_place(p)}.`) + log(`${log_piece_name_and_place(p)} eliminated.`) else // log(`Eliminated ${piece_name(p)}.`) log(`${piece_name(p)} eliminated.`) @@ -1816,8 +1821,8 @@ function place_piece(who, to) { if (game.summary && game.summary.placed) push_summary(game.summary.placed, who) else - // log(`Placed ${piece_name_and_place(who)}.`) - log(`${piece_name_and_place(who)} placed.`) + // log(`Placed ${log_piece_name_and_place(who)}.`) + log(`${log_piece_name_and_place(who)} placed.`) // remember last placed 7-command leader(s) if (is_seven_command_leader(who)) { @@ -1848,55 +1853,55 @@ function place_piece(who, to) { } function capture_enemy_fortress(s) { - log(`Captured fortress at ${space_name(s)}.`) + log(`Captured fortress at %${s}.`) set_delete(enemy_player.fortresses, s) set_add(player.fortresses, s) award_vp(3) } function recapture_french_fortress(s) { - log(`France recaptured fortress at ${space_name(s)}.`) + log(`France recaptured fortress at %${s}.`) set_delete(game.british.fortresses, s) set_add(game.french.fortresses, s) award_french_vp(3) } function recapture_british_fortress(s) { - log(`Britain recaptured fortress at ${space_name(s)}.`) + log(`Britain recaptured fortress at %${s}.`) set_delete(game.french.fortresses, s) set_add(game.british.fortresses, s) award_british_vp(3) } function capture_enemy_fort_intact(s) { - log(`Captured intact fort at ${space_name(s)}.`) + log(`Captured intact fort at %${s}.`) set_delete(enemy_player.forts, s) set_add(player.forts, s) award_vp(2) } function capture_enemy_fort(s) { - log(`Captured fort at ${space_name(s)}.`) + log(`Captured fort at %${s}.`) set_delete(enemy_player.forts, s) set_add(player.forts_uc, s) award_vp(2) } function capture_enemy_stockade(s) { - log(`Captured stockade at ${space_name(s)}.`) + log(`Captured stockade at %${s}.`) set_delete(enemy_player.stockades, s) set_add(player.stockades, s) award_vp(1) } function destroy_enemy_stockade_after_battle(s) { - log(`Destroyed stockade at ${space_name(s)}.`) + log(`Destroyed stockade at %${s}.`) set_delete(enemy_player.stockades, s) award_vp(1) } function destroy_enemy_stockade_in_raid(s) { - log(`Destroyed stockade at ${space_name(s)}.`) + log(`Destroyed stockade at %${s}.`) set_delete(enemy_player.stockades, s) } @@ -1917,7 +1922,7 @@ function lift_sieges_and_amphib() { // Lift sieges for_each_siege(s => { if (is_fort_or_fortress_vacant_of_besieging_units(s)) { - log(`Lifted siege at ${space_name(s)}.`) + log(`Lifted siege at %${s}.`) for (let p = 1; p <= last_piece; ++p) if (is_piece_in_space(p, s)) set_piece_outside(p) @@ -1930,7 +1935,7 @@ function lift_sieges_and_amphib() { let s = game.amphib[i] if (!has_british_units(s)) { if (has_french_drilled_troops(s) || (s !== LOUISBOURG && has_unbesieged_french_fortification(s))) { - log(`Removed Amphib at ${space_name(s)}.`) + log(`Removed Amphib at %${s}.`) game.amphib.splice(i, 1) } } @@ -1947,13 +1952,13 @@ function lift_sieges_and_amphib() { // Remove forts u/c if solely occupied by enemy drilled troops for (let s of player.forts_uc) { if (has_enemy_drilled_troops(s) && !has_friendly_units(s)) { - log(`Removed fort u/c at ${space_name(s)}.`) + log(`Removed fort u/c at %${s}.`) remove_friendly_fort_uc(s) } } for (let s of enemy_player.forts_uc) { if (has_friendly_drilled_troops(s) && !has_enemy_units(s)) { - log(`Removed fort u/c at ${space_name(s)}.`) + log(`Removed fort u/c at %${s}.`) remove_enemy_fort_uc(s) } } @@ -1968,13 +1973,13 @@ function update_vp(name, s) { let br = has_british_units(s) || has_british_fortifications(s) if (fr && !br) { if (game[name] < 0) { - log("France captured " + space_name(s) + ".") + log(`France captured %${s}.`) award_french_vp(1) game[name] = 1 } } else if (br && !fr) { if (game[name] > 0) { - log("Britain captured " + space_name(s) + ".") + log(`Britain captured %${s}.`) award_british_vp(1) game[name] = -1 } @@ -2462,7 +2467,7 @@ states.select_campaign_2 = { function goto_pick_first_move() { if (game.activation.length > 1) { logbr() - log("Selected\n" + game.activation.map(piece_name_and_place).join(",\n") + ".") + log("Selected\n" + game.activation.map(log_piece_name_and_place).join(",\n") + ".") game.state = 'pick_move' } else { goto_move_piece(game.activation.pop()) @@ -2770,14 +2775,14 @@ states.designate_force_lone_ax = { function describe_force(force, verbose) { if (is_leader(force) && count_pieces_in_force(force) > 1) { - let desc = verbose ? piece_name_and_place(force) : piece_name(force) + let desc = verbose ? log_piece_name_and_place(force) : piece_name(force) for_each_piece_in_force(force, p => { if (p !== force) desc += ",\n" + piece_name(p) }) return desc } else { - return verbose ? piece_name_and_place(force) : piece_name(force) + return verbose ? log_piece_name_and_place(force) : piece_name(force) } } @@ -3211,9 +3216,9 @@ function apply_move(to) { } if (game.move.infiltrated) - log(`Infiltrated ${space_name(to)}.`) + log(`Infiltrated %${to}.`) else - log(`Moved to ${space_name(to)}.`) + log(`Moved to %${to}.`) move_piece_to(who, to) lift_sieges_and_amphib() @@ -3529,7 +3534,7 @@ states.lake_schooner = { set_active_enemy() - log(`${piece_name(who)} stopped at ${space_name(from)}.`) + log(`${piece_name(who)} stopped at %${from}.`) if (would_be_infiltration_move(who, from, to)) { // 6.63 eliminate if forced back into enemy-occupied space during infiltration @@ -3585,7 +3590,7 @@ function remove_siege_marker(where) { } function place_siege_marker(where) { - log(`Started siege at ${space_name(where)}.`) + log(`Started siege at %${where}.`) game.sieges[where] = 0 } @@ -4068,7 +4073,7 @@ states.avoid_to = { } }, space(to) { - log(`Avoided to ${space_name(to)}.`) + log(`Avoided to %${to}.`) end_avoid_battle_success(to) }, } @@ -4200,9 +4205,9 @@ function combat_result(die, str, shift) { function goto_battle(where, is_assault) { logbr() if (is_assault) - log(".assault " + space_name(where)) + log(".assault %" + where) else if (game.raid.where !== where) - log(".battle " + space_name(where)) + log(".battle %" + where) logbr() game.battle = { @@ -4244,7 +4249,7 @@ function goto_battle(where, is_assault) { if (game.activation) { for_each_attacking_piece(p => { if (game.activation.includes(p)) { - log(`Deactivated ${piece_name_and_place(p)}.`) + log(`Deactivated ${log_piece_name_and_place(p)}.`) remove_from_array(game.activation, p) unstack_force(p) } @@ -4587,6 +4592,7 @@ states.attacker_events = { if (have.length === 0 && dont_have.length === 0) view.prompt += " You have no more response events." gen_action_pass() + gen_action_next() // XXX }, play_event(c) { push_undo() @@ -4659,6 +4665,7 @@ states.defender_events = { if (have.length === 0 && dont_have.length === 0) view.prompt += " You have no more response events." gen_action_pass() + gen_action_next() // XXX }, play_event(c) { push_undo() @@ -5376,7 +5383,7 @@ states.retreat_attacker = { for_each_friendly_piece_in_space(from, p => { if (is_piece_unbesieged(p)) { if (can_attacker_retreat_from_to(p, from, to)) { - push_retreat_summary(p, "to " + space_name(to)) + push_retreat_summary(p, "to %" + to) move_piece_to(p, to) } else { eliminate_piece(p, false) @@ -5565,7 +5572,7 @@ states.retreat_defender_to = { push_retreat_summary(who, "into fort") set_piece_inside(who) } else { - push_retreat_summary(who, "to " + space_name(to)) + push_retreat_summary(who, "to %" + to) move_piece_to(who, to) } game.state = 'retreat_defender' @@ -5607,7 +5614,7 @@ states.retreat_all_defenders_to = { } } else { if (can_defender_retreat_from_to(p, from, to)) { - push_retreat_summary(p, "to " + space_name(to)) + push_retreat_summary(p, "to %" + to) move_piece_to(p, to) } else { done = false @@ -5697,7 +5704,7 @@ states.retreat_lone_leader = { log(`${piece_name(who)} retreated into fort.`) set_piece_inside(who) } else { - log(`${piece_name(who)} retreated to ${space_name(to)}.`) + log(`${piece_name(who)} retreated to %${to}.`) move_piece_to(who, to) } resume_retreat_lone_leader(from) @@ -5913,7 +5920,7 @@ const SIEGE_TABLE_RESULT = { function resolve_siege() { let where = game.siege_where logbr() - log(".siege " + space_name(where)) + log(".siege %" + where) logbr() let att_leader = find_friendly_commanding_leader_in_space(where) let def_leader = find_enemy_commanding_leader_in_space(where) @@ -5978,7 +5985,7 @@ states.assault_possible = { pass() { let where = game.assault_possible delete game.assault_possible - log("Did not assault " + space_name(where)) + log("Did not assault %" + where) end_move_step(true) }, } @@ -6009,7 +6016,7 @@ states.pick_raid = { }, space(s) { logbr() - log(".raid " + space_name(s)) + log(".raid %" + s) logbr() game.raid.where = s remove_from_array(game.raid.list, s) @@ -6780,14 +6787,14 @@ states.demolish_fort = { }, space(s) { if (has_friendly_fort_uc(s)) { - log(`Demolished fort U/C at\n${space_name(s)}.`) - // log(`Fort U/C (${space_name(s)}) demolished.`) - // log(`Fort U/C at ${space_name(s)} demolished.`) + log(`Demolished fort U/C at\n%${s}.`) + // log(`Fort U/C (%${s}) demolished.`) + // log(`Fort U/C at %${s} demolished.`) remove_friendly_fort_uc(s) } else if (has_friendly_fort(s)) { - log(`Demolished fort at\n${space_name(s)}.`) - // log(`Fort (${space_name(s)}) demolished.`) - // log(`Fort at ${space_name(s)} demolished.`) + log(`Demolished fort at\n%${s}.`) + // log(`Fort (%${s}) demolished.`) + // log(`Fort at %${s} demolished.`) award_vp(-1) remove_friendly_fort(s) } @@ -6803,10 +6810,10 @@ states.demolish_stockade = { gen_action_space(s) }, space(s) { - log(`Demolished stockade at\n${space_name(s)}.`) - // log(`Stockade (${space_name(s)}) demolished.`) - // log(`Stockade at ${space_name(s)} demolished.`) - // log(`Demolished stockade (${space_name(s)}).`) + log(`Demolished stockade at\n%${s}.`) + // log(`Stockade (%${s}) demolished.`) + // log(`Stockade at %${s} demolished.`) + // log(`Demolished stockade (%${s}).`) remove_friendly_stockade(s) end_demolish() } @@ -6870,9 +6877,9 @@ states.construct_stockades = { }, space(s) { push_undo() - log(`Stockade at ${space_name(s)}.`) - // log(`Constructed stockade at ${space_name(s)}.`) - // log(`Stockade at ${space_name(s)} constructed.`) + log(`Stockade at %${s}.`) + // log(`Constructed stockade at %${s}.`) + // log(`Stockade at %${s} constructed.`) set_add(player.stockades, s) game.count -- }, @@ -6920,14 +6927,14 @@ states.construct_forts = { space(s) { push_undo() if (has_friendly_fort_uc(s)) { - // log(`Finished building fort at ${space_name(s)}.`) - // log(`Fort (${space_name(s)}) built.`) - log(`Fort at ${space_name(s)}.`) + // log(`Finished building fort at %${s}.`) + // log(`Fort (%${s}) built.`) + log(`Fort at %${s}.`) place_friendly_fort(s) } else { - // log(`Started building fort at ${space_name(s)}.`) - // log(`Fort U/C (${space_name(s)}) built.`) - log(`Fort U/C at ${space_name(s)}.`) + // log(`Started building fort at %${s}.`) + // log(`Fort U/C (%${s}) built.`) + log(`Fort U/C at %${s}.`) place_friendly_fort_uc(s) game.list.push(s) // don't finish it in the same action phase } @@ -7061,10 +7068,10 @@ states.massacre_2 = { } } if (done) { - view.prompt = `Massacre! Eliminate all indians in ${space_name(s)} \u2014 done.` + view.prompt = `Massacre! Eliminate all indians in %${s} \u2014 done.` gen_action_next() } else { - view.prompt = `Massacre! Eliminate all indians in ${space_name(s)}.` + view.prompt = `Massacre! Eliminate all indians in %${s}.` } }, piece(p) { @@ -7633,8 +7640,8 @@ states.governor_vaudreuil_interferes = { let p_loc = piece_space(p) move_piece_to(a, p_loc) move_piece_to(p, a_loc) - log(`${piece_name(a)} moved to ${space_name(p_loc)}.`) - log(`${piece_name(p)} moved to ${space_name(a_loc)}.`) + log(`${piece_name(a)} moved to %${p_loc}.`) + log(`${piece_name(p)} moved to %${a_loc}.`) game.count = 0 } else { push_undo() @@ -7666,7 +7673,7 @@ states.small_pox = { gen_action_space(s) }, space(s) { - log(`Small Pox at ${space_name(s)}.`) + log(`Small Pox at %${s}.`) let roll = roll_die() if (count_units_in_space(s) > 8) { game.count = roll @@ -8219,7 +8226,7 @@ states.bastions_repaired = { }, space(s) { push_undo() - log(`Replaced siege marker at ${space_name(s)} with siege 0.`) + log(`Replaced siege marker at %${s} with siege 0.`) game.sieges[s] = 0 game.count = 0 }, |