mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 15:30:43 +00:00
Executions dont switch owner (#326)
when an building is taken over by another player the execution for it doesnt change its owner this makes it so when a sam is captured it tries to intercept your own nukes and doesnt intercept the ones by the previous player this change makes executions of buildings automaticly switch their owner
This commit is contained in:
@@ -44,10 +44,10 @@ export class CityExecution implements Execution {
|
||||
this.active = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
owner(): Player {
|
||||
return null;
|
||||
if (this.player != this.city.owner()) {
|
||||
this.player = this.city.owner();
|
||||
}
|
||||
}
|
||||
|
||||
isActive(): boolean {
|
||||
|
||||
@@ -76,6 +76,10 @@ export class ConstructionExecution implements Execution {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.player != this.construction.owner()) {
|
||||
this.player = this.construction.owner();
|
||||
}
|
||||
|
||||
if (this.ticksUntilComplete == 0) {
|
||||
this.player = this.construction.owner();
|
||||
this.construction.delete(false);
|
||||
@@ -123,10 +127,6 @@ export class ConstructionExecution implements Execution {
|
||||
}
|
||||
}
|
||||
|
||||
owner(): Player {
|
||||
return null;
|
||||
}
|
||||
|
||||
isActive(): boolean {
|
||||
return this.active;
|
||||
}
|
||||
|
||||
@@ -45,10 +45,10 @@ export class DefensePostExecution implements Execution {
|
||||
this.active = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
owner(): Player {
|
||||
return null;
|
||||
if (this.player != this.post.owner()) {
|
||||
this.player = this.post.owner();
|
||||
}
|
||||
}
|
||||
|
||||
isActive(): boolean {
|
||||
|
||||
@@ -42,11 +42,11 @@ export class MissileSiloExecution implements Execution {
|
||||
return;
|
||||
}
|
||||
this.silo = this.player.buildUnit(UnitType.MissileSilo, 0, this.tile);
|
||||
}
|
||||
}
|
||||
|
||||
owner(): Player {
|
||||
return null;
|
||||
if (this.player != this.silo.owner()) {
|
||||
this.player = this.silo.owner();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
isActive(): boolean {
|
||||
|
||||
@@ -25,11 +25,6 @@ export class MoveWarshipExecution implements Execution {
|
||||
this.active = false;
|
||||
}
|
||||
|
||||
owner(): Player {
|
||||
const warship = this.mg.units().find((u) => u.id() == this.unitId);
|
||||
return warship ? warship.owner() : null;
|
||||
}
|
||||
|
||||
isActive(): boolean {
|
||||
return this.active;
|
||||
}
|
||||
|
||||
@@ -66,6 +66,10 @@ export class PortExecution implements Execution {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._owner != this.port.owner().id()) {
|
||||
this._owner = this.port.owner().id();
|
||||
}
|
||||
|
||||
const totalNbOfPorts = this.mg.units(UnitType.Port).length;
|
||||
if (
|
||||
!this.random.chance(this.mg.config().tradeShipSpawnRate(totalNbOfPorts))
|
||||
@@ -88,10 +92,6 @@ export class PortExecution implements Execution {
|
||||
);
|
||||
}
|
||||
|
||||
owner(): Player {
|
||||
return null;
|
||||
}
|
||||
|
||||
isActive(): boolean {
|
||||
return this.active;
|
||||
}
|
||||
|
||||
@@ -57,6 +57,10 @@ export class SAMLauncherExecution implements Execution {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.player != this.post.owner()) {
|
||||
this.player = this.post.owner();
|
||||
}
|
||||
|
||||
if (!this.pseudoRandom) {
|
||||
this.pseudoRandom = new PseudoRandom(this.post.id());
|
||||
}
|
||||
@@ -133,10 +137,6 @@ export class SAMLauncherExecution implements Execution {
|
||||
}
|
||||
}
|
||||
|
||||
owner(): Player {
|
||||
return null;
|
||||
}
|
||||
|
||||
isActive(): boolean {
|
||||
return this.active;
|
||||
}
|
||||
|
||||
@@ -85,9 +85,6 @@ export class SAMMissileExecution implements Execution {
|
||||
}
|
||||
}
|
||||
|
||||
owner(): Player {
|
||||
return null;
|
||||
}
|
||||
isActive(): boolean {
|
||||
return this.active;
|
||||
}
|
||||
|
||||
@@ -63,9 +63,6 @@ export class ShellExecution implements Execution {
|
||||
}
|
||||
}
|
||||
|
||||
owner(): Player {
|
||||
return null;
|
||||
}
|
||||
isActive(): boolean {
|
||||
return this.active;
|
||||
}
|
||||
|
||||
@@ -151,10 +151,6 @@ export class TradeShipExecution implements Execution {
|
||||
return;
|
||||
}
|
||||
|
||||
owner(): Player {
|
||||
return null;
|
||||
}
|
||||
|
||||
isActive(): boolean {
|
||||
return this.active;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
import { PathFinder } from "../pathfinding/PathFinding";
|
||||
import { PathFindResultType } from "../pathfinding/AStar";
|
||||
import { PseudoRandom } from "../PseudoRandom";
|
||||
import { distSort, distSortUnit } from "../Util";
|
||||
import { consolex } from "../Consolex";
|
||||
import { TileRef } from "../game/GameMap";
|
||||
import { ShellExecution } from "./ShellExecution";
|
||||
@@ -151,7 +150,7 @@ export class WarshipExecution implements Execution {
|
||||
!this.alreadySentShell.has(unit) &&
|
||||
(unit.type() !== UnitType.TradeShip || hasPort) &&
|
||||
(unit.type() !== UnitType.TradeShip ||
|
||||
unit.dstPort()?.owner() !== this.owner()),
|
||||
unit.dstPort()?.owner() !== this._owner),
|
||||
);
|
||||
|
||||
this.target =
|
||||
@@ -229,7 +228,7 @@ export class WarshipExecution implements Execution {
|
||||
);
|
||||
switch (result.type) {
|
||||
case PathFindResultType.Completed:
|
||||
this.owner().captureUnit(this.target);
|
||||
this._owner.captureUnit(this.target);
|
||||
this.target = null;
|
||||
return;
|
||||
case PathFindResultType.NextTile:
|
||||
@@ -244,10 +243,6 @@ export class WarshipExecution implements Execution {
|
||||
}
|
||||
}
|
||||
|
||||
owner(): Player {
|
||||
return this._owner;
|
||||
}
|
||||
|
||||
isActive(): boolean {
|
||||
return this.active;
|
||||
}
|
||||
|
||||
@@ -156,7 +156,6 @@ export interface Execution {
|
||||
activeDuringSpawnPhase(): boolean;
|
||||
init(mg: Game, ticks: number): void;
|
||||
tick(ticks: number): void;
|
||||
owner(): Player;
|
||||
}
|
||||
|
||||
export interface Attack {
|
||||
@@ -375,7 +374,6 @@ export interface Player {
|
||||
executeRetreat(attackID: string): void;
|
||||
|
||||
// Misc
|
||||
executions(): Execution[];
|
||||
toUpdate(): PlayerUpdate;
|
||||
playerProfile(): PlayerProfile;
|
||||
canBoat(tile: TileRef): boolean;
|
||||
|
||||
@@ -285,11 +285,6 @@ export class PlayerImpl implements Player {
|
||||
isAlive(): boolean {
|
||||
return this._tiles.size > 0;
|
||||
}
|
||||
executions(): Execution[] {
|
||||
return this.mg
|
||||
.executions()
|
||||
.filter((exec) => exec.owner().id() == this.id());
|
||||
}
|
||||
|
||||
incomingAllianceRequests(): AllianceRequest[] {
|
||||
return this.mg.allianceRequests.filter((ar) => ar.recipient() == this);
|
||||
|
||||
Reference in New Issue
Block a user