2017-08-17 17:51:22 +00:00
|
|
|
/// <reference path="BaseEffect.ts"/>
|
|
|
|
|
2017-09-24 22:23:22 +00:00
|
|
|
module TK.SpaceTac {
|
2017-08-17 17:51:22 +00:00
|
|
|
/**
|
|
|
|
* Repel ships from a central point
|
|
|
|
*/
|
|
|
|
export class RepelEffect extends BaseEffect {
|
|
|
|
value: number;
|
|
|
|
|
|
|
|
constructor(value = 0) {
|
|
|
|
super("repel");
|
|
|
|
|
|
|
|
this.value = value;
|
|
|
|
}
|
|
|
|
|
2018-03-20 23:23:00 +00:00
|
|
|
getOnDiffs(ship: Ship, source: Ship | Drone): BaseBattleDiff[] {
|
2017-08-17 17:51:22 +00:00
|
|
|
if (ship != source) {
|
|
|
|
let angle = arenaAngle(source.location, ship.location);
|
|
|
|
let destination = new ArenaLocation(ship.arena_x + Math.cos(angle) * this.value, ship.arena_y + Math.sin(angle) * this.value);
|
|
|
|
let exclusions = ExclusionAreas.fromShip(ship);
|
|
|
|
destination = exclusions.stopBefore(destination, ship.location);
|
2017-11-14 00:07:06 +00:00
|
|
|
// TODO Apply area effect adding/removal
|
|
|
|
return [
|
|
|
|
new ShipMoveDiff(ship, ship.location, new ArenaLocationAngle(destination.x, destination.y, ship.arena_angle))
|
|
|
|
];
|
|
|
|
} else {
|
|
|
|
return [];
|
2017-08-17 17:51:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
getDescription(): string {
|
|
|
|
return `repel ships ${this.value}km away`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|