mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-22 06:12:19 +00:00
fix: clean up NukeWars mode implementation
- Remove merge conflicts from all files - Fix WinCheckExecution.ts syntax issues - Properly separate NukeWars from Team mode - Clean implementation of preparation phase - Consistent checks for GameMode.NukeWars across codebase - Fix DefaultConfig numPreparationPhaseTurns implementation
This commit is contained in:
@@ -53,13 +53,7 @@ export class HostLobbyModal extends LitElement {
|
||||
@state() private clients: ClientInfo[] = [];
|
||||
@state() private useRandomMap: boolean = false;
|
||||
@state() private disabledUnits: UnitType[] = [];
|
||||
<<<<<<< Updated upstream
|
||||
=======
|
||||
|
||||
private readonly nukeWarsDisabledUnits = [
|
||||
UnitType.MIRV,
|
||||
];
|
||||
>>>>>>> Stashed changes
|
||||
private readonly nukeWarsDisabledUnits = [UnitType.MIRV];
|
||||
@state() private lobbyCreatorClientID: string = "";
|
||||
@state() private lobbyIdVisible: boolean = true;
|
||||
|
||||
@@ -278,6 +272,14 @@ export class HostLobbyModal extends LitElement {
|
||||
${translateText("game_mode.teams")}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="option-card ${this.gameMode === GameMode.NukeWars ? "selected" : ""}"
|
||||
@click=${() => this.handleGameModeSelection(GameMode.NukeWars)}
|
||||
>
|
||||
<div class="option-card-title">
|
||||
${translateText("game_mode.nukewars")}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -702,6 +704,14 @@ export class HostLobbyModal extends LitElement {
|
||||
|
||||
private async handleGameModeSelection(value: GameMode) {
|
||||
this.gameMode = value;
|
||||
if (value === GameMode.NukeWars) {
|
||||
// Enforce Nuke Wars settings
|
||||
this.selectedMap = GameMapType.Baikal;
|
||||
this.teamCount = 2;
|
||||
this.disabledUnits = Array.from(new Set([...this.disabledUnits, ...this.nukeWarsDisabledUnits]));
|
||||
this.donateGold = true;
|
||||
this.donateTroops = true;
|
||||
}
|
||||
this.putGameConfig();
|
||||
}
|
||||
|
||||
|
||||
@@ -514,6 +514,13 @@ export class SinglePlayerModal extends LitElement {
|
||||
|
||||
const selectedColor = this.userSettings.getSelectedColor();
|
||||
|
||||
if (this.gameMode === GameMode.NukeWars) {
|
||||
// Enforce Nuke Wars defaults for singleplayer
|
||||
this.selectedMap = GameMapType.Baikal;
|
||||
this.teamCount = 2;
|
||||
this.disabledUnits = Array.from(new Set([...this.disabledUnits, ...this.nukeWarsDisabledUnits]));
|
||||
}
|
||||
|
||||
this.dispatchEvent(
|
||||
new CustomEvent("join-lobby", {
|
||||
detail: {
|
||||
|
||||
@@ -89,6 +89,7 @@ export interface Config {
|
||||
donateTroops(): boolean;
|
||||
instantBuild(): boolean;
|
||||
numSpawnPhaseTurns(): number;
|
||||
numPreparationPhaseTurns(): number;
|
||||
userSettings(): UserSettings;
|
||||
playerTeams(): TeamCountConfig;
|
||||
|
||||
|
||||
@@ -323,12 +323,9 @@ export class DefaultConfig implements Config {
|
||||
}
|
||||
|
||||
isUnitDisabled(unitType: UnitType): boolean {
|
||||
<<<<<<< Updated upstream
|
||||
=======
|
||||
if (this._gameConfig.gameMode === GameMode.NukeWars) {
|
||||
return unitType === UnitType.MIRV;
|
||||
}
|
||||
>>>>>>> Stashed changes
|
||||
return this._gameConfig.disabledUnits?.includes(unitType) ?? false;
|
||||
}
|
||||
|
||||
@@ -622,8 +619,6 @@ export class DefaultConfig implements Config {
|
||||
numSpawnPhaseTurns(): number {
|
||||
return this._gameConfig.gameType === GameType.Singleplayer ? 100 : 300;
|
||||
}
|
||||
<<<<<<< Updated upstream
|
||||
=======
|
||||
|
||||
numPreparationPhaseTurns(): number {
|
||||
if (this._gameConfig.gameMode === GameMode.NukeWars) {
|
||||
@@ -631,7 +626,6 @@ export class DefaultConfig implements Config {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
>>>>>>> Stashed changes
|
||||
numBots(): number {
|
||||
return this.bots();
|
||||
}
|
||||
|
||||
@@ -29,13 +29,10 @@ export class WinCheckExecution implements Execution {
|
||||
}
|
||||
if (this.mg === null) throw new Error("Not initialized");
|
||||
|
||||
if (this.mg.config().gameConfig().gameMode === GameMode.FFA) {
|
||||
const gameMode = this.mg.config().gameConfig().gameMode;
|
||||
if (gameMode === GameMode.FFA) {
|
||||
this.checkWinnerFFA();
|
||||
<<<<<<< Updated upstream
|
||||
} else {
|
||||
=======
|
||||
} else if (gameMode === GameMode.NukeWars || gameMode === GameMode.Team) {
|
||||
>>>>>>> Stashed changes
|
||||
this.checkWinnerTeam();
|
||||
}
|
||||
}
|
||||
@@ -91,8 +88,6 @@ export class WinCheckExecution implements Execution {
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
=======
|
||||
private checkNukeWarsWinCondition(sorted: [Team, number][]): void {
|
||||
if (this.mg === null) throw new Error("Not initialized");
|
||||
const numTilesWithoutFallout =
|
||||
@@ -153,7 +148,6 @@ export class WinCheckExecution implements Execution {
|
||||
return maxTimerValue !== undefined && timeElapsed >= maxTimerValue * 60;
|
||||
}
|
||||
|
||||
>>>>>>> Stashed changes
|
||||
isActive(): boolean {
|
||||
return this.active;
|
||||
}
|
||||
|
||||
@@ -96,12 +96,10 @@ export class GameImpl implements Game {
|
||||
this._width = _map.width();
|
||||
this._height = _map.height();
|
||||
this.unitGrid = new UnitGrid(this._map);
|
||||
<<<<<<< Updated upstream
|
||||
|
||||
if (_config.gameConfig().gameMode === GameMode.Team) {
|
||||
=======
|
||||
if (this.isTeamBasedGame()) {
|
||||
>>>>>>> Stashed changes
|
||||
// Handle team population for Team and NukeWars modes
|
||||
const gameMode = _config.gameConfig().gameMode;
|
||||
if (gameMode === GameMode.Team || gameMode === GameMode.NukeWars) {
|
||||
this.populateTeams();
|
||||
}
|
||||
this.addPlayers();
|
||||
@@ -338,15 +336,12 @@ export class GameImpl implements Game {
|
||||
return this._ticks <= this.config().numSpawnPhaseTurns();
|
||||
}
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
=======
|
||||
inPreparationPhase(): boolean {
|
||||
const spawn = this.config().numSpawnPhaseTurns();
|
||||
const prep = this.config().numPreparationPhaseTurns();
|
||||
return this._ticks > spawn && this._ticks <= spawn + prep;
|
||||
}
|
||||
|
||||
>>>>>>> Stashed changes
|
||||
ticks(): number {
|
||||
return this._ticks;
|
||||
}
|
||||
@@ -689,11 +684,8 @@ export class GameImpl implements Game {
|
||||
}
|
||||
|
||||
teams(): Team[] {
|
||||
<<<<<<< Updated upstream
|
||||
if (this._config.gameConfig().gameMode !== GameMode.Team) {
|
||||
=======
|
||||
if (!this.isTeamBasedGame()) {
|
||||
>>>>>>> Stashed changes
|
||||
const gameMode = this._config.gameConfig().gameMode;
|
||||
if (gameMode !== GameMode.Team && gameMode !== GameMode.NukeWars) {
|
||||
return [];
|
||||
}
|
||||
return [this.botTeam, ...this.playerTeams];
|
||||
|
||||
Reference in New Issue
Block a user