diff --git a/src/client/graphics/layers/radial/BuildMenu.ts b/src/client/graphics/layers/radial/BuildMenu.ts index 347d4efe7..74d6d8ae7 100644 --- a/src/client/graphics/layers/radial/BuildMenu.ts +++ b/src/client/graphics/layers/radial/BuildMenu.ts @@ -14,7 +14,7 @@ import shieldIcon from '../../../../../resources/images/ShieldIconWhite.svg'; import cityIcon from '../../../../../resources/images/CityIconWhite.svg'; import { renderNumber } from '../../../Utils'; import { ContextMenuEvent } from '../../../InputHandler'; -import { GameView } from '../../../../core/GameView'; +import { GameView, PlayerActions, PlayerView } from '../../../../core/GameView'; interface BuildItemDisplay { unitType: UnitType @@ -40,6 +40,7 @@ export class BuildMenu extends LitElement { public eventBus: EventBus; private myPlayer: Player; private clickedCell: Cell; + private playerActions: PlayerActions | null static styles = css` :host { @@ -186,10 +187,10 @@ export class BuildMenu extends LitElement { private _hidden = true; private canBuild(item: BuildItemDisplay): boolean { - if (this.myPlayer == null) { + if (this.myPlayer == null || this.playerActions == null) { return false } - return this.myPlayer.canBuild(item.unitType, this.game.tile(this.clickedCell)) != false + return this.playerActions.buildableUnits.some(u => u == item.unitType) } public onBuildSelected = (item: BuildItemDisplay) => { @@ -228,11 +229,15 @@ export class BuildMenu extends LitElement { this.requestUpdate(); } - showMenu(player: Player, clickedCell: Cell) { - this.myPlayer = player; - this.clickedCell = clickedCell; - this._hidden = false; - this.requestUpdate(); + showMenu(player: PlayerView, clickedCell: Cell) { + player.actions(this.game.tile(clickedCell)).then(actions => { + console.log(`got actions: ${JSON.stringify(actions)}`) + this.playerActions = actions + this.myPlayer = player; + this.clickedCell = clickedCell; + this._hidden = false; + this.requestUpdate(); + }) } get isVisible() { diff --git a/src/core/configuration/DevConfig.ts b/src/core/configuration/DevConfig.ts index 43b01b7d9..7e4999d6f 100644 --- a/src/core/configuration/DevConfig.ts +++ b/src/core/configuration/DevConfig.ts @@ -19,7 +19,7 @@ export class DevConfig extends DefaultConfig { } numSpawnPhaseTurns(): number { - return this.gameConfig().gameType == GameType.Singleplayer ? 400 : 200 + return this.gameConfig().gameType == GameType.Singleplayer ? 40 : 200 // return 100 }