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" }, diff --git a/src/client/Main.ts b/src/client/Main.ts index 433fe5682..28378aeb8 100644 --- a/src/client/Main.ts +++ b/src/client/Main.ts @@ -15,6 +15,7 @@ import { consolex } from "../core/Consolex"; import "./FlagInput"; import { FlagInput } from "./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``; diff --git a/src/client/graphics/layers/NameLayer.ts b/src/client/graphics/layers/NameLayer.ts index 566af94d0..66a66ab82 100644 --- a/src/client/graphics/layers/NameLayer.ts +++ b/src/client/graphics/layers/NameLayer.ts @@ -149,23 +149,12 @@ 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"); 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"; @@ -173,13 +162,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 = "-17%"; + 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 = this.theme.playerInfoColor(player.id()).toHex(); + 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"); 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/client/index.html b/src/client/index.html index 09f876274..707780ef4 100644 --- a/src/client/index.html +++ b/src/client/index.html @@ -221,7 +221,7 @@ >
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/DefaultConfig.ts b/src/core/configuration/DefaultConfig.ts index 4c49f28cc..2c21ee40a 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; @@ -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(); 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[ 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()); + } }); }