1
0
Fork 0
spacetac/src/core/diffs/ShipEffectAddedDiff.ts

48 lines
1.2 KiB
TypeScript
Raw Normal View History

/// <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);
}
}
}