mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-24 13:14:45 +00:00
NukeWars: enable transport ships within team zones but prevent crossing midpoint
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import {
|
||||
Execution,
|
||||
Game,
|
||||
GameMapType,
|
||||
GameMode,
|
||||
MessageType,
|
||||
Player,
|
||||
PlayerID,
|
||||
@@ -103,6 +105,27 @@ export class TransportShipExecution implements Execution {
|
||||
return;
|
||||
}
|
||||
|
||||
// In Nuke Wars on Baikal, prevent transport ships from crossing the midpoint
|
||||
const gc = this.mg.config().gameConfig();
|
||||
if (
|
||||
gc.gameMode === GameMode.NukeWars &&
|
||||
gc.gameMap === GameMapType.Baikal
|
||||
) {
|
||||
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) {
|
||||
this.mg.displayMessage(
|
||||
"Transport ships cannot cross the midpoint in Nuke Wars",
|
||||
MessageType.ATTACK_FAILED,
|
||||
this.attacker.id(),
|
||||
);
|
||||
this.active = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const closestTileSrc = this.attacker.canBuild(
|
||||
UnitType.TransportShip,
|
||||
this.dst,
|
||||
|
||||
@@ -930,17 +930,13 @@ export class PlayerImpl implements Player {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Prevent crossing midpoint with ships/boats at any time in Nuke Wars.
|
||||
// In Nuke Wars on Baikal, prevent ships from crossing the midpoint but allow them within team zones
|
||||
const gc = this.mg.config().gameConfig();
|
||||
if (
|
||||
gc.gameMode === GameMode.NukeWars &&
|
||||
gc.gameMap === GameMapType.Baikal
|
||||
) {
|
||||
if (
|
||||
unitType === UnitType.TransportShip ||
|
||||
unitType === UnitType.Warship ||
|
||||
unitType === UnitType.TradeShip
|
||||
) {
|
||||
if (unitType === UnitType.Warship || unitType === UnitType.TradeShip) {
|
||||
if (!this.isInTeamSpawnZone(targetTile)) return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user