bugfix: flags not showing in game

This commit is contained in:
Evan
2025-04-06 10:27:52 -07:00
parent e7041305fb
commit 08c2c01dae
8 changed files with 15 additions and 14 deletions
+1 -13
View File
@@ -11,11 +11,7 @@ import {
ServerStartGameMessageSchema,
Turn,
} from "../core/Schemas";
import {
createGameRecord,
decompressGameRecord,
generateID,
} from "../core/Util";
import { createGameRecord, decompressGameRecord } from "../core/Util";
import { LobbyConfig } from "./ClientGameRunner";
import { getPersistentIDFromCookie } from "./Main";
@@ -56,14 +52,6 @@ export class LocalServer {
gameID: this.lobbyConfig.gameStartInfo.gameID,
gameStartInfo: this.lobbyConfig.gameStartInfo,
turns: this.turns,
players: [
{
flag: this.lobbyConfig.flag,
playerID: generateID(),
clientID: this.lobbyConfig.clientID,
username: this.lobbyConfig.playerName,
},
],
}),
);
}
+9
View File
@@ -10,6 +10,7 @@ import "./components/baseComponents/Modal";
import "./components/Difficulties";
import { DifficultyDescription } from "./components/Difficulties";
import "./components/Maps";
import { FlagInput } from "./FlagInput";
import { JoinLobbyEvent } from "./Main";
import { UsernameInput } from "./UsernameInput";
@@ -334,6 +335,10 @@ export class SinglePlayerModal extends LitElement {
consolex.warn("Username input element not found");
}
const flagInput = document.querySelector("flag-input") as FlagInput;
if (!flagInput) {
consolex.warn("Flag input element not found");
}
this.dispatchEvent(
new CustomEvent("join-lobby", {
detail: {
@@ -346,6 +351,10 @@ export class SinglePlayerModal extends LitElement {
playerID: generateID(),
clientID,
username: usernameInput.getCurrentUsername(),
flag:
flagInput.getCurrentFlag() == "xx"
? ""
: flagInput.getCurrentFlag(),
},
],
config: {
+1
View File
@@ -337,6 +337,7 @@ export class Transport {
lastTurn: numTurns,
persistentID: this.lobbyConfig.persistentID,
username: this.lobbyConfig.playerName,
flag: this.lobbyConfig.flag,
}),
),
);
@@ -58,7 +58,6 @@ export class TerrainLayer implements Layer {
}
renderLayer(context: CanvasRenderingContext2D) {
console.log(this.transformHandler.scale);
if (this.transformHandler.scale < 1) {
context.imageSmoothingEnabled = true;
context.imageSmoothingQuality = "low";
+1
View File
@@ -396,6 +396,7 @@ export const ClientJoinMessageSchema = ClientBaseMessageSchema.extend({
type: z.literal("join"),
lastTurn: z.number(), // The last turn the client saw.
username: SafeString,
flag: SafeString.nullable().optional(),
});
export const ClientMessageSchema = z.union([
+1
View File
@@ -16,5 +16,6 @@ export class Client {
public readonly ip: string,
public readonly username: string,
public readonly ws: WebSocket,
public readonly flag: string | null,
) {}
}
+1
View File
@@ -267,6 +267,7 @@ export class GameServer {
playerID: c.playerID,
username: c.username,
clientID: c.clientID,
flag: c.flag,
})),
});
+1
View File
@@ -303,6 +303,7 @@ export function startWorker() {
ip,
clientMsg.username,
ws,
clientMsg.flag,
);
const wasFound = gm.addClient(