fixed center button clicked immediately on creation, make fake humans less strong.

This commit is contained in:
evanpelle
2024-10-01 08:01:44 -07:00
parent 6469911230
commit 8ca1edf9a2
2 changed files with 16 additions and 14 deletions
+15 -13
View File
@@ -191,7 +191,7 @@ export class RadialMenu implements Layer {
this.showRadialMenu(event.x, event.y); this.showRadialMenu(event.x, event.y);
} }
this.isCenterButtonEnabled = false this.isCenterButtonEnabled = false
this.updateCenterButtonState() this.enableCenterButton()
for (const item of this.menuItems.values()) { for (const item of this.menuItems.values()) {
item.disabled = true item.disabled = true
this.updateMenuItemState(item) this.updateMenuItemState(item)
@@ -206,8 +206,7 @@ export class RadialMenu implements Layer {
if (this.game.inSpawnPhase()) { if (this.game.inSpawnPhase()) {
if (tile.isLand() && !tile.hasOwner()) { if (tile.isLand() && !tile.hasOwner()) {
this.isCenterButtonEnabled = true this.enableCenterButton()
this.updateCenterButtonState()
} }
return return
} }
@@ -220,8 +219,7 @@ export class RadialMenu implements Layer {
if (tile.owner() != myPlayer && tile.isLand() && myPlayer.sharesBorderWith(other)) { if (tile.owner() != myPlayer && tile.isLand() && myPlayer.sharesBorderWith(other)) {
if (!other.isPlayer() || !myPlayer.isAlliedWith(other)) { if (!other.isPlayer() || !myPlayer.isAlliedWith(other)) {
this.isCenterButtonEnabled = true this.enableCenterButton()
this.updateCenterButtonState()
} }
} }
@@ -351,17 +349,21 @@ export class RadialMenu implements Layer {
this.menuElement.select('.center-button-text').transition().duration(200).style('font-size', fontSize); this.menuElement.select('.center-button-text').transition().duration(200).style('font-size', fontSize);
} }
private updateCenterButtonState() { private enableCenterButton() {
const centerButton = this.menuElement.select('.center-button'); // Add delay so center button is clicked immediately on creation.
setTimeout(() => {
this.isCenterButtonEnabled = true;
const centerButton = this.menuElement.select('.center-button');
centerButton.select('.center-button-hitbox') centerButton.select('.center-button-hitbox')
.style('cursor', this.isCenterButtonEnabled ? 'pointer' : 'not-allowed'); .style('cursor', this.isCenterButtonEnabled ? 'pointer' : 'not-allowed');
centerButton.select('.center-button-visible') centerButton.select('.center-button-visible')
.attr('fill', this.isCenterButtonEnabled ? '#2c3e50' : '#999999'); .attr('fill', this.isCenterButtonEnabled ? '#2c3e50' : '#999999');
centerButton.select('.center-button-text') centerButton.select('.center-button-text')
.attr('fill', this.isCenterButtonEnabled ? 'white' : '#cccccc'); .attr('fill', this.isCenterButtonEnabled ? 'white' : '#cccccc');
}, 25);
} }
private getDisabledColor(color: string): string { private getDisabledColor(color: string): string {
+1 -1
View File
@@ -118,7 +118,7 @@ export class DefaultConfig implements Config {
return 10000 return 10000
} }
if (playerInfo.playerType == PlayerType.FakeHuman) { if (playerInfo.playerType == PlayerType.FakeHuman) {
return 50000 return 10000
} }
return 10000 return 10000
} }