1
0
Fork 0
spacetac/src/core/missions/MissionPartGoTo.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("MissionPartGoTo", test => {
test.case("completes when the fleet is at location, without encounter", check => {
let destination = new StarLocation(new Star(null, 0, 0, "Atanax"));
destination.encounter_random = new SkewedRandomGenerator([0], true);
let universe = new Universe();
let fleet = new Fleet();
2017-07-02 18:21:04 +00:00
let part = new MissionPartGoTo(new Mission(universe, fleet), destination);
2017-10-26 21:47:13 +00:00
check.equals(part.title, "Go to Atanax system");
check.same(part.checkCompleted(), false, "Init location");
fleet.setLocation(destination);
2017-10-26 21:47:13 +00:00
check.same(part.checkCompleted(), false, "Encounter not clear");
destination.clearEncounter();
2017-10-26 21:47:13 +00:00
check.same(part.checkCompleted(), true, "Encouter cleared");
fleet.setLocation(new StarLocation());
2017-10-26 21:47:13 +00:00
check.same(part.checkCompleted(), false, "Went to another system");
fleet.setLocation(destination);
2017-10-26 21:47:13 +00:00
check.same(part.checkCompleted(), true, "Back at destination");
})
2017-06-29 17:25:38 +00:00
2017-10-26 21:47:13 +00:00
test.case("force completes", check => {
2017-06-29 17:25:38 +00:00
let destination = new StarLocation(new Star(null, 0, 0, "Atanax"));
destination.encounter_random = new SkewedRandomGenerator([0], true);
let universe = new Universe();
let fleet = new Fleet();
let part = new MissionPartGoTo(new Mission(universe, fleet), destination, "Investigate");
2017-10-26 21:47:13 +00:00
check.equals(part.title, "Investigate");
check.equals(part.checkCompleted(), false);
2017-06-29 17:25:38 +00:00
part.forceComplete();
2017-10-26 21:47:13 +00:00
check.equals(part.checkCompleted(), true);
2017-06-29 17:25:38 +00:00
});
})
}