2015-02-27 00:00:00 +00:00
|
|
|
/// <reference path="TemporaryEffect.ts"/>
|
|
|
|
|
|
|
|
module SpaceTac.Game {
|
|
|
|
// Hard limitation on attribute value
|
|
|
|
// For example, this could be used to slow a target by limiting its action points
|
|
|
|
export class AttributeLimitEffect extends TemporaryEffect {
|
|
|
|
// Affected attribute
|
|
|
|
attrcode: AttributeCode;
|
|
|
|
|
|
|
|
// Limit of the attribute value
|
|
|
|
value: number;
|
|
|
|
|
|
|
|
constructor(attrcode: AttributeCode, duration: number = 0, value: number = 0) {
|
|
|
|
super("attrlimit", duration);
|
|
|
|
|
|
|
|
this.attrcode = attrcode;
|
|
|
|
this.value = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
singleApply(ship: Ship, on_stick: boolean): void {
|
|
|
|
var current = ship.attributes.getValue(this.attrcode);
|
|
|
|
if (current > this.value) {
|
|
|
|
ship.setAttribute(ship.attributes.getRawAttr(this.attrcode), this.value);
|
|
|
|
}
|
|
|
|
}
|
2015-04-22 20:03:59 +00:00
|
|
|
|
|
|
|
getFullCode(): string {
|
|
|
|
return this.code + "-" + AttributeCode[this.attrcode].toLowerCase().replace("_", "");
|
|
|
|
}
|
2017-01-03 22:26:56 +00:00
|
|
|
}
|
2015-02-27 00:00:00 +00:00
|
|
|
}
|