2015-01-13 00:00:00 +00:00
|
|
|
module SpaceTac.Game {
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
// Piece of equipment to attach in slots
|
|
|
|
export class Equipment {
|
|
|
|
// Type of slot this equipment will fit in
|
|
|
|
slot: SlotType;
|
|
|
|
|
|
|
|
// Equipment name
|
|
|
|
name: string;
|
|
|
|
|
2015-01-29 00:00:00 +00:00
|
|
|
// Maximal distance allowed to target
|
2015-01-13 00:00:00 +00:00
|
|
|
distance: number;
|
|
|
|
|
|
|
|
// Effect area's radius
|
|
|
|
blast: number;
|
|
|
|
|
|
|
|
// Duration
|
|
|
|
duration: number;
|
|
|
|
|
|
|
|
// Action Points usage
|
|
|
|
ap_usage: number;
|
|
|
|
|
|
|
|
// Level requirement
|
|
|
|
min_level: number;
|
2015-01-16 00:00:00 +00:00
|
|
|
|
2015-02-06 00:00:00 +00:00
|
|
|
// Minimal attribute to be able to equip this equipment
|
|
|
|
requirements: Attribute[];
|
|
|
|
|
2015-01-16 00:00:00 +00:00
|
|
|
// Action associated with this equipment
|
|
|
|
action: BaseAction;
|
2015-01-22 00:00:00 +00:00
|
|
|
|
2015-02-06 00:00:00 +00:00
|
|
|
// Permanent effects on the ship that equips the equipment
|
2015-01-22 00:00:00 +00:00
|
|
|
permanent_effects: BaseEffect[];
|
|
|
|
|
2015-01-28 00:00:00 +00:00
|
|
|
// Effects on target
|
|
|
|
target_effects: BaseEffect[];
|
|
|
|
|
2015-01-22 00:00:00 +00:00
|
|
|
// Basic constructor
|
|
|
|
constructor() {
|
2015-02-06 00:00:00 +00:00
|
|
|
this.requirements = [];
|
2015-01-22 00:00:00 +00:00
|
|
|
this.permanent_effects = [];
|
2015-01-28 00:00:00 +00:00
|
|
|
this.target_effects = [];
|
2015-01-22 00:00:00 +00:00
|
|
|
}
|
2015-02-06 00:00:00 +00:00
|
|
|
|
|
|
|
// Returns true if the equipment can be equipped on a ship
|
|
|
|
// This checks *requirements* against the ship capabilities
|
|
|
|
canBeEquipped(ship: Ship): boolean {
|
|
|
|
var able = true;
|
|
|
|
this.requirements.forEach((cap: Attribute) => {
|
|
|
|
if (ship.attributes.getValue(cap.code) < cap.current) {
|
|
|
|
able = false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return able;
|
|
|
|
}
|
2015-01-13 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|