Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion public/modules/ui/battle-screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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}<br>`;
Comment thread
Palladium103 marked this conversation as resolved.
Outdated
this.prevPhasePerIteration = { d: this.defenders.phase, a: this.attackers.phase }
Comment thread
Palladium103 marked this conversation as resolved.
Outdated
}

// update table values
this.updateTable("attackers");
this.updateTable("defenders");
Expand Down Expand Up @@ -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
)}%`;
)}%<p>\n${this.phasePerIteration}</p>`;
notes.push({id: `marker${i}`, name: this.name, legend});

tip(`${this.name} is over. ${result}`, true, "success", 4000);
Expand Down