From 5c4b278141a318aefd186a881d7caa3b78164fa6 Mon Sep 17 00:00:00 2001 From: allen Date: Sun, 3 May 2026 02:21:37 +0800 Subject: [PATCH 1/2] battle phases now in notes --- public/modules/ui/battle-screen.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/public/modules/ui/battle-screen.js b/public/modules/ui/battle-screen.js index 5b441a7b4..1eb677e8e 100644 --- a/public/modules/ui/battle-screen.js +++ b/public/modules/ui/battle-screen.js @@ -12,6 +12,8 @@ class Battle { this.cell = findCell(this.x, this.y); this.attackers = {regiments: [], distances: [], morale: 100, casualties: 0, power: 0}; this.defenders = {regiments: [], distances: [], morale: 100, casualties: 0, power: 0}; + this.phasePerIteration = ""; + this.prevPhasePerIteration = { d: undefined, a: undefined }; this.addHeaders(); this.addRegiment("attackers", attacker); @@ -724,6 +726,12 @@ class Battle { this.attackers.morale = Math.max(this.attackers.morale - casualtiesA * 100 - 1, 0); this.defenders.morale = Math.max(this.defenders.morale - casualtiesD * 100 - 1, 0); + // record Phases + if (this.prevPhasePerIteration.d != this.defenders.phase || this.prevPhasePerIteration.a != this.attackers.phase) { + this.phasePerIteration += `Defender: ${this.defenders.phase}, Attacker: ${this.attackers.phase}
`; + this.prevPhasePerIteration = { d: this.defenders.phase, a: this.attackers.phase } + } + // update table values this.updateTable("attackers"); this.updateTable("defenders"); @@ -888,7 +896,7 @@ class Battle { )} and ${getSide(this.defenders.regiments, 0)}. ${result}. \r\nAttackers losses: ${getLosses(this.attackers.casualties)}%, defenders losses: ${getLosses( this.defenders.casualties - )}%`; + )}%

\n${this.phasePerIteration}

`; notes.push({id: `marker${i}`, name: this.name, legend}); tip(`${this.name} is over. ${result}`, true, "success", 4000); From 4628016563a2a6fff58d3be25ba81aabc7647eea Mon Sep 17 00:00:00 2001 From: allen Date: Fri, 8 May 2026 00:18:16 +0800 Subject: [PATCH 2/2] fix: phase recording will now record when phase actually gets updated and also when user changes the phase manually --- public/modules/ui/battle-screen.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/public/modules/ui/battle-screen.js b/public/modules/ui/battle-screen.js index 1eb677e8e..2ab4e8d5c 100644 --- a/public/modules/ui/battle-screen.js +++ b/public/modules/ui/battle-screen.js @@ -522,6 +522,13 @@ class Battle { this[side].die = +el.innerHTML; } + recordPhases(d, a) { + if (this.prevPhasePerIteration.d != d || this.prevPhasePerIteration.a != a) { + this.phasePerIteration += `Defender: ${d}, Attacker: ${a}
`; + this.prevPhasePerIteration = {d: d, a: a} + } + } + selectPhase() { const i = this.iteration; const morale = [this.attackers.morale, this.defenders.morale]; @@ -669,6 +676,8 @@ class Battle { const buttonD = ensureEl("battlePhase_defenders"); buttonD.className = "icon-button-" + this.defenders.phase; buttonD.dataset.tip = buttonD.nextElementSibling.querySelector("[data-phase='" + phase[1] + "']").dataset.tip; + + this.recordPhases(this.defenders.phase, this.attackers.phase); } run() { @@ -726,12 +735,6 @@ class Battle { this.attackers.morale = Math.max(this.attackers.morale - casualtiesA * 100 - 1, 0); this.defenders.morale = Math.max(this.defenders.morale - casualtiesD * 100 - 1, 0); - // record Phases - if (this.prevPhasePerIteration.d != this.defenders.phase || this.prevPhasePerIteration.a != this.attackers.phase) { - this.phasePerIteration += `Defender: ${this.defenders.phase}, Attacker: ${this.attackers.phase}
`; - this.prevPhasePerIteration = { d: this.defenders.phase, a: this.attackers.phase } - } - // update table values this.updateTable("attackers"); this.updateTable("defenders"); @@ -811,6 +814,8 @@ class Battle { button.className = "icon-button-" + phase; button.dataset.tip = ev.target.dataset.tip; this.calculateStrength(side); + + this.recordPhases(this.defenders.phase, this.attackers.phase); } applyResults() {