1
0
Fork 0
spacetac/src/core/missions/MissionPartCleanLocation.spec.ts

42 lines
1.7 KiB
TypeScript
Raw Normal View History

2017-09-24 22:23:22 +00:00
module TK.SpaceTac.Specs {
2017-10-26 21:47:13 +00:00
testing("MissionPartEscort", test => {
test.case("completes when the fleet is at location, and the encounter is clean", check => {
2017-07-10 20:40:22 +00:00
let destination = new StarLocation(new Star(null, 0, 0, "Atanax"));
destination.clearEncounter();
let universe = new Universe();
let fleet = new Fleet();
let part = new MissionPartCleanLocation(new Mission(universe, fleet), destination);
2017-10-26 21:47:13 +00:00
check.equals(part.title, "Clean a planet in Atanax system");
check.same(part.checkCompleted(), false, "Init location");
2017-07-10 20:40:22 +00:00
2017-10-26 21:47:13 +00:00
check.equals(destination.isClear(), true);
2017-07-10 20:40:22 +00:00
part.onStarted();
2017-10-26 21:47:13 +00:00
check.equals(destination.isClear(), false);
2017-07-10 20:40:22 +00:00
fleet.setLocation(destination);
2017-10-26 21:47:13 +00:00
check.same(part.checkCompleted(), false, "Encounter not clear");
2017-07-10 20:40:22 +00:00
destination.clearEncounter();
2017-10-26 21:47:13 +00:00
check.same(part.checkCompleted(), true, "Encouter cleared");
2017-07-10 20:40:22 +00:00
})
2017-09-11 23:29:15 +00:00
2017-10-26 21:47:13 +00:00
test.case("generates the battle immediately if the fleet is already at the destination", check => {
2017-09-11 23:29:15 +00:00
let destination = new StarLocation(new Star(null, 0, 0, "Atanax"));
destination.clearEncounter();
let universe = new Universe();
let fleet = new Fleet();
fleet.setLocation(destination);
2017-09-11 23:29:15 +00:00
let part = new MissionPartCleanLocation(new Mission(universe, fleet), destination);
2017-10-26 21:47:13 +00:00
check.equals(fleet.battle, null);
2017-09-11 23:29:15 +00:00
part.onStarted();
2017-10-26 21:47:13 +00:00
check.notequals(fleet.battle, null);
check.equals(nn(fleet.battle).fleets, [fleet, nn(destination.encounter)]);
check.equals(part.checkCompleted(), false);
2017-09-11 23:29:15 +00:00
})
2017-07-10 20:40:22 +00:00
})
}