2014-12-31 00:00:00 +00:00
|
|
|
/// <reference path="../../definitions/jasmine.d.ts"/>
|
2014-12-31 00:00:00 +00:00
|
|
|
|
2014-12-31 00:00:00 +00:00
|
|
|
module SpaceTac.Game {
|
2015-01-07 00:00:00 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
describe("Ship", function () {
|
|
|
|
it("limits movement range by action points", function () {
|
2014-12-31 00:00:00 +00:00
|
|
|
var ship = new Ship(null, "Test");
|
2014-12-31 00:00:00 +00:00
|
|
|
ship.ap_current = 8;
|
|
|
|
ship.movement_cost = 3;
|
|
|
|
ship.setArenaPosition(50, 50);
|
|
|
|
|
|
|
|
var point = ship.getLongestMove(51, 52);
|
|
|
|
expect(point).toEqual([51, 52]);
|
|
|
|
|
2015-01-07 00:00:00 +00:00
|
|
|
point = ship.getLongestMove(60, 55);
|
2014-12-31 00:00:00 +00:00
|
|
|
expect(point[0]).toBeCloseTo(52.385139, 0.0001);
|
|
|
|
expect(point[1]).toBeCloseTo(51.19256, 0.0001);
|
|
|
|
});
|
|
|
|
|
2015-01-07 00:00:00 +00:00
|
|
|
it("moves and consumes action points", function () {
|
2014-12-31 00:00:00 +00:00
|
|
|
var ship = new Ship(null, "Test");
|
2014-12-31 00:00:00 +00:00
|
|
|
ship.ap_current = 8;
|
|
|
|
ship.movement_cost = 3;
|
|
|
|
ship.setArenaPosition(50, 50);
|
|
|
|
|
|
|
|
ship.moveTo(51, 50);
|
|
|
|
expect(ship.ap_current).toEqual(5);
|
|
|
|
expect(ship.arena_x).toEqual(51);
|
|
|
|
expect(ship.arena_y).toEqual(50);
|
|
|
|
|
|
|
|
ship.moveTo(53, 50);
|
|
|
|
expect(ship.ap_current).toBe(0);
|
|
|
|
expect(ship.arena_x).toBeCloseTo(52.333333, 0.00001);
|
|
|
|
expect(ship.arena_y).toEqual(50);
|
|
|
|
});
|
|
|
|
});
|
2015-01-07 00:00:00 +00:00
|
|
|
}
|