2017-09-24 22:23:22 +00:00
|
|
|
module TK.SpaceTac.Specs {
|
2017-10-26 21:47:13 +00:00
|
|
|
testing("MainStory", test => {
|
2017-07-02 18:21:04 +00:00
|
|
|
function checkPart(story: Mission, index: number, title: string, completed = false) {
|
|
|
|
let result = story.checkStatus();
|
2017-10-26 21:47:13 +00:00
|
|
|
test.check.same(story.parts.indexOf(story.current_part), index);
|
2017-06-27 15:42:28 +00:00
|
|
|
expect(story.current_part.title).toMatch(title);
|
2017-10-26 21:47:13 +00:00
|
|
|
test.check.same(story.completed, completed);
|
|
|
|
test.check.same(result, !completed);
|
2017-06-27 15:42:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function goTo(fleet: Fleet, location: StarLocation, win_encounter = true) {
|
|
|
|
fleet.setLocation(location, true);
|
|
|
|
if (fleet.battle) {
|
|
|
|
fleet.battle.endBattle(win_encounter ? fleet : fleet.battle.fleets[1]);
|
|
|
|
if (win_encounter) {
|
|
|
|
fleet.player.exitBattle();
|
|
|
|
} else {
|
|
|
|
fleet.player.revertBattle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-26 21:47:13 +00:00
|
|
|
test.case("can be completed", check => {
|
2017-06-27 15:42:28 +00:00
|
|
|
let session = new GameSession();
|
|
|
|
session.startNewGame(true, true);
|
|
|
|
let fleet = nn(session.player.fleet);
|
|
|
|
|
|
|
|
let missions = session.player.missions;
|
|
|
|
let story = nn(missions.main);
|
2017-07-02 18:21:04 +00:00
|
|
|
let fleet_size = fleet.ships.length;
|
2017-06-27 15:42:28 +00:00
|
|
|
|
2017-07-02 18:21:04 +00:00
|
|
|
checkPart(story, 0, "^Travel to Terranax galaxy$");
|
2017-07-06 22:55:29 +00:00
|
|
|
(<MissionPartConversation>story.current_part).skip();
|
2017-07-02 18:21:04 +00:00
|
|
|
|
|
|
|
checkPart(story, 1, "^Find your contact in .*$");
|
2017-06-27 15:42:28 +00:00
|
|
|
goTo(fleet, (<MissionPartGoTo>story.current_part).destination);
|
2017-06-29 17:25:38 +00:00
|
|
|
|
2017-07-02 18:21:04 +00:00
|
|
|
checkPart(story, 2, "^Speak with your contact");
|
2017-07-06 22:55:29 +00:00
|
|
|
(<MissionPartConversation>story.current_part).skip();
|
2017-07-02 18:21:04 +00:00
|
|
|
|
|
|
|
checkPart(story, 3, "^Go with .* in .* system$");
|
2017-10-26 21:47:13 +00:00
|
|
|
check.same(fleet.ships.length, fleet_size + 1);
|
2017-07-02 18:21:04 +00:00
|
|
|
goTo(fleet, (<MissionPartEscort>story.current_part).destination);
|
|
|
|
|
2017-09-11 23:29:15 +00:00
|
|
|
checkPart(story, 4, "^Listen to .*$");
|
|
|
|
(<MissionPartConversation>story.current_part).skip();
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(session.getBattle(), null);
|
2017-09-11 23:29:15 +00:00
|
|
|
|
|
|
|
checkPart(story, 5, "^Fight the arrived fleet$");
|
2017-10-26 21:47:13 +00:00
|
|
|
check.notequals(session.getBattle(), null);
|
2017-09-11 23:29:15 +00:00
|
|
|
nn(session.getBattle()).endBattle(fleet);
|
|
|
|
|
2017-10-26 21:47:13 +00:00
|
|
|
check.same(story.checkStatus(), false, "story not complete");
|
2017-06-27 15:42:28 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|