48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
|
/// <reference path="BaseBattleDiff.ts"/>
|
||
|
|
||
|
module TK.SpaceTac {
|
||
|
/**
|
||
|
* An effect is attached to a ship
|
||
|
*/
|
||
|
export class ShipEffectAddedDiff extends BaseBattleShipDiff {
|
||
|
// Effect added
|
||
|
effect: BaseEffect
|
||
|
|
||
|
constructor(ship: Ship | RObjectId, effect: BaseEffect) {
|
||
|
super(ship);
|
||
|
|
||
|
this.effect = effect;
|
||
|
}
|
||
|
|
||
|
protected applyOnShip(ship: Ship, battle: Battle): void {
|
||
|
ship.active_effects.add(this.effect);
|
||
|
}
|
||
|
|
||
|
protected getReverse(): BaseBattleDiff {
|
||
|
return new ShipEffectRemovedDiff(this.ship_id, this.effect);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* An attached effect is removed from a ship
|
||
|
*/
|
||
|
export class ShipEffectRemovedDiff extends BaseBattleShipDiff {
|
||
|
// Effect removed
|
||
|
effect: BaseEffect
|
||
|
|
||
|
constructor(ship: Ship | RObjectId, effect: BaseEffect) {
|
||
|
super(ship);
|
||
|
|
||
|
this.effect = effect;
|
||
|
}
|
||
|
|
||
|
protected applyOnShip(ship: Ship, battle: Battle): void {
|
||
|
ship.active_effects.remove(this.effect);
|
||
|
}
|
||
|
|
||
|
protected getReverse(): BaseBattleDiff {
|
||
|
return new ShipEffectAddedDiff(this.ship_id, this.effect);
|
||
|
}
|
||
|
}
|
||
|
}
|