mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-30 06:22:14 +00:00
fix
This commit is contained in:
@@ -149,8 +149,13 @@ export const isGameType = (value: unknown): value is GameType =>
|
||||
export enum GameMode {
|
||||
FFA = "Free For All",
|
||||
Team = "Team",
|
||||
}
|
||||
|
||||
export enum TeamGameType {
|
||||
Standard = "Standard",
|
||||
NukeWars = "Nuke Wars",
|
||||
}
|
||||
|
||||
export const isGameMode = (value: unknown): value is GameMode =>
|
||||
isEnumValue(GameMode, value);
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import {
|
||||
Unit,
|
||||
UnitInfo,
|
||||
UnitType,
|
||||
TeamGameType,
|
||||
} from "./Game";
|
||||
import { GameMap, TileRef, TileUpdate } from "./GameMap";
|
||||
import { GameUpdate, GameUpdateType } from "./GameUpdates";
|
||||
@@ -98,8 +99,7 @@ export class GameImpl implements Game {
|
||||
this.unitGrid = new UnitGrid(this._map);
|
||||
// Treat Team and NukeWars as team-based games (Nuke Wars is 2-team only)
|
||||
if (
|
||||
_config.gameConfig().gameMode === GameMode.Team ||
|
||||
_config.gameConfig().gameMode === GameMode.NukeWars
|
||||
_config.gameConfig().gameMode === GameMode.Team
|
||||
) {
|
||||
this.populateTeams();
|
||||
}
|
||||
@@ -109,7 +109,7 @@ export class GameImpl implements Game {
|
||||
private populateTeams() {
|
||||
let numPlayerTeams = this._config.playerTeams();
|
||||
// Force 2 teams for NukeWars
|
||||
if (this._config.gameConfig().gameMode === GameMode.NukeWars) {
|
||||
if (this._config.gameConfig().gameMode === GameMode.Team && this._config.gameConfig().teamGameType === TeamGameType.NukeWars) {
|
||||
numPlayerTeams = 2;
|
||||
}
|
||||
if (typeof numPlayerTeams !== "number") {
|
||||
@@ -681,10 +681,7 @@ export class GameImpl implements Game {
|
||||
|
||||
teams(): Team[] {
|
||||
if (this._config.gameConfig().gameMode !== GameMode.Team) {
|
||||
// Treat NukeWars as a team-based mode (2 teams)
|
||||
if (this._config.gameConfig().gameMode !== GameMode.NukeWars) {
|
||||
return [];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
return [this.botTeam, ...this.playerTeams];
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import {
|
||||
PlayerType,
|
||||
Relation,
|
||||
Team,
|
||||
TeamGameType,
|
||||
TerraNullius,
|
||||
Tick,
|
||||
Unit,
|
||||
@@ -905,7 +906,8 @@ export class PlayerImpl implements Player {
|
||||
|
||||
private isInTeamSpawnZone(tile: TileRef): boolean {
|
||||
const gameMode = this.mg.config().gameConfig().gameMode;
|
||||
if (gameMode !== GameMode.NukeWars) {
|
||||
const teamGameType = this.mg.config().gameConfig().teamGameType;
|
||||
if (!(gameMode === GameMode.Team && teamGameType === TeamGameType.NukeWars)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -936,7 +938,8 @@ export class PlayerImpl implements Player {
|
||||
// Nuke Wars restrictions on Baikal map
|
||||
const gc = this.mg.config().gameConfig();
|
||||
if (
|
||||
gc.gameMode === GameMode.NukeWars &&
|
||||
gc.gameMode === GameMode.Team &&
|
||||
gc.teamGameType === TeamGameType.NukeWars &&
|
||||
gc.gameMap === GameMapType.Baikal
|
||||
) {
|
||||
// Ships cannot enter enemy team spawn zones
|
||||
@@ -985,7 +988,7 @@ export class PlayerImpl implements Player {
|
||||
// In Nuke Wars, AtomBomb and HydrogenBomb cannot be launched during the
|
||||
// preparation phase, but are allowed afterwards. Other build restrictions
|
||||
// (like team spawn zones) are handled above.
|
||||
if (gc.gameMode === GameMode.NukeWars && this.mg.inPreparationPhase()) {
|
||||
if (gc.gameMode === GameMode.Team && gc.teamGameType === TeamGameType.NukeWars && this.mg.inPreparationPhase()) {
|
||||
this.mg.displayMessage(
|
||||
"Nuclear weapons cannot be launched during the preparation phase",
|
||||
MessageType.ATTACK_FAILED,
|
||||
@@ -1097,7 +1100,7 @@ export class PlayerImpl implements Player {
|
||||
const owner = this.mg.owner(tile);
|
||||
const gc = this.mg.config().gameConfig();
|
||||
// In NukeWars prep phase, allow building in team territory
|
||||
if (gc.gameMode === GameMode.NukeWars && this.mg.inPreparationPhase()) {
|
||||
if (gc.gameMode === GameMode.Team && gc.teamGameType === TeamGameType.NukeWars && this.mg.inPreparationPhase()) {
|
||||
if (!owner.isPlayer() || !this.isOnSameTeam(owner as Player)) {
|
||||
return [];
|
||||
}
|
||||
@@ -1243,7 +1246,8 @@ export class PlayerImpl implements Player {
|
||||
// side deterministically by smallID parity (odd = left, even = right).
|
||||
const gameCfg = this.mg.config().gameConfig();
|
||||
if (
|
||||
gameCfg.gameMode === GameMode.NukeWars &&
|
||||
gameCfg.gameMode === GameMode.Team &&
|
||||
gameCfg.teamGameType === TeamGameType.NukeWars &&
|
||||
gameCfg.gameMap === GameMapType.Baikal &&
|
||||
this.mg.inSpawnPhase()
|
||||
) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { PathFindResultType } from "../pathfinding/AStar";
|
||||
import { MiniAStar } from "../pathfinding/MiniAStar";
|
||||
import { Game, GameMapType, GameMode, Player, UnitType } from "./Game";
|
||||
import { Game, GameMapType, GameMode, Player, TeamGameType, UnitType } from "./Game";
|
||||
import { andFN, GameMap, manhattanDistFN, TileRef } from "./GameMap";
|
||||
|
||||
export function canBuildTransportShip(
|
||||
@@ -22,19 +22,19 @@ export function canBuildTransportShip(
|
||||
const other = game.owner(tile);
|
||||
// During NukeWars, don't block transport ships between team members
|
||||
const gc = game.config().gameConfig();
|
||||
if (gc.gameMode !== GameMode.NukeWars) {
|
||||
if (!(gc.gameMode === GameMode.Team && gc.teamGameType === TeamGameType.NukeWars)) {
|
||||
if (other === player) {
|
||||
return false;
|
||||
}
|
||||
if (other.isPlayer() && player.isFriendly(other)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// In NukeWars, only block sending to enemy teams
|
||||
if (other.isPlayer() && player.isOnSameTeam(other as Player)) {
|
||||
return false;
|
||||
// In NukeWars, only block sending to enemy teams
|
||||
} else if (gc.gameMode === GameMode.Team && gc.teamGameType === TeamGameType.NukeWars) {
|
||||
if (other.isPlayer() && player.isOnSameTeam(other as Player)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (game.isOceanShore(dst)) {
|
||||
let myPlayerBordersOcean = false;
|
||||
@@ -85,7 +85,8 @@ export function canBuildTransportShip(
|
||||
// Block lake deployments into enemy team territory in Nuke Wars
|
||||
const gc = game.config().gameConfig();
|
||||
if (
|
||||
gc.gameMode === GameMode.NukeWars &&
|
||||
gc.gameMode === GameMode.Team &&
|
||||
gc.teamGameType === TeamGameType.NukeWars &&
|
||||
gc.gameMap === GameMapType.Baikal
|
||||
) {
|
||||
const tileOwner = game.owner(t);
|
||||
|
||||
Reference in New Issue
Block a user