Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/client/HostLobbyModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
></lobby-player-view>
</div>
Expand Down Expand Up @@ -771,6 +772,7 @@ export class HostLobbyModal extends BaseModal {
: undefined,
startingGold:
this.startingGold === true ? this.startingGoldValue : undefined,
useRandomMap: this.useRandomMap,
} satisfies Partial<GameConfig>,
},
bubbles: true,
Expand Down
32 changes: 19 additions & 13 deletions src/client/components/LobbyPlayerView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find all TypeScript files related to join/lobby/modal
echo "=== All TypeScript files containing 'Join' or 'join' ==="
fd --type=f -e ts | rg -i "join" | head -20

echo ""
echo "=== Check for JoinLobbyModal specifically ==="
fd --type=f -e ts | xargs rg -l "JoinLobbyModal" 2>/dev/null

echo ""
echo "=== All modal-related files ==="
fd --type=f -e ts | rg -i "modal" | head -20

Repository: openfrontio/OpenFrontIO

Length of output: 953


🏁 Script executed:

#!/bin/bash
# Search for nation count display in join/lobby context
echo "=== Files containing 'nationCount' or 'nation_count' ==="
rg -l "nationCount|nation_count" --type=ts

echo ""
echo "=== Context around nationCount in those files ==="
rg -n -C5 "nationCount|nation_count" --type=ts | head -100

Repository: openfrontio/OpenFrontIO

Length of output: 7854


🏁 Script executed:

#!/bin/bash
# Check LobbyPlayerView.ts structure and uses
echo "=== LobbyPlayerView.ts content ==="
cat -n src/client/components/LobbyPlayerView.ts | head -100

echo ""
echo "=== Check where LobbyPlayerView is used ==="
rg -n "lobby-player-view|LobbyPlayerView" --type=ts -A2 -B2

Repository: openfrontio/OpenFrontIO

Length of output: 7018


🏁 Script executed:

#!/bin/bash
# Search for join lobby modal and its nation count display
echo "=== Search for useRandomMap references ==="
rg -n "useRandomMap" --type=ts -C3

echo ""
echo "=== Search for isRandomMap references ==="
rg -n "isRandomMap" --type=ts -C3

Repository: openfrontio/OpenFrontIO

Length of output: 17152


Pass isRandomMap to lobby-player-view in join lobby modal.

The <lobby-player-view> component in JoinLobbyModal.ts (line 130-142) is missing the .isRandomMap property. When a random map is selected, the nation count display shows a number instead of "?" like in the host modal.

Add: .isRandomMap=${this.gameConfig?.useRandomMap ?? false}

This matches the pattern already used in HostLobbyModal.ts (line 324).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/client/components/LobbyPlayerView.ts` at line 41, The JoinLobbyModal is
not passing the isRandomMap boolean into the <lobby-player-view>, causing the
nation count to show a number instead of "?"; update the JoinLobbyModal render
where <lobby-player-view> is instantiated to include the property
.isRandomMap=${this.gameConfig?.useRandomMap ?? false} (same pattern used in
HostLobbyModal), ensuring the LobbyPlayerView.@property({ type: Boolean })
isRandomMap is set correctly.


private theme: PastelTheme = new PastelTheme();
@state() private showTeamColors: boolean = false;
Expand All @@ -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);
Expand All @@ -72,10 +74,10 @@ export class LobbyTeamView extends LitElement {
? translateText("host_modal.player")
: translateText("host_modal.players")}
<span style="margin: 0 8px;">•</span>
${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")}
</div>
</div>
<div
Expand Down Expand Up @@ -183,15 +185,19 @@ export class LobbyTeamView extends LitElement {

private renderTeamCard(preview: TeamPreviewData, isEmpty: boolean = false) {
const effectiveNationCount = this.getEffectiveNationCount();
const displayCount =
preview.team === ColoredTeams.Nations
? effectiveNationCount
: preview.players.length;
const isNationsTeam = preview.team === ColoredTeams.Nations;

const maxTeamSize =
preview.team === ColoredTeams.Nations
? effectiveNationCount
: this.teamMaxSize;
const displayCount = isNationsTeam
? this.isRandomMap
? "?"
: effectiveNationCount
: preview.players.length;

const maxTeamSize = isNationsTeam
? this.isRandomMap
? "?"
: effectiveNationCount
: this.teamMaxSize;
Comment on lines +190 to +200
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you turn this into regular if statements, nested ternary are hard to reason about


return html`
<div class="bg-gray-800 border border-gray-700 rounded-xl flex flex-col">
Expand Down
1 change: 1 addition & 0 deletions src/core/Schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
19 changes: 14 additions & 5 deletions src/server/GamePreviewBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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})` : "";
Expand Down
Loading