1
0
Fork 0
spacetac/src/core/actions/DeployDroneAction.ts

35 lines
1.1 KiB
TypeScript
Raw Normal View History

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 {
2017-03-09 17:11:00 +00:00
equipment: Equipment;
2017-02-07 00:08:07 +00:00
constructor(equipment: Equipment) {
super("deploy-" + equipment.code, "Deploy", true, equipment);
}
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;
}
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;
let battle = ship.getBattle();
if (battle) {
battle.addDrone(drone);
}
2017-02-07 00:08:07 +00:00
}
}
}