mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 19:56:43 +00:00
alert when unit is destroyed
This commit is contained in:
@@ -11,7 +11,8 @@ import {
|
||||
Game,
|
||||
Player,
|
||||
PlayerID,
|
||||
TargetPlayerEvent
|
||||
TargetPlayerEvent,
|
||||
UnitEvent
|
||||
} from "../../../core/game/Game";
|
||||
import { ClientID } from "../../../core/Schemas";
|
||||
import { Layer } from "./Layer";
|
||||
|
||||
@@ -31,18 +31,15 @@ export const devConfig = new class extends DefaultConfig {
|
||||
tradeShipSpawnRate(): number {
|
||||
return 10
|
||||
}
|
||||
// boatMaxDistance(): number {
|
||||
// return 5000
|
||||
// }
|
||||
boatMaxDistance(): number {
|
||||
return 5000
|
||||
}
|
||||
|
||||
// numBots(): number {
|
||||
// return 0
|
||||
// }
|
||||
// spawnNPCs(): boolean {
|
||||
// return false
|
||||
// }
|
||||
numBots(): number {
|
||||
return 0
|
||||
}
|
||||
spawnNPCs(): boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
// boatMaxDistance(): number {
|
||||
// return 2000
|
||||
// }
|
||||
}
|
||||
@@ -28,12 +28,6 @@ export class MissileSiloExecution implements Execution {
|
||||
}
|
||||
this.silo = this.player.buildUnit(UnitType.MissileSilo, 0, tile)
|
||||
}
|
||||
|
||||
if (!this.silo.tile().hasOwner()) {
|
||||
this.silo.delete()
|
||||
this.active = false
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
owner(): MutablePlayer {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { MessageType } from "../../client/graphics/layers/EventsDisplay";
|
||||
import { simpleHash } from "../Util";
|
||||
import { MutableUnit, Tile, TerraNullius, UnitType, Player, UnitInfo } from "./Game";
|
||||
import { GameImpl } from "./GameImpl";
|
||||
@@ -46,14 +47,26 @@ export class UnitImpl implements MutableUnit {
|
||||
}
|
||||
|
||||
setOwner(newOwner: Player): void {
|
||||
const oldOwner = this._owner
|
||||
this._owner = newOwner as PlayerImpl
|
||||
this.g.fireUnitUpdateEvent(this, this.tile())
|
||||
this.g.displayMessage(
|
||||
`Your ${this.type()} was captured by ${newOwner.displayName()}`,
|
||||
MessageType.ERROR,
|
||||
oldOwner.id()
|
||||
)
|
||||
}
|
||||
|
||||
delete(): void {
|
||||
if (!this.isActive()) {
|
||||
throw new Error(`cannot delete ${this} not active`)
|
||||
}
|
||||
this._owner._units = this._owner._units.filter(b => b != this);
|
||||
this._active = false;
|
||||
this.g.fireUnitUpdateEvent(this, this._tile);
|
||||
if (this.type() != UnitType.AtomBomb && this.type() != UnitType.HydrogenBomb) {
|
||||
this.g.displayMessage(`Your ${this.type()} was destroyed`, MessageType.ERROR, this.owner().id())
|
||||
}
|
||||
}
|
||||
isActive(): boolean {
|
||||
return this._active;
|
||||
|
||||
Reference in New Issue
Block a user