Added flags

This commit is contained in:
NewHappyRabbit
2025-02-11 23:34:19 +02:00
parent b8a743e745
commit 949f68287e
17 changed files with 255 additions and 352 deletions
+16 -8
View File
@@ -9,7 +9,8 @@
647
],
"name": "Bulgaria",
"strength": 1
"strength": 1,
"flag": "BG"
},
{
"coordinates": [
@@ -17,7 +18,8 @@
929
],
"name": "Turkiye",
"strength": 2
"strength": 2,
"flag": "TR"
},
{
"coordinates": [
@@ -25,7 +27,8 @@
237
],
"name": "Romania",
"strength": 1
"strength": 1,
"flag": "RO"
},
{
"coordinates": [
@@ -33,7 +36,8 @@
188
],
"name": "Maldova",
"strength": 1
"strength": 1,
"flag": "MD"
},
{
"coordinates": [
@@ -41,7 +45,8 @@
120
],
"name": "Ukraine",
"strength": 1
"strength": 1,
"flag": "UA"
},
{
"coordinates": [
@@ -49,7 +54,8 @@
354
],
"name": "Russia",
"strength": 3
"strength": 3,
"flag": "RU"
},
{
"coordinates": [
@@ -57,7 +63,8 @@
722
],
"name": "Georgia",
"strength": 1
"strength": 1,
"flag": "GE"
},
{
"coordinates": [
@@ -65,7 +72,8 @@
943
],
"name": "Armenia",
"strength": 1
"strength": 1,
"flag": "AM"
}
]
}
+93 -155
View File
@@ -4,252 +4,190 @@
"height": 1000,
"nations": [
{
"coordinates": [
171,
171
],
"coordinates": [171, 171],
"name": "Iceland 🇮🇸",
"strength": 1
"strength": 1,
"flag": "IS"
},
{
"coordinates": [
477,
473
],
"coordinates": [477, 473],
"name": "Ireland 🇮🇪",
"strength": 1
"strength": 1,
"flag": "IE"
},
{
"coordinates": [
650,
500
],
"coordinates": [650, 500],
"name": "England 🇬🇧",
"strength": 3
"strength": 3,
"flag": "GB"
},
{
"coordinates": [
560,
800
],
"coordinates": [560, 800],
"name": "Spain 🇪🇸",
"strength": 2
"strength": 2,
"flag": "ES"
},
{
"coordinates": [
726,
616
],
"coordinates": [726, 616],
"name": "France 🇫🇷",
"strength": 2
"strength": 2,
"flag": "FR"
},
{
"coordinates": [
1050,
745
],
"coordinates": [1050, 745],
"name": "Italy 🇮🇹",
"strength": 1
"strength": 1,
"flag": "IT"
},
{
"coordinates": [
872,
634
],
"coordinates": [872, 634],
"name": "Switzerland 🇨🇭",
"strength": 1
"strength": 1,
"flag": "CH"
},
{
"coordinates": [
960,
271
],
"coordinates": [960, 271],
"name": "Norway 🇳🇴",
"strength": 1
"strength": 1,
"flag": "NO"
},
{
"coordinates": [
1095,
336
],
"coordinates": [1095, 336],
"name": "Sweden 🇸🇪",
"strength": 1
"strength": 1,
"flag": "SE"
},
{
"coordinates": [
1403,
235
],
"coordinates": [1403, 235],
"name": "Finland 🇫🇮",
"strength": 1
"strength": 1,
"flag": "FI"
},
{
"coordinates": [
775,
541
],
"coordinates": [775, 541],
"name": "Belgium 🇧🇪",
"strength": 1
"strength": 1,
"flag": "BE"
},
{
"coordinates": [
868,
487
],
"coordinates": [868, 487],
"name": "Netherlands 🇳🇱",
"strength": 1
"strength": 1,
"flag": "NL"
},
{
"coordinates": [
1000,
480
],
"coordinates": [1000, 480],
"name": "Germany 🇩🇪",
"strength": 1
"strength": 1,
"flag": "DE"
},
{
"coordinates": [
1017,
628
],
"coordinates": [1017, 628],
"name": "Austria 🇦🇹",
"strength": 1
"strength": 1,
"flag": "AT"
},
{
"coordinates": [
1120,
477
],
"coordinates": [1120, 477],
"name": "Poland 🇵🇱",
"strength": 1
"strength": 1,
"flag": "PL"
},
{
"coordinates": [
1060,
530
],
"coordinates": [1060, 530],
"name": "Czechia 🇨🇿",
"strength": 1
"strength": 1,
"flag": "CZ"
},
{
"coordinates": [
1540,
602
],
"coordinates": [1540, 602],
"name": "Ukraine 🇺🇦",
"strength": 1
"strength": 1,
"flag": "UA"
},
{
"coordinates": [
1500,
440
],
"coordinates": [1500, 440],
"name": "Belarus 🇧🇾",
"strength": 1
"strength": 1,
"flag": "BY"
},
{
"coordinates": [
1400,
670
],
"coordinates": [1400, 670],
"name": "Romania 🇷🇴",
"strength": 1
"strength": 1,
"flag": "RO"
},
{
"coordinates": [
1580,
834
],
"coordinates": [1580, 834],
"name": "Turkiye 🇹🇷",
"strength": 1
"strength": 1,
"flag": "TR"
},
{
"coordinates": [
525,
955
],
"coordinates": [525, 955],
"name": "Morocco 🇲🇦",
"strength": 1
"strength": 1,
"flag": "MA"
},
{
"coordinates": [
1674,
449
],
"coordinates": [1674, 449],
"name": "Russia 🇷🇺",
"strength": 3
"strength": 3,
"flag": "RU"
},
{
"coordinates": [
1750,
950
],
"coordinates": [1750, 950],
"name": "Syria 🇸🇾",
"strength": 1
"strength": 1,
"flag": "SY"
},
{
"coordinates": [
1930,
950
],
"coordinates": [1930, 950],
"name": "Iraq 🇮🇶",
"strength": 1
"strength": 1,
"flag": "IQ"
},
{
"coordinates": [
1900,
720
],
"coordinates": [1900, 720],
"name": "Georgia 🇬🇪",
"strength": 1
"strength": 1,
"flag": "GE"
},
{
"coordinates": [
950,
930
],
"coordinates": [950, 930],
"name": "Tunisia 🇹🇳",
"strength": 1
"strength": 1,
"flag": "TN"
},
{
"coordinates": [
740,
940
],
"coordinates": [740, 940],
"name": "Algeria 🇩🇿",
"strength": 1
"strength": 1,
"flag": "DZ"
},
{
"coordinates": [
460,
830
],
"coordinates": [460, 830],
"name": "Portugal 🇵🇹",
"strength": 1
"strength": 1,
"flag": "PT"
},
{
"coordinates": [
1300,
830
],
"coordinates": [1300, 830],
"name": "Greece 🇬🇷",
"strength": 1
"strength": 1,
"flag": "GR"
},
{
"coordinates": [
1270,
700
],
"coordinates": [1270, 700],
"name": "Serbia 🇷🇸",
"strength": 1
"strength": 1,
"flag": "RS"
},
{
"coordinates": [
1200,
630
],
"coordinates": [1200, 630],
"name": "Hungary 🇭🇺",
"strength": 1
"strength": 1,
"flag": "HU"
}
]
}
+88 -176
View File
@@ -4,354 +4,266 @@
"height": 1000,
"nations": [
{
"coordinates": [
375,
272
],
"coordinates": [375, 272],
"flag": "US",
"name": "USA 🇺🇸",
"strength": 3
},
{
"coordinates": [
372,
136
],
"coordinates": [372, 136],
"flag": "CA",
"name": "Canada 🇨🇦",
"strength": 2
},
{
"coordinates": [
375,
374
],
"coordinates": [375, 374],
"flag": "MX",
"name": "Mexico 🇲🇽",
"strength": 1
},
{
"coordinates": [
500,
378
],
"coordinates": [500, 378],
"flag": "CU",
"name": "Cuba 🇨🇺",
"strength": 1
},
{
"coordinates": [
524,
474
],
"coordinates": [524, 474],
"flag": "CO",
"name": "Colombia 🇨🇴",
"strength": 1
},
{
"coordinates": [
593,
473
],
"coordinates": [593, 473],
"flag": "VE",
"name": "Venezuela 🇻🇪",
"strength": 1
},
{
"coordinates": [
596,
705
],
"coordinates": [596, 705],
"flag": "AR",
"name": "Argentina 🇦🇷",
"strength": 1
},
{
"coordinates": [
637,
567
],
"coordinates": [637, 567],
"flag": "BR",
"name": "Brazil 🇧🇷",
"strength": 1
},
{
"coordinates": [
1280,
975
],
"coordinates": [1280, 975],
"flag": "AQ",
"name": "Antartica 🇦🇶",
"strength": 3
},
{
"coordinates": [
709,
57
],
"coordinates": [709, 57],
"flag": "GL",
"name": "Greenland 🇬🇱",
"strength": 2
},
{
"coordinates": [
831,
112
],
"coordinates": [831, 112],
"flag": "IS",
"name": "Iceland 🇮🇸",
"strength": 1
},
{
"coordinates": [
925,
186
],
"coordinates": [925, 186],
"flag": "GB",
"name": "England 🇬🇧",
"strength": 3
},
{
"coordinates": [
887,
183
],
"coordinates": [887, 183],
"flag": "IE",
"name": "Ireland 🇮🇪",
"strength": 1
},
{
"coordinates": [
908,
264
],
"coordinates": [908, 264],
"flag": "ES",
"name": "Spain 🇪🇸",
"strength": 1
},
{
"coordinates": [
1004,
250
],
"coordinates": [1004, 250],
"flag": "IT",
"name": "Italy 🇮🇹",
"strength": 1
},
{
"coordinates": [
958,
220
],
"coordinates": [958, 220],
"flag": "FR",
"name": "France 🇫🇷",
"strength": 2
},
{
"coordinates": [
997,
205
],
"coordinates": [997, 205],
"flag": "DE",
"name": "Germany 🇩🇪",
"strength": 1
},
{
"coordinates": [
1064,
101
],
"coordinates": [1064, 101],
"flag": "SE",
"name": "Sweden 🇸🇪",
"strength": 1
},
{
"coordinates": [
1046,
193
],
"coordinates": [1046, 193],
"flag": "PL",
"name": "Poland 🇵🇱",
"strength": 1
},
{
"coordinates": [
1061,
188
],
"coordinates": [1061, 188],
"flag": "BY",
"name": "Belarus 🇧🇾",
"strength": 1
},
{
"coordinates": [
1073,
243
],
"coordinates": [1073, 243],
"flag": "RO",
"name": "Romania 🇷🇴",
"strength": 1
},
{
"coordinates": [
1161,
274
],
"coordinates": [1161, 274],
"flag": "TR",
"name": "Turkiye 🇹🇷",
"strength": 1
},
{
"coordinates": [
969,
133
],
"coordinates": [969, 133],
"flag": "NO",
"name": "Norway 🇳🇴",
"strength": 1
},
{
"coordinates": [
1062,
133
],
"coordinates": [1062, 133],
"flag": "FI",
"name": "Finland 🇫🇮",
"strength": 1
},
{
"coordinates": [
1099,
211
],
"coordinates": [1099, 211],
"flag": "UA",
"name": "Ukraine 🇺🇦",
"strength": 1
},
{
"coordinates": [
1344,
136
],
"coordinates": [1344, 136],
"flag": "RU",
"name": "Russia 🇷🇺",
"strength": 3
},
{
"coordinates": [
1537,
186
],
"coordinates": [1537, 186],
"flag": "MN",
"name": "Mongolia 🇲🇳",
"strength": 1
},
{
"coordinates": [
1524,
328
],
"coordinates": [1524, 328],
"flag": "CN",
"name": "China 🇨🇳",
"strength": 3
},
{
"coordinates": [
1368,
373
],
"coordinates": [1368, 373],
"flag": "IN",
"name": "India 🇮🇳",
"strength": 2
},
{
"coordinates": [
1276,
239
],
"coordinates": [1276, 239],
"flag": "KZ",
"name": "Kazakhstan 🇰🇿",
"strength": 1
},
{
"coordinates": [
1238,
309
],
"coordinates": [1238, 309],
"flag": "IR",
"name": "Iran 🇮🇷",
"strength": 1
},
{
"coordinates": [
1178,
351
],
"coordinates": [1178, 351],
"flag": "SA",
"name": "Saudi Arabia 🇸🇦",
"strength": 1
},
{
"coordinates": [
1679,
657
],
"coordinates": [1679, 657],
"flag": "AU",
"name": "Australia 🇦🇺",
"strength": 2
},
{
"coordinates": [
1890,
775
],
"coordinates": [1890, 775],
"flag": "NZ",
"name": "New Zealand 🇳🇿",
"strength": 0.5
},
{
"coordinates": [
918,
342
],
"coordinates": [918, 342],
"flag": "DZ",
"name": "Algeria 🇩🇿",
"strength": 1
},
{
"coordinates": [
1030,
332
],
"coordinates": [1030, 332],
"flag": "LY",
"name": "Libya 🇱🇾",
"strength": 1
},
{
"coordinates": [
1092,
335
],
"coordinates": [1092, 335],
"flag": "EG",
"name": "Egypt 🇪🇬",
"strength": 1
},
{
"coordinates": [
963,
410
],
"coordinates": [963, 410],
"flag": "NE",
"name": "Niger 🇳🇪",
"strength": 1
},
{
"coordinates": [
1112,
406
],
"coordinates": [1112, 406],
"flag": "SD",
"name": "Sudan 🇸🇩",
"strength": 1
},
{
"coordinates": [
1074,
508
],
"coordinates": [1074, 508],
"flag": "CD",
"name": "DRC 🇨🇩",
"strength": 1
},
{
"coordinates": [
1154,
443
],
"coordinates": [1154, 443],
"flag": "ET",
"name": "Ethiopia 🇪🇹",
"strength": 1
},
{
"coordinates": [
1075,
707
],
"coordinates": [1075, 707],
"flag": "ZA",
"name": "South Africa 🇿🇦",
"strength": 1
},
{
"coordinates": [
1194,
627
],
"coordinates": [1194, 627],
"flag": "MG",
"name": "Madagascar 🇲🇬",
"strength": 0.5
},
{
"coordinates": [
1052,
420
],
"coordinates": [1052, 420],
"flag": "TD",
"name": "Chad 🇹🇩",
"strength": 1
}
+1
View File
@@ -48,6 +48,7 @@ import { GameView, PlayerView } from "../core/game/GameView";
import { GameUpdateViewData } from "../core/game/GameUpdates";
export interface LobbyConfig {
flag: () => string;
playerName: () => string;
clientID: ClientID;
playerID: PlayerID;
+1
View File
@@ -104,6 +104,7 @@ class Client {
this.gameStop = joinLobby(
{
gameType: event.detail.gameType,
flag: (): string => this.flagInput.getCurrentFlag(),
playerName: (): string =>
this.usernameInput.getCurrentUsername(),
gameID: lobby.id,
+1
View File
@@ -340,6 +340,7 @@ export class Transport {
type: "spawn",
clientID: this.lobbyConfig.clientID,
playerID: this.lobbyConfig.playerID,
flag: this.lobbyConfig.flag(),
name: this.lobbyConfig.playerName(),
playerType: PlayerType.Human,
x: event.cell.x,
+6
View File
@@ -114,6 +114,10 @@ export class FlagInput extends LitElement {
this.storeFlag(flag);
}
public getCurrentFlag(): string {
return this.flag;
}
private getStoredFlag(): string {
const storedFlag = localStorage.getItem(flagKey);
if (storedFlag) {
@@ -125,6 +129,8 @@ export class FlagInput extends LitElement {
private storeFlag(flag: string) {
if (flag) {
localStorage.setItem(flagKey, flag);
} else if (flag === "") {
localStorage.removeItem(flagKey);
}
}
+27 -9
View File
@@ -16,6 +16,7 @@ import targetIcon from "../../../../resources/images/TargetIcon.svg";
import { ClientID } from "../../../core/Schemas";
import { GameView, PlayerView } from "../../../core/game/GameView";
import { createCanvas, renderTroops } from "../../Utils";
import { sanitize } from "../../../core/Util";
class RenderInfo {
public icons: Map<string, HTMLImageElement> = new Map(); // Track icon elements
@@ -142,33 +143,50 @@ 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 nameDiv = document.createElement("div");
nameDiv.classList.add('player-name');
nameDiv.innerHTML = player.name();
nameDiv.style.color = this.theme.playerInfoColor(player.id()).toHex();
nameDiv.style.fontFamily = this.theme.font();
nameDiv.style.whiteSpace = "nowrap";
nameDiv.style.overflow = "hidden";
nameDiv.style.textOverflow = "ellipsis";
nameDiv.style.zIndex = "2";
nameDiv.style.zIndex = "3";
element.appendChild(nameDiv);
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.fontFamily = this.theme.font();
troopsDiv.style.fontWeight = "bold";
troopsDiv.style.zIndex = "2";
troopsDiv.style.zIndex = "3";
element.appendChild(troopsDiv);
const iconsDiv = document.createElement("div");
iconsDiv.classList.add('player-icons');
iconsDiv.style.display = "flex";
iconsDiv.style.gap = "4px";
iconsDiv.style.justifyContent = "center";
iconsDiv.style.alignItems = "center";
iconsDiv.style.position = "absolute"; // Add this
iconsDiv.style.zIndex = "1"; // Add this
iconsDiv.style.width = "100%"; // Add this
iconsDiv.style.height = "100%"; // Add this
iconsDiv.style.position = "absolute";
iconsDiv.style.zIndex = "2";
iconsDiv.style.width = "100%";
iconsDiv.style.height = "100%";
element.appendChild(iconsDiv);
this.container.appendChild(element);
@@ -208,14 +226,14 @@ export class NameLayer implements Layer {
render.lastRenderCalc = now + this.rand.nextInt(0, 100);
// Update text sizes
const nameDiv = render.element.children[0] as HTMLDivElement;
const troopsDiv = render.element.children[1] as HTMLDivElement;
const nameDiv = render.element.querySelector(".player-name") as HTMLDivElement;
const troopsDiv = render.element.querySelector(".player-troops") as HTMLDivElement;
nameDiv.style.fontSize = `${render.fontSize}px`;
troopsDiv.style.fontSize = `${render.fontSize}px`;
troopsDiv.textContent = renderTroops(render.player.troops());
// Handle icons
const iconsDiv = render.element.children[2] as HTMLDivElement;
const iconsDiv = render.element.querySelector(".player-icons") as HTMLDivElement;
const iconSize = Math.min(render.fontSize * 1.5, 48);
const myPlayer = this.getPlayer();
+1
View File
@@ -139,6 +139,7 @@ export const AttackIntentSchema = BaseIntentSchema.extend({
});
export const SpawnIntentSchema = BaseIntentSchema.extend({
flag: z.string().nullable(),
type: z.literal("spawn"),
playerID: ID,
name: SafeString,
+3 -3
View File
@@ -37,9 +37,9 @@ export class DevConfig extends DefaultConfig {
// return 1
// }
// populationIncreaseRate(player: Player): number {
// return this.maxPopulation(player)
// }
populationIncreaseRate(player: Player): number {
return this.maxPopulation(player)
}
// boatMaxDistance(): number {
// return 5000
+2
View File
@@ -64,6 +64,7 @@ export class Executor {
case "spawn":
return new SpawnExecution(
new PlayerInfo(
intent.flag,
// Players see their original name, others see a sanitized version
intent.clientID == this.clientID
? sanitize(intent.name)
@@ -131,6 +132,7 @@ export class Executor {
new FakeHumanExecution(
this.gameID,
new PlayerInfo(
nation.flag || "",
nation.name,
PlayerType.FakeHuman,
null,
+2
View File
@@ -86,6 +86,7 @@ export enum Relation {
export class Nation {
constructor(
public readonly flag: string,
public readonly name: string,
public readonly cell: Cell,
public readonly strength: number
@@ -168,6 +169,7 @@ export interface MutableAlliance extends Alliance {
export class PlayerInfo {
constructor(
public readonly flag: string,
public readonly name: string,
public readonly playerType: PlayerType,
// null if bot.
+1
View File
@@ -78,6 +78,7 @@ export class GameImpl implements Game {
this.nations_ = nationMap.nations.map(
(n) =>
new Nation(
n.flag || "",
n.name,
new Cell(n.coordinates[0], n.coordinates[1]),
n.strength
+1
View File
@@ -80,6 +80,7 @@ export interface PlayerUpdate {
type: GameUpdateType.Player;
nameViewData?: NameViewData;
clientID: ClientID;
flag: string,
name: string;
displayName: string;
id: PlayerID;
+4 -1
View File
@@ -127,6 +127,9 @@ export class PlayerView {
smallID(): number {
return this.data.smallID;
}
flag(): string {
return this.data.flag;
}
name(): string {
return this.data.name;
}
@@ -196,7 +199,7 @@ export class PlayerView {
return this.data.outgoingEmojis;
}
info(): PlayerInfo {
return new PlayerInfo(this.name(), this.type(), this.clientID(), this.id());
return new PlayerInfo(this.flag(), this.name(), this.type(), this.clientID(), this.id());
}
}
+7
View File
@@ -64,6 +64,7 @@ export class PlayerImpl implements Player {
public _units: UnitImpl[] = [];
public _tiles: Set<TileRef> = new Set();
private _flag: string;
private _name: string;
private _displayName: string;
@@ -86,6 +87,7 @@ export class PlayerImpl implements Player {
private readonly playerInfo: PlayerInfo,
startPopulation: number
) {
this._flag = playerInfo.flag;
this._name = playerInfo.name;
this._targetTroopRatio = 1;
this._troops = startPopulation * this._targetTroopRatio;
@@ -100,6 +102,7 @@ export class PlayerImpl implements Player {
return {
type: GameUpdateType.Player,
clientID: this.clientID(),
flag: this.flag(),
name: this.name(),
displayName: this.displayName(),
id: this.id(),
@@ -139,6 +142,10 @@ export class PlayerImpl implements Player {
return this._smallID;
}
flag(): string {
return this._flag;
}
name(): string {
return this._name;
}
+1
View File
@@ -17,6 +17,7 @@ export interface NationMap {
export interface Nation {
coordinates: [number, number];
flag: string;
name: string;
strength: number;
}