mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-23 17:36:29 +00:00
Merge branch 'main' into 2393-show-boat-troops-as-attacking-troops
This commit is contained in:
@@ -451,6 +451,7 @@ export interface Unit {
|
||||
toUpdate(): UnitUpdate;
|
||||
hasTrainStation(): boolean;
|
||||
setTrainStation(trainStation: boolean): void;
|
||||
wasDestroyedByEnemy(): boolean;
|
||||
|
||||
// Train
|
||||
trainType(): TrainType | undefined;
|
||||
|
||||
@@ -24,6 +24,7 @@ export class UnitImpl implements Unit {
|
||||
private _retreating: boolean = false;
|
||||
private _targetedBySAM = false;
|
||||
private _reachedTarget = false;
|
||||
private _wasDestroyedByEnemy: boolean = false;
|
||||
private _lastSetSafeFromPirates: number; // Only for trade ships
|
||||
private _constructionType: UnitType | undefined;
|
||||
private _lastOwner: PlayerImpl | null = null;
|
||||
@@ -254,6 +255,10 @@ export class UnitImpl implements Unit {
|
||||
if (!this.isActive()) {
|
||||
throw new Error(`cannot delete ${this} not active`);
|
||||
}
|
||||
|
||||
// Record whether this unit was destroyed by an enemy (vs. arrived / retreated)
|
||||
this._wasDestroyedByEnemy = destroyer !== undefined;
|
||||
|
||||
this._owner._units = this._owner._units.filter((b) => b !== this);
|
||||
this._active = false;
|
||||
this.mg.addUpdate(this.toUpdate());
|
||||
@@ -307,6 +312,10 @@ export class UnitImpl implements Unit {
|
||||
return this._active;
|
||||
}
|
||||
|
||||
wasDestroyedByEnemy(): boolean {
|
||||
return this._wasDestroyedByEnemy;
|
||||
}
|
||||
|
||||
retreating(): boolean {
|
||||
return this._retreating;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user