2017-01-24 00:14:04 +00:00
|
|
|
/// <reference path="BaseEffect.ts"/>
|
2015-02-27 00:00:00 +00:00
|
|
|
|
2017-01-26 23:52:45 +00:00
|
|
|
module TS.SpaceTac.Game {
|
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;
|
|
|
|
}
|
|
|
|
|
2017-01-24 00:14:04 +00:00
|
|
|
applyOnShip(ship: Ship): boolean {
|
2017-02-07 19:15:21 +00:00
|
|
|
ship.updateAttributes();
|
2017-01-24 00:14:04 +00:00
|
|
|
return true;
|
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-02-07 19:15:21 +00:00
|
|
|
let attrname = SHIP_ATTRIBUTES[this.attrcode].name;
|
|
|
|
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
|
|
|
}
|