Fixed ship rotating when applying action with no target
This commit is contained in:
parent
2265f53a7b
commit
44426745d6
|
@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
Loading…
Reference in a new issue