2017-02-09 00:00:35 +00:00
|
|
|
module TS.SpaceTac.Specs {
|
2015-02-13 00:00:00 +00:00
|
|
|
describe("BattleOutcome", () => {
|
2017-03-14 17:48:04 +00:00
|
|
|
it("generates loot from defeated ships", () => {
|
2015-02-13 00:00:00 +00:00
|
|
|
var fleet1 = new Fleet();
|
2017-03-14 17:48:04 +00:00
|
|
|
fleet1.addShip(new Ship());
|
2015-02-13 00:00:00 +00:00
|
|
|
var fleet2 = new Fleet();
|
2017-03-14 17:48:04 +00:00
|
|
|
fleet2.addShip(new Ship());
|
|
|
|
fleet2.addShip(new Ship());
|
|
|
|
fleet2.addShip(new Ship());
|
|
|
|
fleet2.addShip(new Ship());
|
2015-02-13 00:00:00 +00:00
|
|
|
|
2017-03-17 00:07:00 +00:00
|
|
|
fleet2.ships[2].level.forceLevel(5);
|
|
|
|
fleet2.ships[3].level.forceLevel(5);
|
2015-03-12 00:00:00 +00:00
|
|
|
|
2017-03-14 17:48:04 +00:00
|
|
|
fleet2.ships[0].addSlot(SlotType.Weapon).attach(new Equipment(SlotType.Weapon, "0a"));
|
|
|
|
fleet2.ships[0].addSlot(SlotType.Weapon).attach(new Equipment(SlotType.Weapon, "0b"));
|
|
|
|
fleet2.ships[1].addSlot(SlotType.Weapon).attach(new Equipment(SlotType.Weapon, "1a"));
|
|
|
|
fleet2.ships[2].addSlot(SlotType.Weapon).attach(new Equipment(SlotType.Weapon, "2b"));
|
|
|
|
fleet2.ships[3].addSlot(SlotType.Weapon).attach(new Equipment(SlotType.Weapon, "3b"));
|
2015-02-13 00:00:00 +00:00
|
|
|
|
|
|
|
var battle = new Battle(fleet1, fleet2);
|
|
|
|
var outcome = new BattleOutcome(fleet1);
|
|
|
|
|
2017-02-26 17:44:15 +00:00
|
|
|
var random = new SkewedRandomGenerator([
|
2017-03-14 17:48:04 +00:00
|
|
|
0.6, // standard loot on first ship
|
2015-02-13 00:00:00 +00:00
|
|
|
0, // - take first equipment
|
2017-03-14 17:48:04 +00:00
|
|
|
0, // leave second ship alone
|
2015-02-13 00:00:00 +00:00
|
|
|
0.95, // lucky loot on third ship
|
2017-03-14 17:48:04 +00:00
|
|
|
0, // - lower end of level range (ship has 5, so range is 4-6)
|
2017-04-20 21:20:50 +00:00
|
|
|
0.5, // - common quality
|
2015-02-13 00:00:00 +00:00
|
|
|
0, // - take first generated equipment (there is only one anyway)
|
|
|
|
0.96, // lucky loot on fourth ship
|
2017-04-20 21:20:50 +00:00
|
|
|
0.999, // - higher end of level range
|
|
|
|
0.98 // - premium quality
|
2017-02-26 17:44:15 +00:00
|
|
|
]);
|
2015-02-13 00:00:00 +00:00
|
|
|
|
|
|
|
// Force lucky finds with one template
|
|
|
|
var looter = new LootGenerator(random, false);
|
|
|
|
var template = new LootTemplate(SlotType.Power, "Nuclear Reactor");
|
2017-04-18 19:51:23 +00:00
|
|
|
template.setSkillsRequirements({ "skill_energy": istep(4) });
|
2017-04-20 21:20:50 +00:00
|
|
|
template.addAttributeEffect("power_capacity", 1);
|
2015-02-13 00:00:00 +00:00
|
|
|
looter.templates = [template];
|
|
|
|
spyOn(outcome, "getLootGenerator").and.returnValue(looter);
|
|
|
|
|
2015-02-13 00:00:00 +00:00
|
|
|
outcome.createLoot(battle, random);
|
|
|
|
|
2017-03-14 17:48:04 +00:00
|
|
|
expect(outcome.loot.length).toBe(3);
|
|
|
|
expect(outcome.loot[0].name).toBe("0a");
|
|
|
|
expect(outcome.loot[1].name).toBe("Nuclear Reactor");
|
2017-04-20 21:20:50 +00:00
|
|
|
expect(outcome.loot[1].level).toBe(4);
|
|
|
|
expect(outcome.loot[1].quality).toBe(EquipmentQuality.COMMON);
|
2017-04-18 19:51:23 +00:00
|
|
|
expect(outcome.loot[1].requirements).toEqual({ "skill_energy": 7 });
|
2017-03-14 17:48:04 +00:00
|
|
|
expect(outcome.loot[2].name).toBe("Nuclear Reactor");
|
2017-04-20 21:20:50 +00:00
|
|
|
expect(outcome.loot[2].level).toBe(6);
|
|
|
|
expect(outcome.loot[2].quality).toBe(EquipmentQuality.PREMIUM);
|
2017-04-18 19:51:23 +00:00
|
|
|
expect(outcome.loot[2].requirements).toEqual({ "skill_energy": 9 });
|
2015-02-13 00:00:00 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|