summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-05-15 12:50:46 +0200
committerTor Andersson <tor@ccxvii.net>2024-05-15 12:51:04 +0200
commita4d2ec9f722f39aa911744d93a8b1e997a76ac5b (patch)
tree4e2aa3d65ad10073054b1824798142cecce61c60
parentb7dc4ddf831eb2b5534558a28788f7a7af49009f (diff)
downloadplantagenet-a4d2ec9f722f39aa911744d93a8b1e997a76ac5b.tar.gz
drop battle_steps array
-rw-r--r--rules.js26
-rw-r--r--rules.ts27
2 files changed, 32 insertions, 21 deletions
diff --git a/rules.js b/rules.js
index 628ed0b..3fbb78d 100644
--- a/rules.js
+++ b/rules.js
@@ -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)
diff --git a/rules.ts b/rules.ts
index ba8972f..71e8de1 100644
--- a/rules.ts
+++ b/rules.ts
@@ -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)