summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-05-15 13:51:56 +0200
committerTor Andersson <tor@ccxvii.net>2024-05-15 13:51:56 +0200
commit8492a7bc6fb763d12c8669e6bf4e1f08d595e6fd (patch)
treebb12e088a47ea79ed8b6982f86795eb20187a4a0
parent183ba1599a65e06bc607704ae3db58165f4d1533 (diff)
downloadplantagenet-8492a7bc6fb763d12c8669e6bf4e1f08d595e6fd.tar.gz
1/2 missile hits after totaling engagement
-rw-r--r--rules.js57
-rw-r--r--rules.ts55
2 files changed, 65 insertions, 47 deletions
diff --git a/rules.js b/rules.js
index 3fbb78d..6025895 100644
--- a/rules.js
+++ b/rules.js
@@ -4986,10 +4986,10 @@ function set_active_attacker() {
set_active(game.battle.attacker);
}
function set_active_defender() {
- if (game.battle.attacker === P1)
- set_active(P2);
+ if (game.battle.attacker === YORK)
+ set_active(LANCASTER);
else
- set_active(P1);
+ set_active(YORK);
}
function filled(pos) {
let lord = game.battle.array[pos];
@@ -5003,10 +5003,6 @@ function count_missile_hits(lord) {
hits += get_lord_forces(lord, BURGUNDIANS) << 2;
hits += get_lord_forces(lord, MILITIA);
hits += get_lord_forces(lord, MERCENARIES);
- if (is_leeward_battle_line_in_play(lord)) {
- // half rounded up!
- return (hits + 1) >> 1;
- }
return hits;
}
function count_melee_hits(lord) {
@@ -5033,6 +5029,8 @@ function total_lord_hits(lord) {
hits += count_missile_hits(lord);
else
hits += count_melee_hits(lord);
+ log_hits(hits / 2, "L" + lord);
+ hits += use_culverins(lord);
return hits;
}
function format_strike_step() {
@@ -5706,22 +5704,13 @@ function end_for_trust_not_him() {
resume_battle_events();
}
// === BATTLE EVENT: LEEWARD BATTLE LINE ===
-function is_leeward_battle_line_in_play(lord) {
- if (is_missiles_step()) {
- if (is_event_in_play(EVENT_LANCASTER_LEEWARD_BATTLE_LINE)
- && !is_event_in_play(EVENT_YORK_LEEWARD_BATTLE_LINE)
- && is_york_lord(lord)) {
- logevent(EVENT_LANCASTER_LEEWARD_BATTLE_LINE);
- return true;
- }
- if (is_event_in_play(EVENT_YORK_LEEWARD_BATTLE_LINE)
- && !is_event_in_play(EVENT_LANCASTER_LEEWARD_BATTLE_LINE)
- && is_lancaster_lord(lord)) {
- logevent(EVENT_YORK_LEEWARD_BATTLE_LINE);
- return true;
- }
- }
- return false;
+function is_york_leeward_battle_line_in_play() {
+ return (is_event_in_play(EVENT_YORK_LEEWARD_BATTLE_LINE) &&
+ !is_event_in_play(EVENT_LANCASTER_LEEWARD_BATTLE_LINE));
+}
+function is_lancaster_leeward_battle_line_in_play() {
+ return (is_event_in_play(EVENT_LANCASTER_LEEWARD_BATTLE_LINE) &&
+ !is_event_in_play(EVENT_YORK_LEEWARD_BATTLE_LINE));
}
// === BATTLE EVENT: REGROUP ===
function is_regroup_in_play() {
@@ -6330,14 +6319,32 @@ function goto_total_hits() {
let lord = game.battle.array[pos];
if (lord !== NOBODY) {
let hits = total_lord_hits(lord);
- log_hits(hits / 2, "L" + lord);
- hits += use_culverins(lord);
+ if (is_missiles_step()) {
+ if (is_york_lord(lord) && is_lancaster_leeward_battle_line_in_play())
+ logii("\xbd E" + EVENT_LANCASTER_LEEWARD_BATTLE_LINE);
+ if (is_lancaster_lord(lord) && is_york_leeward_battle_line_in_play())
+ logii("\xbd E" + EVENT_YORK_LEEWARD_BATTLE_LINE);
+ }
if (pos === A1 || pos === A2 || pos === A3)
ahits += hits;
else
dhits += hits;
}
}
+ if (is_missiles_step()) {
+ if (game.battle.attacker === YORK) {
+ if (is_york_leeward_battle_line_in_play())
+ dhits = (dhits + 1) >> 1;
+ if (is_lancaster_leeward_battle_line_in_play())
+ ahits = (ahits + 1) >> 1;
+ }
+ else {
+ if (is_lancaster_leeward_battle_line_in_play())
+ dhits = (dhits + 1) >> 1;
+ if (is_york_leeward_battle_line_in_play())
+ ahits = (ahits + 1) >> 1;
+ }
+ }
if (ahits & 1)
ahits = (ahits >> 1) + 1;
else
diff --git a/rules.ts b/rules.ts
index 5165c73..9ff1e62 100644
--- a/rules.ts
+++ b/rules.ts
@@ -5986,12 +5986,6 @@ function count_missile_hits(lord: Lord) {
hits += get_lord_forces(lord, BURGUNDIANS) << 2
hits += get_lord_forces(lord, MILITIA)
hits += get_lord_forces(lord, MERCENARIES)
-
- if (is_leeward_battle_line_in_play(lord)) {
- // half rounded up!
- return (hits + 1) >> 1
- }
-
return hits
}
@@ -6766,22 +6760,18 @@ function end_for_trust_not_him() {
// === BATTLE EVENT: LEEWARD BATTLE LINE ===
-function is_leeward_battle_line_in_play(lord: Lord) {
- if (is_missiles_step()) {
- if (is_event_in_play(EVENT_LANCASTER_LEEWARD_BATTLE_LINE)
- && !is_event_in_play(EVENT_YORK_LEEWARD_BATTLE_LINE)
- && is_york_lord(lord)) {
- logevent(EVENT_LANCASTER_LEEWARD_BATTLE_LINE)
- return true
- }
- if (is_event_in_play(EVENT_YORK_LEEWARD_BATTLE_LINE)
- && !is_event_in_play(EVENT_LANCASTER_LEEWARD_BATTLE_LINE)
- && is_lancaster_lord(lord)) {
- logevent(EVENT_YORK_LEEWARD_BATTLE_LINE)
- return true
- }
- }
- return false
+function is_york_leeward_battle_line_in_play() {
+ return (
+ is_event_in_play(EVENT_YORK_LEEWARD_BATTLE_LINE) &&
+ !is_event_in_play(EVENT_LANCASTER_LEEWARD_BATTLE_LINE)
+ )
+}
+
+function is_lancaster_leeward_battle_line_in_play() {
+ return (
+ is_event_in_play(EVENT_LANCASTER_LEEWARD_BATTLE_LINE) &&
+ !is_event_in_play(EVENT_YORK_LEEWARD_BATTLE_LINE)
+ )
}
// === BATTLE EVENT: REGROUP ===
@@ -7462,10 +7452,17 @@ function goto_total_hits() {
else
log_h4("Melee")
+
for (let pos of game.battle.engagements[0]) {
let lord = game.battle.array[pos]
if (lord !== NOBODY) {
let hits = total_lord_hits(lord)
+ if (is_missiles_step()) {
+ if (is_york_lord(lord) && is_lancaster_leeward_battle_line_in_play())
+ logii("\xbd E" + EVENT_LANCASTER_LEEWARD_BATTLE_LINE)
+ if (is_lancaster_lord(lord) && is_york_leeward_battle_line_in_play())
+ logii("\xbd E" + EVENT_YORK_LEEWARD_BATTLE_LINE)
+ }
if (pos === A1 || pos === A2 || pos === A3)
ahits += hits
else
@@ -7473,6 +7470,20 @@ function goto_total_hits() {
}
}
+ if (is_missiles_step()) {
+ if (game.battle.attacker === YORK) {
+ if (is_york_leeward_battle_line_in_play())
+ dhits = (dhits + 1) >> 1
+ if (is_lancaster_leeward_battle_line_in_play())
+ ahits = (ahits + 1) >> 1
+ } else {
+ if (is_lancaster_leeward_battle_line_in_play())
+ dhits = (dhits + 1) >> 1
+ if (is_york_leeward_battle_line_in_play())
+ ahits = (ahits + 1) >> 1
+ }
+ }
+
if (ahits & 1)
ahits = (ahits >> 1) + 1
else