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 {
|
2015-02-27 00:00:00 +00:00
|
|
|
// Hard limitation on attribute 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
|
|
|
|
attrcode: AttributeCode;
|
|
|
|
|
|
|
|
// Limit of the attribute value
|
|
|
|
value: number;
|
|
|
|
|
2017-01-24 00:14:04 +00:00
|
|
|
constructor(attrcode: AttributeCode, value: number = 0) {
|
|
|
|
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 {
|
2015-02-27 00:00:00 +00:00
|
|
|
var current = ship.attributes.getValue(this.attrcode);
|
|
|
|
if (current > this.value) {
|
|
|
|
ship.setAttribute(ship.attributes.getRawAttr(this.attrcode), this.value);
|
|
|
|
}
|
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 {
|
|
|
|
return this.code + "-" + AttributeCode[this.attrcode].toLowerCase().replace("_", "");
|
|
|
|
}
|
2017-01-16 23:20:33 +00:00
|
|
|
|
|
|
|
getDescription(): string {
|
|
|
|
return `limit ${ATTRIBUTE_NAMES[this.attrcode]} to ${this.value}`;
|
|
|
|
}
|
2017-01-03 22:26:56 +00:00
|
|
|
}
|
2015-02-27 00:00:00 +00:00
|
|
|
}
|