diff --git a/src/core/execution/TransportShipExecution.ts b/src/core/execution/TransportShipExecution.ts index efa3096b6..e166a8abb 100644 --- a/src/core/execution/TransportShipExecution.ts +++ b/src/core/execution/TransportShipExecution.ts @@ -105,19 +105,20 @@ export class TransportShipExecution implements Execution { return; } - // In Nuke Wars on Baikal, prevent transport ships from crossing the midpoint + // In Nuke Wars on Baikal, prevent transport ships from entering enemy territory const gc = this.mg.config().gameConfig(); if ( gc.gameMode === GameMode.NukeWars && - gc.gameMap === GameMapType.Baikal + gc.gameMap === GameMapType.Baikal && + this.dst !== null ) { - const mapWidth = this.mg.width(); - const wantLeft = this.attacker.smallID() % 2 === 1; - const dstX = this.mg.x(this.dst); - const dstLeft = dstX < Math.floor(mapWidth / 2); - if (wantLeft !== dstLeft) { + const dstOwner = this.mg.owner(this.dst); + if ( + dstOwner.isPlayer() && + !this.attacker.isOnSameTeam(dstOwner as Player) + ) { this.mg.displayMessage( - "Transport ships cannot cross the midpoint in Nuke Wars", + "Transport ships cannot enter enemy team territory in Nuke Wars", MessageType.ATTACK_FAILED, this.attacker.id(), ); diff --git a/src/core/game/PlayerImpl.ts b/src/core/game/PlayerImpl.ts index ac8ac5b97..71d1998b2 100644 --- a/src/core/game/PlayerImpl.ts +++ b/src/core/game/PlayerImpl.ts @@ -909,14 +909,17 @@ export class PlayerImpl implements Player { return true; } + const team = this.team(); + if (!team) return false; + + // Simple geometric split: + // Team 1 (first team) gets left half (x < width/2) + // Team 2 (second team) gets right half (x >= width/2) const x = this.mg.x(tile); const mapWidth = this.mg.width(); const midpoint = Math.floor(mapWidth / 2); - const team = this.team(); - if (!team) return false; - - // Team 1 spawns on left side, Team 2 on right side + // Team 1 gets left half, Team 2 gets right half const isTeam1 = team === this.mg.teams()[0]; return isTeam1 ? x < midpoint : x >= midpoint; } @@ -936,15 +939,19 @@ export class PlayerImpl implements Player { gc.gameMode === GameMode.NukeWars && gc.gameMap === GameMapType.Baikal ) { - // Ships must stay on their team's side + // Ships cannot enter enemy team spawn zones if ( unitType === UnitType.Warship || unitType === UnitType.TradeShip || unitType === UnitType.TransportShip ) { - if (!this.isInTeamSpawnZone(targetTile)) { + const targetOwner = this.mg.owner(targetTile); + if ( + targetOwner.isPlayer() && + !this.isOnSameTeam(targetOwner as Player) + ) { this.mg.displayMessage( - "Ships cannot cross the midpoint in Nuke Wars", + "Ships cannot enter enemy team territory in Nuke Wars", MessageType.ATTACK_FAILED, this.id(), ); @@ -1087,9 +1094,17 @@ export class PlayerImpl implements Player { } private validStructureSpawnTiles(tile: TileRef): TileRef[] { - if (this.mg.owner(tile) !== this) { + 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 (!owner.isPlayer() || !this.isOnSameTeam(owner as Player)) { + return []; + } + } else if (owner !== this) { return []; } + const searchRadius = 15; const searchRadiusSquared = searchRadius ** 2; const types = Object.values(UnitType).filter((unitTypeValue) => { diff --git a/src/core/game/TransportShipUtils.ts b/src/core/game/TransportShipUtils.ts index b93be3333..862f533e5 100644 --- a/src/core/game/TransportShipUtils.ts +++ b/src/core/game/TransportShipUtils.ts @@ -20,11 +20,20 @@ export function canBuildTransportShip( } const other = game.owner(tile); - if (other === player) { - return false; - } - if (other.isPlayer() && player.isFriendly(other)) { - return false; + // During NukeWars, don't block transport ships between team members + const gc = game.config().gameConfig(); + if (gc.gameMode !== GameMode.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; + } } if (game.isOceanShore(dst)) { @@ -73,17 +82,16 @@ export function canBuildTransportShip( for (const t of sorted) { if (game.owner(t) === player) { - // Block cross-midpoint lake deployments in Nuke Wars on Baikal + // Block lake deployments into enemy team territory in Nuke Wars const gc = game.config().gameConfig(); if ( gc.gameMode === GameMode.NukeWars && gc.gameMap === GameMapType.Baikal ) { - const mapWidth = game.width(); - const wantLeft = player.smallID() % 2 === 1; - const tX = game.x(t); - const tLeft = tX < Math.floor(mapWidth / 2); - if (wantLeft !== tLeft) return false; + const tileOwner = game.owner(t); + if (tileOwner.isPlayer() && !player.isOnSameTeam(tileOwner as Player)) { + return false; + } } return transportShipSpawn(game, player, t); }