Skip to content

Commit 6ec0689

Browse files
committed
BuildMenu now also only uses playerBuildables instead of playerActions
1 parent 60dedc0 commit 6ec0689

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/client/graphics/layers/BuildMenu.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
BuildableUnit,
77
BuildMenuTypes,
88
Gold,
9-
PlayerActions,
109
UnitType,
1110
} from "../../../core/game/Game";
1211
import { TileRef } from "../../../core/game/GameMap";
@@ -129,7 +128,7 @@ export class BuildMenu extends LitElement implements Layer {
129128
public eventBus: EventBus;
130129
public uiState: UIState;
131130
private clickedTile: TileRef;
132-
public playerActions: PlayerActions | null;
131+
public playerBuildables: BuildableUnit[] | null;
133132
private filteredBuildTable: BuildItemDisplay[][] = buildTable;
134133
public transformHandler: TransformHandler;
135134

@@ -360,10 +359,10 @@ export class BuildMenu extends LitElement implements Layer {
360359
private _hidden = true;
361360

362361
public canBuildOrUpgrade(item: BuildItemDisplay): boolean {
363-
if (this.game?.myPlayer() === null || this.playerActions === null) {
362+
if (this.game?.myPlayer() === null || this.playerBuildables === null) {
364363
return false;
365364
}
366-
const buildableUnits = this.playerActions?.buildableUnits ?? [];
365+
const buildableUnits = this.playerBuildables ?? [];
367366
const unit = buildableUnits.filter((u) => u.type === item.unitType);
368367
if (unit.length === 0) {
369368
return false;
@@ -372,7 +371,7 @@ export class BuildMenu extends LitElement implements Layer {
372371
}
373372

374373
public cost(item: BuildItemDisplay): Gold {
375-
for (const bu of this.playerActions?.buildableUnits ?? []) {
374+
for (const bu of this.playerBuildables ?? []) {
376375
if (bu.type === item.unitType) {
377376
return bu.cost;
378377
}
@@ -420,7 +419,7 @@ export class BuildMenu extends LitElement implements Layer {
420419
(row) => html`
421420
<div class="build-row">
422421
${row.map((item) => {
423-
const buildableUnit = this.playerActions?.buildableUnits.find(
422+
const buildableUnit = this.playerBuildables?.find(
424423
(bu) => bu.type === item.unitType,
425424
);
426425
if (buildableUnit === undefined) {
@@ -493,9 +492,9 @@ export class BuildMenu extends LitElement implements Layer {
493492
private refresh() {
494493
this.game
495494
.myPlayer()
496-
?.actions(this.clickedTile, BuildMenuTypes)
497-
.then((actions) => {
498-
this.playerActions = actions;
495+
?.buildables(this.clickedTile, BuildMenuTypes)
496+
.then((buildables) => {
497+
this.playerBuildables = buildables;
499498
this.requestUpdate();
500499
});
501500

src/client/graphics/layers/MainRadialMenu.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export class MainRadialMenu extends LitElement implements Layer {
112112
screenX: number | null = null,
113113
screenY: number | null = null,
114114
) {
115-
this.buildMenu.playerActions = actions;
115+
this.buildMenu.playerBuildables = actions.buildableUnits;
116116

117117
const tileOwner = this.game.owner(tile);
118118
const recipient = tileOwner.isPlayer() ? (tileOwner as PlayerView) : null;

0 commit comments

Comments
 (0)