2017-02-27 23:36:12 +00:00
|
|
|
module TS.SpaceTac.UI.Specs {
|
|
|
|
describe("CharacterSheet", function () {
|
|
|
|
|
2017-02-28 22:34:02 +00:00
|
|
|
describe("in UI", function () {
|
|
|
|
let testgame = setupEmptyView();
|
2017-02-27 23:36:12 +00:00
|
|
|
|
2017-02-28 22:34:02 +00:00
|
|
|
it("displays fleet and ship information", function () {
|
|
|
|
let view = testgame.baseview;
|
|
|
|
let sheet = new CharacterSheet(view, -1000);
|
2017-02-27 23:36:12 +00:00
|
|
|
|
2017-02-28 22:34:02 +00:00
|
|
|
expect(sheet.x).toEqual(-1000);
|
2017-02-27 23:36:12 +00:00
|
|
|
|
2017-02-28 22:34:02 +00:00
|
|
|
let fleet = new Fleet();
|
|
|
|
let ship1 = fleet.addShip();
|
2017-03-05 14:12:08 +00:00
|
|
|
ship1.addSlot(SlotType.Hull);
|
2017-02-28 22:34:02 +00:00
|
|
|
ship1.addSlot(SlotType.Engine);
|
|
|
|
ship1.addSlot(SlotType.Shield);
|
|
|
|
ship1.addSlot(SlotType.Weapon);
|
2017-03-05 17:48:13 +00:00
|
|
|
ship1.setCargoSpace(3);
|
2017-02-28 22:34:02 +00:00
|
|
|
ship1.name = "Ship 1";
|
|
|
|
let ship2 = fleet.addShip();
|
2017-03-05 14:12:08 +00:00
|
|
|
ship2.addSlot(SlotType.Hull);
|
2017-02-28 22:34:02 +00:00
|
|
|
ship2.name = "Ship 2";
|
2017-03-05 17:48:13 +00:00
|
|
|
ship2.setCargoSpace(2);
|
2017-02-27 23:36:12 +00:00
|
|
|
|
2017-02-28 22:34:02 +00:00
|
|
|
sheet.show(ship1, false);
|
2017-02-27 23:36:12 +00:00
|
|
|
|
2017-02-28 22:34:02 +00:00
|
|
|
expect(sheet.x).toEqual(0);
|
|
|
|
expect(sheet.portraits.length).toBe(2);
|
2017-02-27 23:36:12 +00:00
|
|
|
|
2017-02-28 22:34:02 +00:00
|
|
|
expect(sheet.ship_name.text).toEqual("Ship 1");
|
|
|
|
expect(sheet.ship_slots.length).toBe(4);
|
2017-03-05 17:48:13 +00:00
|
|
|
expect(sheet.ship_cargo.length).toBe(3);
|
2017-02-28 22:34:02 +00:00
|
|
|
|
|
|
|
let portrait = <Phaser.Button>sheet.portraits.getChildAt(1);
|
|
|
|
portrait.onInputUp.dispatch();
|
|
|
|
|
|
|
|
expect(sheet.ship_name.text).toEqual("Ship 2");
|
|
|
|
expect(sheet.ship_slots.length).toBe(1);
|
2017-03-05 17:48:13 +00:00
|
|
|
expect(sheet.ship_cargo.length).toBe(2);
|
2017-02-28 22:34:02 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("fits slots in area", function () {
|
|
|
|
let result = CharacterSheet.getSlotPositions(6, 300, 200, 100, 100);
|
|
|
|
expect(result).toEqual({
|
|
|
|
positions: [{ x: 0, y: 0 }, { x: 100, y: 0 }, { x: 200, y: 0 }, { x: 0, y: 100 }, { x: 100, y: 100 }, { x: 200, y: 100 }],
|
|
|
|
scaling: 1
|
|
|
|
});
|
2017-02-27 23:36:12 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|