2017-01-24 00:14:04 +00:00
|
|
|
/// <reference path="BaseEffect.ts"/>
|
2015-02-27 00:00:00 +00:00
|
|
|
|
2017-09-24 22:23:22 +00:00
|
|
|
module TK.SpaceTac {
|
2017-02-07 19:15:21 +00:00
|
|
|
/**
|
|
|
|
* Enforce a limitation on ship attribute final value
|
|
|
|
*
|
|
|
|
* For example, this could be used to slow a target by limiting its action points
|
|
|
|
*/
|
2017-01-24 00:14:04 +00:00
|
|
|
export class AttributeLimitEffect extends BaseEffect {
|
2015-02-27 00:00:00 +00:00
|
|
|
// Affected attribute
|
2017-02-07 19:15:21 +00:00
|
|
|
attrcode: keyof ShipAttributes;
|
2015-02-27 00:00:00 +00:00
|
|
|
|
|
|
|
// Limit of the attribute value
|
|
|
|
value: number;
|
|
|
|
|
2017-02-07 19:15:21 +00:00
|
|
|
constructor(attrcode: keyof ShipAttributes, value = 0) {
|
2017-01-24 00:14:04 +00:00
|
|
|
super("attrlimit");
|
2015-02-27 00:00:00 +00:00
|
|
|
|
|
|
|
this.attrcode = attrcode;
|
|
|
|
this.value = value;
|
|
|
|
}
|
|
|
|
|
2018-03-20 23:23:00 +00:00
|
|
|
getOnDiffs(ship: Ship, source: Ship | Drone): BaseBattleDiff[] {
|
2017-11-14 00:07:06 +00:00
|
|
|
return [
|
|
|
|
new ShipAttributeDiff(ship, this.attrcode, { limit: this.value }, {}),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2017-11-29 22:03:58 +00:00
|
|
|
getOffDiffs(ship: Ship): BaseBattleDiff[] {
|
2017-11-14 00:07:06 +00:00
|
|
|
return [
|
|
|
|
new ShipAttributeDiff(ship, this.attrcode, {}, { limit: this.value }),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
isBeneficial(): boolean {
|
|
|
|
return false;
|
2015-02-27 00:00:00 +00:00
|
|
|
}
|
2015-04-22 20:03:59 +00:00
|
|
|
|
|
|
|
getFullCode(): string {
|
2017-02-07 19:15:21 +00:00
|
|
|
return this.code + "-" + this.attrcode;
|
2015-04-22 20:03:59 +00:00
|
|
|
}
|
2017-01-16 23:20:33 +00:00
|
|
|
|
|
|
|
getDescription(): string {
|
2017-11-14 00:07:06 +00:00
|
|
|
let attrname = SHIP_VALUES_NAMES[this.attrcode];
|
2017-02-07 19:15:21 +00:00
|
|
|
return `limit ${attrname} to ${this.value}`;
|
2017-01-16 23:20:33 +00:00
|
|
|
}
|
2017-01-03 22:26:56 +00:00
|
|
|
}
|
2015-02-27 00:00:00 +00:00
|
|
|
}
|