mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-26 08:02:42 +00:00
NukeWars: fix transport ship restrictions and structure building during preparation phase
This commit is contained in:
@@ -937,12 +937,28 @@ export class PlayerImpl implements Player {
|
||||
gc.gameMap === GameMapType.Baikal
|
||||
) {
|
||||
// Ships must stay on their team's side
|
||||
if (unitType === UnitType.Warship || unitType === UnitType.TradeShip) {
|
||||
if (!this.isInTeamSpawnZone(targetTile)) return false;
|
||||
if (
|
||||
unitType === UnitType.Warship ||
|
||||
unitType === UnitType.TradeShip ||
|
||||
unitType === UnitType.TransportShip
|
||||
) {
|
||||
if (!this.isInTeamSpawnZone(targetTile)) {
|
||||
this.mg.displayMessage(
|
||||
"Ships cannot cross the midpoint in Nuke Wars",
|
||||
MessageType.ATTACK_FAILED,
|
||||
this.id(),
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// During preparation phase, only build in own territory
|
||||
if (this.mg.inPreparationPhase() && !this.isInTeamSpawnZone(targetTile)) {
|
||||
this.mg.displayMessage(
|
||||
"During preparation phase, you can only build in your own territory",
|
||||
MessageType.ATTACK_FAILED,
|
||||
this.id(),
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,18 +49,7 @@ export function canBuildTransportShip(
|
||||
}
|
||||
|
||||
if (myPlayerBordersOcean && otherPlayerBordersOcean) {
|
||||
// In Nuke Wars on Baikal, ensure transport source/destination are on same half.
|
||||
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 dstX = game.x(dst);
|
||||
const dstLeft = dstX < Math.floor(mapWidth / 2);
|
||||
if (wantLeft !== dstLeft) return false;
|
||||
}
|
||||
// Note: Nuke Wars midpoint restrictions are now handled in PlayerImpl.canBuild
|
||||
return transportShipSpawn(game, player, dst);
|
||||
} else {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user