2017-02-07 19:15:21 +00:00
|
|
|
/// <reference path="BaseEffect.ts"/>
|
|
|
|
|
2017-02-09 00:00:35 +00:00
|
|
|
module TS.SpaceTac {
|
2017-02-07 19:15:21 +00:00
|
|
|
/**
|
|
|
|
* Effect to modify an attribute.
|
|
|
|
*
|
|
|
|
* Attribute effects are stacking, and the value of an attribute is in fact the sum of all active attribute effects.
|
|
|
|
*/
|
|
|
|
export class AttributeEffect extends BaseEffect {
|
|
|
|
// Affected attribute
|
|
|
|
attrcode: keyof ShipAttributes;
|
|
|
|
|
|
|
|
// Base value
|
|
|
|
value: number;
|
|
|
|
|
2017-02-09 22:21:39 +00:00
|
|
|
constructor(attrcode: keyof ShipAttributes, value = 0) {
|
2017-02-07 19:15:21 +00:00
|
|
|
super("attr");
|
|
|
|
|
|
|
|
this.attrcode = attrcode;
|
|
|
|
this.value = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
applyOnShip(ship: Ship): boolean {
|
|
|
|
ship.updateAttributes();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
isBeneficial(): boolean {
|
|
|
|
return this.value >= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
getFullCode(): string {
|
|
|
|
return this.code + "-" + this.attrcode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|