1
0
Fork 0

Fixed ship rotating when applying action with no target

This commit is contained in:
Michaël Lemaire 2017-09-14 23:33:08 +02:00
parent 2265f53a7b
commit 44426745d6
2 changed files with 18 additions and 3 deletions

View file

@ -66,5 +66,20 @@ module TS.SpaceTac {
target = weapon.action.checkTarget(ship1, Target.newFromShip(ship2));
expect(target).toEqual(new Target(100, 10));
});
it("rotates toward the target", function () {
let ship = new Ship();
let weapon = TestTools.addWeapon(ship, 1, 0, 100, 30);
expect(ship.arena_angle).toEqual(0);
let result = weapon.action.apply(ship, Target.newFromLocation(10, 20));
expect(result).toBe(true);
expect(ship.arena_angle).toBeCloseTo(1.107, 0.001);
weapon.action.needs_target = false;
result = weapon.action.apply(ship, null);
expect(result).toBe(true);
expect(ship.arena_angle).toBeCloseTo(1.107, 0.001);
});
});
}

View file

@ -84,11 +84,11 @@ module TS.SpaceTac {
if (!target) {
// Self-target
target = Target.newFromShip(ship);
} else {
// Face the target
ship.rotate(Target.newFromShip(ship).getAngleTo(target), first(ship.listEquipment(SlotType.Engine), () => true));
}
// Face the target
ship.rotate(Target.newFromShip(ship).getAngleTo(target), first(ship.listEquipment(SlotType.Engine), () => true));
// Fire event
ship.addBattleEvent(new FireEvent(ship, this.equipment, target));