mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-23 07:55:58 +00:00
Simplify team spawn zones and fix unit restrictions in NukeWars mode
- Simplify isInTeamSpawnZone to use basic left/right map split - Allow ships and structures during entire game - Block only AtomBomb/HydrogenBomb during prep phase - Allow transport ships everywhere except enemy territory
This commit is contained in:
@@ -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(),
|
||||
);
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user