diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-05-15 12:50:46 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-05-15 12:51:04 +0200 |
commit | a4d2ec9f722f39aa911744d93a8b1e997a76ac5b (patch) | |
tree | 4e2aa3d65ad10073054b1824798142cecce61c60 | |
parent | b7dc4ddf831eb2b5534558a28788f7a7af49009f (diff) | |
download | plantagenet-a4d2ec9f722f39aa911744d93a8b1e997a76ac5b.tar.gz |
drop battle_steps array
-rw-r--r-- | rules.js | 26 | ||||
-rw-r--r-- | rules.ts | 27 |
2 files changed, 32 insertions, 21 deletions
@@ -4963,11 +4963,6 @@ function log_lord_engage(lord) { log_lord_cap_ii(lord, AOW_LANCASTER_PIQUIERS); log_lord_cap_ii(lord, AOW_YORK_BARRICADES); } -const battle_steps = [ - null, - { name: "Missiles", hits: count_missile_hits }, - { name: "Melee", hits: count_melee_hits }, -]; function remove_lord_from_battle(lord) { if (set_has(game.battle.reserves, lord)) { array_remove(game.battle.reserves, lord); @@ -5032,11 +5027,19 @@ function count_melee_hits(lord) { } return hits; } -function count_lord_hits(lord) { - return battle_steps[game.battle.step].hits(lord); +function total_lord_hits(lord) { + let hits = 0; + if (is_missiles_step()) + hits += count_missile_hits(lord); + else + hits += count_melee_hits(lord); + return hits; } function format_strike_step() { - return battle_steps[game.battle.step].name; + if (is_missiles_step()) + return "Missiles"; + else + return "Melee"; } function format_hits() { if (game.active !== game.battle.attacker && game.battle.ahits > 0) @@ -6319,11 +6322,14 @@ function goto_total_hits() { } let ahits = 0; let dhits = 0; - log_h4(battle_steps[game.battle.step].name); + if (is_missiles_step()) + log_h4("Missiles"); + else + log_h4("Melee"); for (let pos of game.battle.engagements[0]) { let lord = game.battle.array[pos]; if (lord !== NOBODY) { - let hits = count_lord_hits(lord); + let hits = total_lord_hits(lord); log_hits(hits / 2, "L" + lord); hits += use_culverins(lord); if (pos === A1 || pos === A2 || pos === A3) @@ -5942,12 +5942,6 @@ function log_lord_engage(lord: Lord) { log_lord_cap_ii(lord, AOW_YORK_BARRICADES) } -const battle_steps = [ - null, - { name: "Missiles", hits: count_missile_hits }, - { name: "Melee", hits: count_melee_hits }, -] - function remove_lord_from_battle(lord) { if (set_has(game.battle.reserves, lord)) { array_remove(game.battle.reserves, lord) @@ -6022,12 +6016,20 @@ function count_melee_hits(lord: Lord) { return hits } -function count_lord_hits(lord: Lord) { - return battle_steps[game.battle.step].hits(lord) +function total_lord_hits(lord: Lord) { + let hits = 0 + if (is_missiles_step()) + hits += count_missile_hits(lord) + else + hits += count_melee_hits(lord) + return hits } function format_strike_step() { - return battle_steps[game.battle.step].name + if (is_missiles_step()) + return "Missiles" + else + return "Melee" } function format_hits() { @@ -7450,12 +7452,15 @@ function goto_total_hits() { let ahits = 0 let dhits = 0 - log_h4(battle_steps[game.battle.step].name) + if (is_missiles_step()) + log_h4("Missiles") + else + log_h4("Melee") for (let pos of game.battle.engagements[0]) { let lord = game.battle.array[pos] if (lord !== NOBODY) { - let hits = count_lord_hits(lord) + let hits = total_lord_hits(lord) log_hits(hits / 2, "L" + lord) hits += use_culverins(lord) if (pos === A1 || pos === A2 || pos === A3) |