From a8c04f11ee4d2b3923f8e813922df1f691d1d6f5 Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 12 Feb 2025 10:24:32 -0800 Subject: [PATCH 01/10] bugfix: emoji button to send to all players always active, shorten emoji cooldown --- src/client/graphics/layers/PlayerPanel.ts | 5 ++++- src/core/configuration/DefaultConfig.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/client/graphics/layers/PlayerPanel.ts b/src/client/graphics/layers/PlayerPanel.ts index c34ee53f4..567626d5a 100644 --- a/src/client/graphics/layers/PlayerPanel.ts +++ b/src/client/graphics/layers/PlayerPanel.ts @@ -125,7 +125,10 @@ export class PlayerPanel extends LitElement implements Layer { const canDonate = this.actions.interaction?.canDonate; const canSendAllianceRequest = this.actions.interaction?.canSendAllianceRequest; - const canSendEmoji = this.actions.interaction?.canSendEmoji; + const canSendEmoji = + other == myPlayer + ? this.actions.canSendEmojiAllPlayers + : this.actions.interaction?.canSendEmoji; const canBreakAlliance = this.actions.interaction?.canBreakAlliance; const canTarget = this.actions.interaction?.canTarget; diff --git a/src/core/configuration/DefaultConfig.ts b/src/core/configuration/DefaultConfig.ts index 4c49f28cc..5ea97ff8f 100644 --- a/src/core/configuration/DefaultConfig.ts +++ b/src/core/configuration/DefaultConfig.ts @@ -205,7 +205,7 @@ export class DefaultConfig implements Config { return 5 * 10; } emojiMessageCooldown(): Tick { - return 15 * 10; + return 5 * 10; } targetDuration(): Tick { return 10 * 10; From a478e305d1b478f8a10b358e7b8838dc31737929 Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 12 Feb 2025 10:33:08 -0800 Subject: [PATCH 02/10] fix right click bringing up context menu instead of radial menu on bottom of screen --- src/client/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/index.html b/src/client/index.html index 232ffecf7..bf7e77029 100644 --- a/src/client/index.html +++ b/src/client/index.html @@ -220,7 +220,7 @@ >
From 3639997f0534faa8308c98bc621469b244502bf3 Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 12 Feb 2025 11:29:49 -0800 Subject: [PATCH 03/10] make bot names gray instead of bot emoji --- src/client/graphics/layers/NameLayer.ts | 9 +++++---- src/core/configuration/Config.ts | 1 - src/core/configuration/PastelTheme.ts | 4 ---- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/client/graphics/layers/NameLayer.ts b/src/client/graphics/layers/NameLayer.ts index 3a4f78d88..d43d22fe3 100644 --- a/src/client/graphics/layers/NameLayer.ts +++ b/src/client/graphics/layers/NameLayer.ts @@ -161,11 +161,12 @@ export class NameLayer implements Layer { element.appendChild(flagImg); } + const textColor = player.type() == PlayerType.Human ? "#000000" : "#4D4D4D"; + const nameDiv = document.createElement("div"); nameDiv.classList.add("player-name"); - nameDiv.innerHTML = - (player.type() !== PlayerType.Human ? "🤖 " : "") + player.name(); - nameDiv.style.color = this.theme.playerInfoColor(player.id()).toHex(); + nameDiv.innerHTML = player.name(); + nameDiv.style.color = textColor; nameDiv.style.fontFamily = this.theme.font(); nameDiv.style.whiteSpace = "nowrap"; nameDiv.style.overflow = "hidden"; @@ -176,7 +177,7 @@ export class NameLayer implements Layer { const troopsDiv = document.createElement("div"); troopsDiv.classList.add("player-troops"); troopsDiv.textContent = renderTroops(player.troops()); - troopsDiv.style.color = this.theme.playerInfoColor(player.id()).toHex(); + troopsDiv.style.color = textColor; troopsDiv.style.fontFamily = this.theme.font(); troopsDiv.style.fontWeight = "bold"; troopsDiv.style.zIndex = "3"; diff --git a/src/core/configuration/Config.ts b/src/core/configuration/Config.ts index 90dac57cb..0d2dc1c51 100644 --- a/src/core/configuration/Config.ts +++ b/src/core/configuration/Config.ts @@ -119,7 +119,6 @@ export interface Config { } export interface Theme { - playerInfoColor(id: PlayerID): Colord; territoryColor(playerInfo: PlayerInfo): Colord; borderColor(playerInfo: PlayerInfo): Colord; defendedBorderColor(playerInfo: PlayerInfo): Colord; diff --git a/src/core/configuration/PastelTheme.ts b/src/core/configuration/PastelTheme.ts index a5bfac6b6..e299f637f 100644 --- a/src/core/configuration/PastelTheme.ts +++ b/src/core/configuration/PastelTheme.ts @@ -240,10 +240,6 @@ export const pastelTheme = new (class implements Theme { private _spawnHighlightColor = colord({ r: 255, g: 213, b: 79 }); - playerInfoColor(id: PlayerID): Colord { - return colord({ r: 50, g: 50, b: 50 }); - } - territoryColor(playerInfo: PlayerInfo): Colord { if (playerInfo.playerType == PlayerType.Human) { return this.humanColors[ From 49b794ba4ec9472c4c9bc72a42d9d1d3cf30915a Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 12 Feb 2025 11:30:49 -0800 Subject: [PATCH 04/10] rename Russian Federation => Russia --- resources/maps/Europe.json | 2 +- resources/maps/WorldMap.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/maps/Europe.json b/resources/maps/Europe.json index 885344df5..1636d31a3 100644 --- a/resources/maps/Europe.json +++ b/resources/maps/Europe.json @@ -131,7 +131,7 @@ }, { "coordinates": [1674, 449], - "name": "Russian Federation", + "name": "Russia", "strength": 3, "flag": "ru" }, diff --git a/resources/maps/WorldMap.json b/resources/maps/WorldMap.json index d80c02e4c..23951d668 100644 --- a/resources/maps/WorldMap.json +++ b/resources/maps/WorldMap.json @@ -155,7 +155,7 @@ }, { "coordinates": [1344, 136], - "name": "Russian Federation", + "name": "Russia", "strength": 3, "flag": "ru" }, From 87135d6da2182692e17d1aa78f8a202cf60518e8 Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 12 Feb 2025 11:46:15 -0800 Subject: [PATCH 05/10] style flags: make them smaller and put under name --- src/client/graphics/layers/NameLayer.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/client/graphics/layers/NameLayer.ts b/src/client/graphics/layers/NameLayer.ts index 264e35700..e7765b0fc 100644 --- a/src/client/graphics/layers/NameLayer.ts +++ b/src/client/graphics/layers/NameLayer.ts @@ -154,7 +154,7 @@ export class NameLayer implements Layer { flagImg.classList.add("player-flag"); flagImg.style.marginBottom = "-5%"; flagImg.style.opacity = "0.8"; - flagImg.src = "/flags/" + sanitize(player.flag()) + ".svg"; + flagImg.src = "flags/" + sanitize(player.flag()) + ".svg"; flagImg.style.zIndex = "1"; flagImg.style.width = "40%"; flagImg.style.aspectRatio = "3/4"; @@ -174,13 +174,26 @@ export class NameLayer implements Layer { nameDiv.style.zIndex = "3"; element.appendChild(nameDiv); + if (player.flag()) { + const flagImg = document.createElement("img"); + flagImg.classList.add("player-flag"); + flagImg.style.marginBottom = "-10%"; + flagImg.style.marginTop = "-20%"; + flagImg.style.opacity = "0.8"; + flagImg.src = "flags/" + sanitize(player.flag()) + ".svg"; + flagImg.style.zIndex = "1"; + flagImg.style.width = "30%"; + flagImg.style.aspectRatio = "3/4"; + element.appendChild(flagImg); + } + const troopsDiv = document.createElement("div"); troopsDiv.classList.add("player-troops"); troopsDiv.textContent = renderTroops(player.troops()); troopsDiv.style.color = textColor; troopsDiv.style.fontFamily = this.theme.font(); - troopsDiv.style.fontWeight = "bold"; troopsDiv.style.zIndex = "3"; + troopsDiv.style.marginTop = "-5%"; element.appendChild(troopsDiv); const iconsDiv = document.createElement("div"); From ea0885663697046674cdd98dd4c913802726c96e Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 12 Feb 2025 11:48:25 -0800 Subject: [PATCH 06/10] fix merge conflict: put / in flag path --- src/client/graphics/layers/NameLayer.ts | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/client/graphics/layers/NameLayer.ts b/src/client/graphics/layers/NameLayer.ts index e7765b0fc..79e3acd76 100644 --- a/src/client/graphics/layers/NameLayer.ts +++ b/src/client/graphics/layers/NameLayer.ts @@ -149,18 +149,6 @@ export class NameLayer implements Layer { element.style.alignItems = "center"; element.style.gap = "0px"; - if (player.flag()) { - const flagImg = document.createElement("img"); - flagImg.classList.add("player-flag"); - flagImg.style.marginBottom = "-5%"; - flagImg.style.opacity = "0.8"; - flagImg.src = "flags/" + sanitize(player.flag()) + ".svg"; - flagImg.style.zIndex = "1"; - flagImg.style.width = "40%"; - flagImg.style.aspectRatio = "3/4"; - element.appendChild(flagImg); - } - const textColor = player.type() == PlayerType.Human ? "#000000" : "#4D4D4D"; const nameDiv = document.createElement("div"); @@ -180,7 +168,7 @@ export class NameLayer implements Layer { flagImg.style.marginBottom = "-10%"; flagImg.style.marginTop = "-20%"; flagImg.style.opacity = "0.8"; - flagImg.src = "flags/" + sanitize(player.flag()) + ".svg"; + flagImg.src = "/flags/" + sanitize(player.flag()) + ".svg"; flagImg.style.zIndex = "1"; flagImg.style.width = "30%"; flagImg.style.aspectRatio = "3/4"; From eae53b29cb054d554b11da5b116a7219ac4ef115 Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 12 Feb 2025 11:59:07 -0800 Subject: [PATCH 07/10] change flag top margin a bit --- src/client/graphics/layers/NameLayer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/graphics/layers/NameLayer.ts b/src/client/graphics/layers/NameLayer.ts index 79e3acd76..66a66ab82 100644 --- a/src/client/graphics/layers/NameLayer.ts +++ b/src/client/graphics/layers/NameLayer.ts @@ -166,7 +166,7 @@ export class NameLayer implements Layer { const flagImg = document.createElement("img"); flagImg.classList.add("player-flag"); flagImg.style.marginBottom = "-10%"; - flagImg.style.marginTop = "-20%"; + flagImg.style.marginTop = "-17%"; flagImg.style.opacity = "0.8"; flagImg.src = "/flags/" + sanitize(player.flag()) + ".svg"; flagImg.style.zIndex = "1"; From f4487854760fbd78249b8e53f769f0e086110c5c Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 12 Feb 2025 12:08:50 -0800 Subject: [PATCH 08/10] have client stop polling for public servers after game starts --- src/client/Main.ts | 11 ++++++++++- src/client/PublicLobby.ts | 7 +++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/client/Main.ts b/src/client/Main.ts index 6e03edfa9..c952cc69a 100644 --- a/src/client/Main.ts +++ b/src/client/Main.ts @@ -15,6 +15,7 @@ import { consolex } from "../core/Consolex"; import "./components/FlagInput"; import { FlagInput } from "./components/FlagInput"; import page from "page"; +import { PublicLobby } from "./PublicLobby"; class Client { private gameStop: () => void; @@ -23,6 +24,8 @@ class Client { private flagInput: FlagInput | null = null; private joinModal: JoinPrivateLobbyModal; + private publicLobby: PublicLobby; + constructor() {} initialize(): void { @@ -37,6 +40,9 @@ class Client { if (!this.usernameInput) { consolex.warn("Username input element not found"); } + + this.publicLobby = document.querySelector("public-lobby") as PublicLobby; + window.addEventListener("beforeunload", (event) => { consolex.log("Browser is closing"); if (this.gameStop != null) { @@ -119,7 +125,10 @@ class Client { disableNPCs: event.detail.disableNPCs, creativeMode: event.detail.creativeMode, }, - () => this.joinModal.close(), + () => { + this.joinModal.close(); + this.publicLobby.stop(); + }, ); } diff --git a/src/client/PublicLobby.ts b/src/client/PublicLobby.ts index f1258e2d5..da4dfe658 100644 --- a/src/client/PublicLobby.ts +++ b/src/client/PublicLobby.ts @@ -54,6 +54,13 @@ export class PublicLobby extends LitElement { } } + public stop() { + if (this.lobbiesInterval !== null) { + clearInterval(this.lobbiesInterval); + this.lobbiesInterval = null; + } + } + render() { if (this.lobbies.length === 0) return html``; From 646806d132b4bfec75e7a8fee584a007e8eae86d Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 12 Feb 2025 12:35:10 -0800 Subject: [PATCH 09/10] remove old units in GameView to prevent memory leak --- src/core/game/GameView.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/core/game/GameView.ts b/src/core/game/GameView.ts index e79922c7c..c62c4b5ad 100644 --- a/src/core/game/GameView.ts +++ b/src/core/game/GameView.ts @@ -223,6 +223,8 @@ export class GameView implements GameMap { private defensePostGrid: DefenseGrid; + private toDelete = new Set(); + constructor( public worker: WorkerClient, private _config: Config, @@ -244,6 +246,9 @@ export class GameView implements GameMap { } public update(gu: GameUpdateViewData) { + this.toDelete.forEach((id) => this._units.delete(id)); + this.toDelete.clear(); + this.lastUpdate = gu; this.updatedTiles = []; @@ -283,6 +288,10 @@ export class GameView implements GameMap { this.defensePostGrid.removeDefense(unit); } } + if (!unit.isActive()) { + // Wait until next tick to delete the unit. + this.toDelete.add(unit.id()); + } }); } From cc1291153c9c81bad2bc4acc8f6fdb0eda889ca8 Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 12 Feb 2025 12:42:30 -0800 Subject: [PATCH 10/10] make max pop 100 million on creative so it fits in the UI panel --- src/core/configuration/DefaultConfig.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/configuration/DefaultConfig.ts b/src/core/configuration/DefaultConfig.ts index 5ea97ff8f..2c21ee40a 100644 --- a/src/core/configuration/DefaultConfig.ts +++ b/src/core/configuration/DefaultConfig.ts @@ -371,7 +371,7 @@ export class DefaultConfig implements Config { maxPopulation(player: Player | PlayerView): number { let maxPop = player.type() == PlayerType.Human && this.creativeMode() - ? 999_999_999_999 + ? 1_000_000_000 : 2 * (Math.pow(player.numTilesOwned(), 0.6) * 1000 + 50000) + player.units(UnitType.City).length * this.cityPopulationIncrease();