mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-18 16:02:43 +00:00
Merge pull request #2933 from FloPinguin/fix-nation-loading
Fix for v29: Add nation count loading for JoinPrivateLobbyModal; change HvN difficulty
This commit is contained in:
@@ -14,7 +14,6 @@ import {
|
||||
UnitType,
|
||||
mapCategories,
|
||||
} from "../core/game/Game";
|
||||
import { getCompactMapNationCount } from "../core/game/NationCreation";
|
||||
import { UserSettings } from "../core/game/UserSettings";
|
||||
import {
|
||||
ClientInfo,
|
||||
@@ -28,7 +27,7 @@ import "./components/baseComponents/Modal";
|
||||
import { BaseModal } from "./components/BaseModal";
|
||||
import "./components/Difficulties";
|
||||
import "./components/FluentSlider";
|
||||
import "./components/LobbyTeamView";
|
||||
import "./components/LobbyPlayerView";
|
||||
import "./components/Maps";
|
||||
import { modalHeader } from "./components/ui/ModalHeader";
|
||||
import { crazyGamesSDK } from "./CrazyGamesSDK";
|
||||
@@ -934,33 +933,16 @@ export class HostLobbyModal extends BaseModal {
|
||||
</div>
|
||||
|
||||
<!-- Player List -->
|
||||
<div class="border-t border-white/10 pt-6">
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<div
|
||||
class="text-xs font-bold text-white/40 uppercase tracking-widest"
|
||||
>
|
||||
${this.clients.length}
|
||||
${this.clients.length === 1
|
||||
? 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")}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<lobby-team-view
|
||||
class="block rounded-lg border border-white/10 bg-white/5 p-2"
|
||||
.gameMode=${this.gameMode}
|
||||
.clients=${this.clients}
|
||||
.lobbyCreatorClientID=${this.lobbyCreatorClientID}
|
||||
.teamCount=${this.teamCount}
|
||||
.nationCount=${this.getEffectiveNationCount()}
|
||||
.onKickPlayer=${(clientID: string) => this.kickPlayer(clientID)}
|
||||
></lobby-team-view>
|
||||
</div>
|
||||
<lobby-player-view
|
||||
.gameMode=${this.gameMode}
|
||||
.clients=${this.clients}
|
||||
.lobbyCreatorClientID=${this.lobbyCreatorClientID}
|
||||
.teamCount=${this.teamCount}
|
||||
.nationCount=${this.nationCount}
|
||||
.disableNations=${this.disableNations}
|
||||
.isCompactMap=${this.compactMap}
|
||||
.onKickPlayer=${(clientID: string) => this.kickPlayer(clientID)}
|
||||
></lobby-player-view>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1438,31 +1420,22 @@ export class HostLobbyModal extends BaseModal {
|
||||
}
|
||||
|
||||
private async loadNationCount() {
|
||||
const currentMap = this.selectedMap;
|
||||
try {
|
||||
const mapData = this.mapLoader.getMapData(this.selectedMap);
|
||||
const mapData = this.mapLoader.getMapData(currentMap);
|
||||
const manifest = await mapData.manifest();
|
||||
this.nationCount = manifest.nations.length;
|
||||
// Only update if the map hasn't changed
|
||||
if (this.selectedMap === currentMap) {
|
||||
this.nationCount = manifest.nations.length;
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn("Failed to load nation count", error);
|
||||
this.nationCount = 0;
|
||||
// Only update if the map hasn't changed
|
||||
if (this.selectedMap === currentMap) {
|
||||
this.nationCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the effective nation count for display purposes.
|
||||
* In HumansVsNations mode, this equals the number of human players.
|
||||
* For compact maps, only 25% of nations are used.
|
||||
* Otherwise, it uses the manifest nation count (or 0 if nations are disabled).
|
||||
*/
|
||||
private getEffectiveNationCount(): number {
|
||||
if (this.disableNations) {
|
||||
return 0;
|
||||
}
|
||||
if (this.gameMode === GameMode.Team && this.teamCount === HumansVsNations) {
|
||||
return this.clients.length;
|
||||
}
|
||||
return getCompactMapNationCount(this.nationCount, this.compactMap);
|
||||
}
|
||||
}
|
||||
|
||||
async function createLobby(creatorClientID: string): Promise<GameInfo> {
|
||||
|
||||
Reference in New Issue
Block a user