mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-26 15:44:37 +00:00
Merge remote-tracking branch 'upstream/main'
This commit is contained in:
@@ -131,7 +131,7 @@
|
||||
},
|
||||
{
|
||||
"coordinates": [1674, 449],
|
||||
"name": "Russian Federation",
|
||||
"name": "Russia",
|
||||
"strength": 3,
|
||||
"flag": "ru"
|
||||
},
|
||||
|
||||
@@ -155,7 +155,7 @@
|
||||
},
|
||||
{
|
||||
"coordinates": [1344, 136],
|
||||
"name": "Russian Federation",
|
||||
"name": "Russia",
|
||||
"strength": 3,
|
||||
"flag": "ru"
|
||||
},
|
||||
|
||||
+10
-1
@@ -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();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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``;
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -221,7 +221,7 @@
|
||||
>
|
||||
<div
|
||||
class="w-full sm:w-2/3 sm:fixed sm:right-0 sm:bottom-0 sm:flex justify-end"
|
||||
style="pointer-events: auto"
|
||||
style="pointer-events: none"
|
||||
>
|
||||
<events-display></events-display>
|
||||
</div>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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[
|
||||
|
||||
@@ -223,6 +223,8 @@ export class GameView implements GameMap {
|
||||
|
||||
private defensePostGrid: DefenseGrid;
|
||||
|
||||
private toDelete = new Set<number>();
|
||||
|
||||
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());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user