bugfix: show updated cost when building a unit while another unit of same type is under construction

This commit is contained in:
Evan
2025-02-20 10:45:55 -08:00
parent aa76c28bb1
commit f8c5d29b36
5 changed files with 56 additions and 14 deletions
+17 -6
View File
@@ -228,7 +228,22 @@ export class BuildMenu extends LitElement {
if (this.myPlayer == null || this.playerActions == null) {
return false;
}
return this.playerActions.buildableUnits.some((u) => u == item.unitType);
const unit = this.playerActions.buildableUnits.filter(
(u) => u.type == item.unitType,
);
if (!unit) {
return false;
}
return unit[0].canBuild;
}
private cost(item: BuildItemDisplay): number {
for (const bu of this.playerActions.buildableUnits) {
if (bu.type == item.unitType) {
return bu.cost;
}
}
return 0;
}
public onBuildSelected = (item: BuildItemDisplay) => {
@@ -265,11 +280,7 @@ export class BuildMenu extends LitElement {
<span class="build-description">${item.description}</span>
<span class="build-cost">
${renderNumber(
this.game && this.myPlayer
? this.game
.unitInfo(item.unitType)
.cost(this.myPlayer)
: 0,
this.game && this.myPlayer ? this.cost(item) : 0,
)}
<img
src=${goldCoinIcon}