diff --git a/src/client/GameModeSelector.ts b/src/client/GameModeSelector.ts
index 20319614b..762d870be 100644
--- a/src/client/GameModeSelector.ts
+++ b/src/client/GameModeSelector.ts
@@ -88,9 +88,12 @@ export class GameModeSelector extends LitElement {
);
this.requestUpdate();
- const allGames = Object.values(lobbies.games ?? {}).flat();
+ const allGames =
+ lobbies.mode === "multi"
+ ? Object.values(lobbies.games).flat()
+ : [lobbies.lobby];
for (const game of allGames) {
- const mapType = game.gameConfig?.gameMap as GameMapType;
+ const mapType = game?.gameConfig?.gameMap as GameMapType;
if (mapType && !this.mapAspectRatios.has(mapType)) {
// New Map reference triggers Lit reactivity; placeholder ratio 1 lets
// has() guard against duplicate in-flight fetches.
@@ -114,9 +117,15 @@ export class GameModeSelector extends LitElement {
}
render() {
- const ffa = this.lobbies?.games?.["ffa"]?.[0];
- const teams = this.lobbies?.games?.["team"]?.[0];
- const special = this.lobbies?.games?.["special"]?.[0];
+ const lobbies = this.lobbies;
+ const isSingle = lobbies?.mode === "single";
+ const singleLobby = lobbies?.mode === "single" ? lobbies.lobby : undefined;
+ const ffa =
+ lobbies?.mode === "multi" ? lobbies.games?.["ffa"]?.[0] : undefined;
+ const teams =
+ lobbies?.mode === "multi" ? lobbies.games?.["team"]?.[0] : undefined;
+ const special =
+ lobbies?.mode === "multi" ? lobbies.games?.["special"]?.[0] : undefined;
return html`
@@ -148,47 +157,74 @@ export class GameModeSelector extends LitElement {
-
- ${special
- ? html`
- ${this.renderSpecialLobbyCard(special)}
-
`
- : ffa
- ? html`
- ${this.renderLobbyCard(ffa, this.getLobbyTitle(ffa))}
-
`
- : nothing}
+ ${isSingle && singleLobby
+ ? html`
+
+
+ ${singleLobby.publicGameType === "special"
+ ? this.renderSpecialLobbyCard(singleLobby)
+ : this.renderLobbyCard(
+ singleLobby,
+ this.getLobbyTitle(singleLobby),
+ )}
+
+
+ ${singleLobby.publicGameType === "special"
+ ? this.renderSpecialLobbyCard(singleLobby)
+ : this.renderLobbyCard(
+ singleLobby,
+ this.getLobbyTitle(singleLobby),
+ )}
+
+ `
+ : html`
+
+ ${special
+ ? html`
+ ${this.renderSpecialLobbyCard(special)}
+
`
+ : ffa
+ ? html`
+ ${this.renderLobbyCard(ffa, this.getLobbyTitle(ffa))}
+
`
+ : nothing}
-
-
- ${special && ffa
- ? html`
- ${this.renderLobbyCard(ffa, this.getLobbyTitle(ffa))}
-
`
- : nothing}
- ${teams
- ? html`
- ${this.renderLobbyCard(teams, this.getLobbyTitle(teams))}
-
`
- : nothing}
-
+
+
+ ${special && ffa
+ ? html`
+ ${this.renderLobbyCard(ffa, this.getLobbyTitle(ffa))}
+
`
+ : nothing}
+ ${teams
+ ? html`
+ ${this.renderLobbyCard(
+ teams,
+ this.getLobbyTitle(teams),
+ )}
+
`
+ : nothing}
+
-
-
- ${special ? this.renderSpecialLobbyCard(special) : nothing}
-
-
- ${ffa
- ? this.renderLobbyCard(ffa, this.getLobbyTitle(ffa))
- : nothing}
-
-
- ${teams
- ? this.renderLobbyCard(teams, this.getLobbyTitle(teams))
- : nothing}
-
+
+
+ ${special ? this.renderSpecialLobbyCard(special) : nothing}
+
+
+ ${ffa
+ ? this.renderLobbyCard(ffa, this.getLobbyTitle(ffa))
+ : nothing}
+
+
+ ${teams
+ ? this.renderLobbyCard(teams, this.getLobbyTitle(teams))
+ : nothing}
+
+ `}
diff --git a/src/core/Schemas.ts b/src/core/Schemas.ts
index 07b7f263e..8ad02faf1 100644
--- a/src/core/Schemas.ts
+++ b/src/core/Schemas.ts
@@ -164,11 +164,23 @@ export const PublicGameInfoSchema = z.object({
publicGameType: PublicGameTypeSchema,
});
-export const PublicGamesSchema = z.object({
+const SingleLobbyGamesSchema = z.object({
+ mode: z.literal("single"),
+ serverTime: z.number(),
+ lobby: PublicGameInfoSchema,
+});
+
+const MultiLobbyGamesSchema = z.object({
+ mode: z.literal("multi"),
serverTime: z.number(),
games: z.record(PublicGameTypeSchema, z.array(PublicGameInfoSchema)),
});
+export const PublicGamesSchema = z.discriminatedUnion("mode", [
+ SingleLobbyGamesSchema,
+ MultiLobbyGamesSchema,
+]);
+
export class LobbyInfoEvent implements GameEvent {
constructor(
public lobby: GameInfo,
diff --git a/src/server/IPCBridgeSchema.ts b/src/server/IPCBridgeSchema.ts
index 48293614d..eaf3ba493 100644
--- a/src/server/IPCBridgeSchema.ts
+++ b/src/server/IPCBridgeSchema.ts
@@ -23,6 +23,7 @@ export type MasterMessage = z.infer