diff --git a/src/client/HostLobbyModal.ts b/src/client/HostLobbyModal.ts index 978fa12ac5..12a19698e5 100644 --- a/src/client/HostLobbyModal.ts +++ b/src/client/HostLobbyModal.ts @@ -321,6 +321,7 @@ export class HostLobbyModal extends BaseModal { .nationCount=${this.nationCount} .disableNations=${this.disableNations} .isCompactMap=${this.compactMap} + .isRandomMap=${this.useRandomMap} .onKickPlayer=${(clientID: string) => this.kickPlayer(clientID)} > @@ -771,6 +772,7 @@ export class HostLobbyModal extends BaseModal { : undefined, startingGold: this.startingGold === true ? this.startingGoldValue : undefined, + useRandomMap: this.useRandomMap, } satisfies Partial, }, bubbles: true, diff --git a/src/client/components/LobbyPlayerView.ts b/src/client/components/LobbyPlayerView.ts index 6429ffef77..13c29af4a8 100644 --- a/src/client/components/LobbyPlayerView.ts +++ b/src/client/components/LobbyPlayerView.ts @@ -38,6 +38,7 @@ export class LobbyTeamView extends LitElement { @property({ type: Number }) nationCount: number = 0; @property({ type: Boolean }) disableNations: boolean = false; @property({ type: Boolean }) isCompactMap: boolean = false; + @property({ type: Boolean }) isRandomMap: boolean = false; private theme: PastelTheme = new PastelTheme(); @state() private showTeamColors: boolean = false; @@ -52,7 +53,8 @@ export class LobbyTeamView extends LitElement { changedProperties.has("teamCount") || changedProperties.has("nationCount") || changedProperties.has("disableNations") || - changedProperties.has("isCompactMap") + changedProperties.has("isCompactMap") || + changedProperties.has("isRandomMap") ) { const teamsList = this.getTeamList(); this.computeTeamPreview(teamsList); @@ -72,10 +74,10 @@ export class LobbyTeamView extends LitElement { ? translateText("host_modal.player") : translateText("host_modal.players")} - ${this.getEffectiveNationCount()} - ${this.getEffectiveNationCount() === 1 - ? translateText("host_modal.nation_player") - : translateText("host_modal.nation_players")} + ${this.isRandomMap ? "?" : this.getEffectiveNationCount()} + ${this.isRandomMap || this.getEffectiveNationCount() !== 1 + ? translateText("host_modal.nation_players") + : translateText("host_modal.nation_player")}
diff --git a/src/core/Schemas.ts b/src/core/Schemas.ts index 5647eb744c..7a3ba21275 100644 --- a/src/core/Schemas.ts +++ b/src/core/Schemas.ts @@ -226,6 +226,7 @@ export const GameConfigSchema = z.object({ disableNavMesh: z.boolean().optional(), randomSpawn: z.boolean(), maxPlayers: z.number().optional(), + useRandomMap: z.boolean().optional(), maxTimerValue: z.number().int().min(1).max(120).optional(), // In minutes spawnImmunityDuration: z.number().int().min(0).optional(), // In ticks disabledUnits: z.enum(UnitType).array().optional(), diff --git a/src/server/GamePreviewBuilder.ts b/src/server/GamePreviewBuilder.ts index ea99160258..c73dacf1d7 100644 --- a/src/server/GamePreviewBuilder.ts +++ b/src/server/GamePreviewBuilder.ts @@ -19,6 +19,7 @@ export const ExternalGameInfoSchema = z.object({ gameMode: z.string().optional(), gameType: z.string().optional(), maxPlayers: z.number().optional(), + useRandomMap: z.boolean().optional(), playerTeams: z.union([z.number(), z.string()]).optional(), }) .optional(), @@ -181,11 +182,19 @@ export function buildPreview( // Normalize map name to match filesystem (lowercase, no spaces or special chars) const normalizedMap = map ? map.toLowerCase().replace(/[\s.()]+/g, "") : null; - - const mapThumbnail = normalizedMap - ? `${origin}/maps/${encodeURIComponent(normalizedMap)}/thumbnail.webp` - : null; - const image = mapThumbnail ?? `${origin}/images/GameplayScreenshot.png`; + const useRandomMap = + lobby?.gameConfig?.useRandomMap ?? config.useRandomMap ?? false; + + const mapThumbnail = + normalizedMap && !useRandomMap + ? `${origin}/maps/${encodeURIComponent(normalizedMap)}/thumbnail.webp` + : null; + // display the RandomMap icon in embed and displays if selected + const image = + mapThumbnail ?? + (useRandomMap + ? `${origin}/images/RandomMap.webp` + : `${origin}/images/GameplayScreenshot.png`); const gameType = lobby?.gameConfig?.gameType ?? config.gameType; const gameTypeLabel = gameType ? ` (${gameType})` : "";