From 08f51f7a8b6a1a43c0757b255781cc623ec158c1 Mon Sep 17 00:00:00 2001 From: evanpelle Date: Thu, 3 Jul 2025 19:18:53 -0700 Subject: [PATCH] unit upgrade minor improvements (#1337) ## Description: forgot to push these changes to the branch before merging 513fcb094418f0e9405e878396bd5b3db8b34e5a ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: evan --- src/client/graphics/layers/BuildMenu.ts | 9 +++------ src/core/game/PlayerImpl.ts | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/client/graphics/layers/BuildMenu.ts b/src/client/graphics/layers/BuildMenu.ts index b10901cd7..9a6fcc942 100644 --- a/src/client/graphics/layers/BuildMenu.ts +++ b/src/client/graphics/layers/BuildMenu.ts @@ -133,6 +133,9 @@ export class BuildMenu extends LitElement implements Layer { init() { this.eventBus.on(ShowBuildMenuEvent, (e) => { + if (!this.game.myPlayer()?.isAlive()) { + return; + } const clickedCell = this.transformHandler.screenToWorldCoordinates( e.x, e.y, @@ -144,9 +147,6 @@ export class BuildMenu extends LitElement implements Layer { return; } const tile = this.game.ref(clickedCell.x, clickedCell.y); - if (!this.game.myPlayer()?.isAlive()) { - return; - } this.showMenu(tile); }); this.eventBus.on(CloseViewEvent, () => this.hideMenu()); @@ -383,9 +383,6 @@ export class BuildMenu extends LitElement implements Layer { } public sendBuildOrUpgrade(buildableUnit: BuildableUnit, tile: TileRef): void { - if (buildableUnit === null) { - return; - } if (buildableUnit.canUpgrade !== false) { this.eventBus.emit( new SendUpgradeStructureIntentEvent( diff --git a/src/core/game/PlayerImpl.ts b/src/core/game/PlayerImpl.ts index e415a7aeb..8675f73b6 100644 --- a/src/core/game/PlayerImpl.ts +++ b/src/core/game/PlayerImpl.ts @@ -797,7 +797,7 @@ export class PlayerImpl implements Player { // Returns the existing unit that can be upgraded, // or false if it cannot be upgraded. // New units of the same type can upgrade existing units. - // e.g. if a place a new city here, will it upgrade an existing city? + // e.g. if a place a new city here, can it upgrade an existing city? private canUpgradeExistingUnit( type: UnitType, targetTile: TileRef,