2017-02-07 00:08:07 +00:00
|
|
|
/// <reference path="BaseAction.ts"/>
|
|
|
|
|
2017-02-09 00:00:35 +00:00
|
|
|
module TS.SpaceTac {
|
2017-02-07 00:08:07 +00:00
|
|
|
/**
|
|
|
|
* Action to deploy a drone in space
|
|
|
|
*/
|
|
|
|
export class DeployDroneAction extends BaseAction {
|
|
|
|
constructor(equipment: Equipment) {
|
|
|
|
super("deploy-" + equipment.code, "Deploy", true, equipment);
|
|
|
|
}
|
|
|
|
|
2017-03-07 19:27:46 +00:00
|
|
|
checkLocationTarget(ship: Ship, target: Target): Target {
|
2017-02-07 00:08:07 +00:00
|
|
|
// TODO Not too close to other ships and drones
|
|
|
|
target = target.constraintInRange(ship.arena_x, ship.arena_y, this.equipment.distance);
|
|
|
|
return target;
|
|
|
|
}
|
|
|
|
|
2017-03-07 19:27:46 +00:00
|
|
|
protected customApply(ship: Ship, target: Target) {
|
2017-02-08 18:54:02 +00:00
|
|
|
let drone = new Drone(ship, this.equipment.code);
|
2017-02-07 00:08:07 +00:00
|
|
|
drone.x = target.x;
|
|
|
|
drone.y = target.y;
|
|
|
|
drone.radius = this.equipment.blast;
|
|
|
|
drone.effects = this.equipment.target_effects;
|
|
|
|
drone.duration = this.equipment.duration;
|
2017-03-07 19:27:46 +00:00
|
|
|
|
|
|
|
let battle = ship.getBattle();
|
|
|
|
if (battle) {
|
|
|
|
battle.addDrone(drone);
|
|
|
|
}
|
2017-02-07 00:08:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|