2017-09-28 23:18:46 +00:00
|
|
|
/// <reference path="../TestGame.ts"/>
|
|
|
|
|
|
|
|
module TK.SpaceTac.UI.Specs {
|
|
|
|
describe("ActionIcon", function () {
|
|
|
|
let testgame = setupBattleview();
|
|
|
|
|
|
|
|
it("displays power usage", function () {
|
|
|
|
let bar = testgame.battleview.action_bar;
|
|
|
|
let ship = new Ship();
|
|
|
|
let action = new BaseAction("something", "Do something");
|
|
|
|
let icon = new ActionIcon(bar, ship, action, 0);
|
|
|
|
expect(icon.img_power.visible).toBe(false, "initial state");
|
|
|
|
|
|
|
|
icon.refresh();
|
|
|
|
expect(icon.img_power.visible).toBe(false, "no change");
|
|
|
|
|
|
|
|
spyOn(action, "getActionPointsUsage").and.returnValue(3);
|
|
|
|
icon.refresh();
|
|
|
|
expect(icon.img_power.visible).toBe(true);
|
|
|
|
expect(icon.text_power.text).toBe("3");
|
|
|
|
})
|
|
|
|
|
|
|
|
it("displays disabled and fading states", function () {
|
|
|
|
let bar = testgame.battleview.action_bar;
|
|
|
|
let ship = new Ship();
|
|
|
|
TestTools.setShipAP(ship, 5);
|
|
|
|
let action = nn(TestTools.addWeapon(ship, 50, 3).action);
|
|
|
|
let icon = new ActionIcon(bar, ship, action, 0);
|
|
|
|
|
2017-10-01 16:33:48 +00:00
|
|
|
expect(icon.container.name).toBe("battle-actionbar-frame-enabled", "5/5");
|
2017-09-28 23:18:46 +00:00
|
|
|
expect(icon.img_power.name).toBe("battle-actionbar-consumption-enabled", "5/5");
|
|
|
|
expect(icon.img_power.visible).toBe(true, "5/5");
|
|
|
|
expect(icon.img_bottom.name).toBe("battle-actionbar-bottom-enabled", "5/5");
|
|
|
|
|
|
|
|
icon.refresh(null, 1);
|
2017-10-01 16:33:48 +00:00
|
|
|
expect(icon.container.name).toBe("battle-actionbar-frame-enabled", "4/5");
|
2017-09-28 23:18:46 +00:00
|
|
|
expect(icon.img_power.name).toBe("battle-actionbar-consumption-enabled", "4/5");
|
|
|
|
expect(icon.img_power.visible).toBe(true, "4/5");
|
|
|
|
expect(icon.img_bottom.name).toBe("battle-actionbar-bottom-enabled", "4/5");
|
|
|
|
|
|
|
|
icon.refresh(null, 4);
|
2017-10-01 16:33:48 +00:00
|
|
|
expect(icon.container.name).toBe("battle-actionbar-frame-fading", "1/5");
|
|
|
|
expect(icon.img_power.name).toBe("battle-actionbar-consumption-enabled", "1/5");
|
2017-09-28 23:18:46 +00:00
|
|
|
expect(icon.img_power.visible).toBe(true, "1/5");
|
|
|
|
expect(icon.img_bottom.name).toBe("battle-actionbar-bottom-enabled", "1/5");
|
|
|
|
|
|
|
|
ship.setValue("power", 2);
|
|
|
|
icon.refresh();
|
2017-10-01 16:33:48 +00:00
|
|
|
expect(icon.container.name).toBe("battle-actionbar-frame-disabled", "2/2");
|
2017-09-28 23:18:46 +00:00
|
|
|
expect(icon.img_power.name).toBe("battle-actionbar-consumption-disabled", "2/2");
|
|
|
|
expect(icon.img_power.visible).toBe(true, "2/2");
|
|
|
|
expect(icon.img_bottom.name).toBe("battle-actionbar-bottom-disabled", "2/2");
|
|
|
|
|
|
|
|
icon.refresh(null, 6);
|
2017-10-01 16:33:48 +00:00
|
|
|
expect(icon.container.name).toBe("battle-actionbar-frame-disabled", "0/2");
|
2017-09-28 23:18:46 +00:00
|
|
|
expect(icon.img_power.name).toBe("battle-actionbar-consumption-disabled", "0/2");
|
|
|
|
expect(icon.img_power.visible).toBe(true, "0/2");
|
|
|
|
expect(icon.img_bottom.name).toBe("battle-actionbar-bottom-disabled", "0/2");
|
|
|
|
})
|
|
|
|
|
|
|
|
it("displays toggle state", function () {
|
2017-10-01 16:33:48 +00:00
|
|
|
let bar = testgame.battleview.action_bar;
|
|
|
|
let ship = new Ship();
|
|
|
|
TestTools.setShipAP(ship, 5);
|
|
|
|
let equipment = new Equipment(SlotType.Weapon);
|
|
|
|
ship.addSlot(SlotType.Weapon).attach(equipment);
|
|
|
|
let action = new ToggleAction(equipment, 2);
|
|
|
|
equipment.action = action;
|
|
|
|
let icon = new ActionIcon(bar, ship, action, 0);
|
2017-09-28 23:18:46 +00:00
|
|
|
|
2017-10-01 16:33:48 +00:00
|
|
|
expect(icon.img_bottom.name).toBe("battle-actionbar-bottom-enabled", "initial");
|
|
|
|
expect(icon.img_power.name).toBe("battle-actionbar-consumption-enabled", "initial");
|
|
|
|
expect(icon.img_sticky.name).toBe("battle-actionbar-sticky-untoggled", "initial");
|
|
|
|
expect(icon.img_sticky.visible).toBe(true, "initial");
|
|
|
|
|
|
|
|
action.activated = true;
|
|
|
|
icon.refresh();
|
|
|
|
expect(icon.img_bottom.name).toBe("battle-actionbar-bottom-toggled", "initial");
|
|
|
|
expect(icon.img_power.name).toBe("battle-actionbar-consumption-toggled", "initial");
|
|
|
|
expect(icon.img_sticky.name).toBe("battle-actionbar-sticky-toggled", "initial");
|
|
|
|
expect(icon.img_sticky.visible).toBe(true, "initial");
|
2017-09-28 23:18:46 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it("displays overheat/cooldown", function () {
|
2017-10-01 18:16:41 +00:00
|
|
|
let bar = testgame.battleview.action_bar;
|
|
|
|
let ship = new Ship();
|
|
|
|
TestTools.setShipAP(ship, 5);
|
|
|
|
let action = nn(TestTools.addWeapon(ship, 50, 3).action);
|
|
|
|
action.cooldown.configure(1, 3);
|
|
|
|
let icon = new ActionIcon(bar, ship, action, 0);
|
|
|
|
expect(icon.img_sticky.visible).toBe(false, "initial");
|
|
|
|
expect(icon.img_sticky.name).toBe("battle-actionbar-sticky-untoggled", "initial");
|
|
|
|
expect(icon.img_sticky.children.length).toBe(0, "initial");
|
2017-09-28 23:18:46 +00:00
|
|
|
|
2017-10-01 18:16:41 +00:00
|
|
|
icon.refresh(action);
|
|
|
|
expect(icon.img_sticky.visible).toBe(true, "overheat");
|
|
|
|
expect(icon.img_sticky.name).toBe("battle-actionbar-sticky-overheat", "overheat");
|
|
|
|
expect(icon.img_sticky.children.length).toBe(3, "overheat");
|
|
|
|
|
|
|
|
action.cooldown.configure(1, 12);
|
|
|
|
icon.refresh(action);
|
|
|
|
expect(icon.img_sticky.visible).toBe(true, "superheat");
|
|
|
|
expect(icon.img_sticky.name).toBe("battle-actionbar-sticky-overheat", "superheat");
|
|
|
|
expect(icon.img_sticky.children.length).toBe(5, "superheat");
|
|
|
|
|
|
|
|
action.cooldown.configure(1, 4);
|
|
|
|
action.cooldown.use();
|
|
|
|
icon.refresh(action);
|
|
|
|
expect(icon.img_sticky.visible).toBe(true, "cooling");
|
|
|
|
expect(icon.img_sticky.name).toBe("battle-actionbar-sticky-disabled", "cooling");
|
|
|
|
expect(icon.img_sticky.children.length).toBe(4, "cooling");
|
2017-09-28 23:18:46 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it("displays currently targetting", function () {
|
2017-10-01 16:33:48 +00:00
|
|
|
testgame.battleview.animations.setImmediate();
|
|
|
|
|
|
|
|
let bar = testgame.battleview.action_bar;
|
|
|
|
let ship = new Ship();
|
|
|
|
TestTools.setShipAP(ship, 5);
|
|
|
|
let action = nn(TestTools.addWeapon(ship, 50, 3).action);
|
|
|
|
let icon = new ActionIcon(bar, ship, action, 0);
|
|
|
|
expect(icon.img_targetting.visible).toBe(false, "initial");
|
|
|
|
|
|
|
|
icon.refresh(action);
|
|
|
|
expect(icon.img_targetting.visible).toBe(true, "selected");
|
2017-09-28 23:18:46 +00:00
|
|
|
|
2017-10-01 16:33:48 +00:00
|
|
|
icon.refresh(new BaseAction("other", "Other action"));
|
|
|
|
expect(icon.img_targetting.visible).toBe(false, "other");
|
2017-09-28 23:18:46 +00:00
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|