2017-11-14 00:07:06 +00:00
|
|
|
/// <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);
|
|
|
|
|
2017-11-28 18:01:56 +00:00
|
|
|
this.effect = duplicate(effect, TK.SpaceTac);
|
2017-11-14 00:07:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected applyOnShip(ship: Ship, battle: Battle): void {
|
2017-11-28 18:01:56 +00:00
|
|
|
ship.active_effects.add(duplicate(this.effect, TK.SpaceTac));
|
2017-11-14 00:07:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2017-11-28 18:01:56 +00:00
|
|
|
this.effect = duplicate(effect, TK.SpaceTac);
|
2017-11-14 00:07:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected applyOnShip(ship: Ship, battle: Battle): void {
|
|
|
|
ship.active_effects.remove(this.effect);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected getReverse(): BaseBattleDiff {
|
|
|
|
return new ShipEffectAddedDiff(this.ship_id, this.effect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|