1
0
Fork 0
spacetac/src/game/effects/BaseEffect.ts

50 lines
1.5 KiB
TypeScript
Raw Normal View History

2015-03-03 00:00:00 +00:00
/// <reference path="../Serializable.ts"/>
module TS.SpaceTac.Game {
// Base class for effects of actions
2017-01-23 23:07:54 +00:00
// Effects are typically one shot, but sticky effects can be used to apply effects over a period
2015-03-03 00:00:00 +00:00
export class BaseEffect extends Serializable {
// Identifier code for the type of effect
code: string;
// Base constructor
constructor(code: string) {
2015-03-03 00:00:00 +00:00
super();
this.code = code;
}
2015-01-28 00:00:00 +00:00
/**
* Get a copy, modified by template modifiers
*/
getModifiedCopy(modifiers: EffectTemplateModifier[], power: number): BaseEffect {
let result = Tools.copyObject(this);
modifiers.forEach(modifier => {
result[modifier.name] = modifier.range.getProportional(power);
});
return result;
}
2015-01-28 00:00:00 +00:00
// Apply ponctually the effect on a given ship
// Return true if the effect could be applied
applyOnShip(ship: Ship): boolean {
return false;
}
// Return true if the effect is beneficial to the ship, false if it's a drawback
isBeneficial(): boolean {
return false;
}
// Get a full code, that can be used to identify this effect (for example: "attrlimit-aprecovery")
getFullCode(): string {
return this.code;
}
// Return a human readable description
getDescription(): string {
return "unknown effect";
}
}
}