mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-08-17 05:34:37 +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 clients: ClientInfo[] = [];
|
||||||
@state() private useRandomMap: boolean = false;
|
@state() private useRandomMap: boolean = false;
|
||||||
@state() private disabledUnits: UnitType[] = [];
|
@state() private disabledUnits: UnitType[] = [];
|
||||||
<<<<<<< Updated upstream
|
private readonly nukeWarsDisabledUnits = [UnitType.MIRV];
|
||||||
=======
|
|
||||||
|
|
||||||
private readonly nukeWarsDisabledUnits = [
|
|
||||||
UnitType.MIRV,
|
|
||||||
];
|
|
||||||
>>>>>>> Stashed changes
|
|
||||||
@state() private lobbyCreatorClientID: string = "";
|
@state() private lobbyCreatorClientID: string = "";
|
||||||
@state() private lobbyIdVisible: boolean = true;
|
@state() private lobbyIdVisible: boolean = true;
|
||||||
|
|
||||||
@@ -278,6 +272,14 @@ export class HostLobbyModal extends LitElement {
|
|||||||
${translateText("game_mode.teams")}
|
${translateText("game_mode.teams")}
|
||||||
</div>
|
</div>
|
||||||
</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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -702,6 +704,14 @@ export class HostLobbyModal extends LitElement {
|
|||||||
|
|
||||||
private async handleGameModeSelection(value: GameMode) {
|
private async handleGameModeSelection(value: GameMode) {
|
||||||
this.gameMode = value;
|
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();
|
this.putGameConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -514,6 +514,13 @@ export class SinglePlayerModal extends LitElement {
|
|||||||
|
|
||||||
const selectedColor = this.userSettings.getSelectedColor();
|
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(
|
this.dispatchEvent(
|
||||||
new CustomEvent("join-lobby", {
|
new CustomEvent("join-lobby", {
|
||||||
detail: {
|
detail: {
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ export interface Config {
|
|||||||
donateTroops(): boolean;
|
donateTroops(): boolean;
|
||||||
instantBuild(): boolean;
|
instantBuild(): boolean;
|
||||||
numSpawnPhaseTurns(): number;
|
numSpawnPhaseTurns(): number;
|
||||||
|
numPreparationPhaseTurns(): number;
|
||||||
userSettings(): UserSettings;
|
userSettings(): UserSettings;
|
||||||
playerTeams(): TeamCountConfig;
|
playerTeams(): TeamCountConfig;
|
||||||
|
|
||||||
|
|||||||
@@ -323,12 +323,9 @@ export class DefaultConfig implements Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isUnitDisabled(unitType: UnitType): boolean {
|
isUnitDisabled(unitType: UnitType): boolean {
|
||||||
<<<<<<< Updated upstream
|
|
||||||
=======
|
|
||||||
if (this._gameConfig.gameMode === GameMode.NukeWars) {
|
if (this._gameConfig.gameMode === GameMode.NukeWars) {
|
||||||
return unitType === UnitType.MIRV;
|
return unitType === UnitType.MIRV;
|
||||||
}
|
}
|
||||||
>>>>>>> Stashed changes
|
|
||||||
return this._gameConfig.disabledUnits?.includes(unitType) ?? false;
|
return this._gameConfig.disabledUnits?.includes(unitType) ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -622,8 +619,6 @@ export class DefaultConfig implements Config {
|
|||||||
numSpawnPhaseTurns(): number {
|
numSpawnPhaseTurns(): number {
|
||||||
return this._gameConfig.gameType === GameType.Singleplayer ? 100 : 300;
|
return this._gameConfig.gameType === GameType.Singleplayer ? 100 : 300;
|
||||||
}
|
}
|
||||||
<<<<<<< Updated upstream
|
|
||||||
=======
|
|
||||||
|
|
||||||
numPreparationPhaseTurns(): number {
|
numPreparationPhaseTurns(): number {
|
||||||
if (this._gameConfig.gameMode === GameMode.NukeWars) {
|
if (this._gameConfig.gameMode === GameMode.NukeWars) {
|
||||||
@@ -631,7 +626,6 @@ export class DefaultConfig implements Config {
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
>>>>>>> Stashed changes
|
|
||||||
numBots(): number {
|
numBots(): number {
|
||||||
return this.bots();
|
return this.bots();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,13 +29,10 @@ export class WinCheckExecution implements Execution {
|
|||||||
}
|
}
|
||||||
if (this.mg === null) throw new Error("Not initialized");
|
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();
|
this.checkWinnerFFA();
|
||||||
<<<<<<< Updated upstream
|
|
||||||
} else {
|
} else {
|
||||||
=======
|
|
||||||
} else if (gameMode === GameMode.NukeWars || gameMode === GameMode.Team) {
|
|
||||||
>>>>>>> Stashed changes
|
|
||||||
this.checkWinnerTeam();
|
this.checkWinnerTeam();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,8 +88,6 @@ export class WinCheckExecution implements Execution {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< Updated upstream
|
|
||||||
=======
|
|
||||||
private checkNukeWarsWinCondition(sorted: [Team, number][]): void {
|
private checkNukeWarsWinCondition(sorted: [Team, number][]): void {
|
||||||
if (this.mg === null) throw new Error("Not initialized");
|
if (this.mg === null) throw new Error("Not initialized");
|
||||||
const numTilesWithoutFallout =
|
const numTilesWithoutFallout =
|
||||||
@@ -153,7 +148,6 @@ export class WinCheckExecution implements Execution {
|
|||||||
return maxTimerValue !== undefined && timeElapsed >= maxTimerValue * 60;
|
return maxTimerValue !== undefined && timeElapsed >= maxTimerValue * 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
>>>>>>> Stashed changes
|
|
||||||
isActive(): boolean {
|
isActive(): boolean {
|
||||||
return this.active;
|
return this.active;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,12 +96,10 @@ export class GameImpl implements Game {
|
|||||||
this._width = _map.width();
|
this._width = _map.width();
|
||||||
this._height = _map.height();
|
this._height = _map.height();
|
||||||
this.unitGrid = new UnitGrid(this._map);
|
this.unitGrid = new UnitGrid(this._map);
|
||||||
<<<<<<< Updated upstream
|
|
||||||
|
|
||||||
if (_config.gameConfig().gameMode === GameMode.Team) {
|
// Handle team population for Team and NukeWars modes
|
||||||
=======
|
const gameMode = _config.gameConfig().gameMode;
|
||||||
if (this.isTeamBasedGame()) {
|
if (gameMode === GameMode.Team || gameMode === GameMode.NukeWars) {
|
||||||
>>>>>>> Stashed changes
|
|
||||||
this.populateTeams();
|
this.populateTeams();
|
||||||
}
|
}
|
||||||
this.addPlayers();
|
this.addPlayers();
|
||||||
@@ -338,15 +336,12 @@ export class GameImpl implements Game {
|
|||||||
return this._ticks <= this.config().numSpawnPhaseTurns();
|
return this._ticks <= this.config().numSpawnPhaseTurns();
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< Updated upstream
|
|
||||||
=======
|
|
||||||
inPreparationPhase(): boolean {
|
inPreparationPhase(): boolean {
|
||||||
const spawn = this.config().numSpawnPhaseTurns();
|
const spawn = this.config().numSpawnPhaseTurns();
|
||||||
const prep = this.config().numPreparationPhaseTurns();
|
const prep = this.config().numPreparationPhaseTurns();
|
||||||
return this._ticks > spawn && this._ticks <= spawn + prep;
|
return this._ticks > spawn && this._ticks <= spawn + prep;
|
||||||
}
|
}
|
||||||
|
|
||||||
>>>>>>> Stashed changes
|
|
||||||
ticks(): number {
|
ticks(): number {
|
||||||
return this._ticks;
|
return this._ticks;
|
||||||
}
|
}
|
||||||
@@ -689,11 +684,8 @@ export class GameImpl implements Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
teams(): Team[] {
|
teams(): Team[] {
|
||||||
<<<<<<< Updated upstream
|
const gameMode = this._config.gameConfig().gameMode;
|
||||||
if (this._config.gameConfig().gameMode !== GameMode.Team) {
|
if (gameMode !== GameMode.Team && gameMode !== GameMode.NukeWars) {
|
||||||
=======
|
|
||||||
if (!this.isTeamBasedGame()) {
|
|
||||||
>>>>>>> Stashed changes
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
return [this.botTeam, ...this.playerTeams];
|
return [this.botTeam, ...this.playerTeams];
|
||||||
|
|||||||
Reference in New Issue
Block a user