2015-02-27 00:00:00 +00:00
|
|
|
/// <reference path="BaseEffect.ts"/>
|
|
|
|
|
2017-09-24 22:23:22 +00:00
|
|
|
module TK.SpaceTac {
|
2017-01-24 00:14:04 +00:00
|
|
|
/**
|
2017-11-14 00:07:06 +00:00
|
|
|
* Wrapper around another effect, to make it stick to a ship for a given number of turns.
|
2017-01-24 00:14:04 +00:00
|
|
|
*
|
2017-11-14 00:07:06 +00:00
|
|
|
* The "effect" is to stick the wrapped effect to the ship.
|
2017-01-24 00:14:04 +00:00
|
|
|
*/
|
2017-01-23 23:07:54 +00:00
|
|
|
export class StickyEffect extends BaseEffect {
|
2017-01-24 00:14:04 +00:00
|
|
|
// Wrapped effect
|
2017-11-14 00:07:06 +00:00
|
|
|
base: BaseEffect
|
2017-01-24 00:14:04 +00:00
|
|
|
|
2015-02-27 00:00:00 +00:00
|
|
|
// Duration, in number of turns
|
2017-11-14 00:07:06 +00:00
|
|
|
duration: number
|
2017-01-24 00:14:04 +00:00
|
|
|
|
2015-02-27 00:00:00 +00:00
|
|
|
// Base constructor
|
2017-11-14 00:07:06 +00:00
|
|
|
constructor(base: BaseEffect, duration = 0) {
|
2017-01-24 00:14:04 +00:00
|
|
|
super(base.code);
|
2015-02-27 00:00:00 +00:00
|
|
|
|
2017-01-24 00:14:04 +00:00
|
|
|
this.base = base;
|
2015-02-27 00:00:00 +00:00
|
|
|
this.duration = duration;
|
|
|
|
}
|
|
|
|
|
2017-11-14 00:07:06 +00:00
|
|
|
getOnDiffs(ship: Ship, source: Ship | Drone): BaseBattleDiff[] {
|
|
|
|
// TODO if already there, remove the previous one to replace it
|
|
|
|
let result: BaseBattleDiff[] = [
|
|
|
|
new ShipEffectAddedDiff(ship, new StickyEffect(this.base, this.duration)),
|
|
|
|
]
|
2017-01-24 00:14:04 +00:00
|
|
|
|
2017-11-14 00:07:06 +00:00
|
|
|
result = result.concat(this.base.getOnDiffs(ship, source));
|
2017-01-24 00:14:04 +00:00
|
|
|
|
2017-11-14 00:07:06 +00:00
|
|
|
return result;
|
2017-01-24 00:14:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
isBeneficial(): boolean {
|
|
|
|
return this.base.isBeneficial();
|
2015-02-27 00:00:00 +00:00
|
|
|
}
|
2015-04-22 20:03:59 +00:00
|
|
|
|
|
|
|
getFullCode(): string {
|
2017-01-24 00:14:04 +00:00
|
|
|
return this.base.getFullCode();
|
|
|
|
}
|
|
|
|
|
|
|
|
getDescription(): string {
|
2017-05-22 20:17:59 +00:00
|
|
|
return this.base.getDescription() + ` for ${this.duration} turn${this.duration > 1 ? "s" : ""}`;
|
2015-04-22 20:03:59 +00:00
|
|
|
}
|
2015-02-27 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|