2017-09-24 22:23:22 +00:00
|
|
|
module TK.SpaceTac.Specs {
|
2017-10-26 21:47:13 +00:00
|
|
|
testing("MainStory", test => {
|
2017-10-29 21:08:55 +00:00
|
|
|
function checkPart(story: Mission, index: number, title: RegExp, completed = false) {
|
2017-07-02 18:21:04 +00:00
|
|
|
let result = story.checkStatus();
|
2017-11-14 00:07:06 +00:00
|
|
|
test.check.in(`part ${index}`, check => {
|
|
|
|
check.same(story.parts.indexOf(story.current_part), index);
|
|
|
|
check.regex(title, story.current_part.title);
|
|
|
|
check.same(story.completed, completed);
|
|
|
|
check.same(result, !completed);
|
|
|
|
});
|
2017-06-27 15:42:28 +00:00
|
|
|
}
|
|
|
|
|
2018-01-16 00:08:24 +00:00
|
|
|
function goTo(session: GameSession, location: StarLocation, win_encounter = true) {
|
|
|
|
session.fleet.setLocation(location);
|
|
|
|
|
|
|
|
let battle = session.getBattle();
|
|
|
|
if (battle) {
|
|
|
|
battle.endBattle(win_encounter ? session.fleet : battle.fleets[1]);
|
2017-06-27 15:42:28 +00:00
|
|
|
if (win_encounter) {
|
2018-01-16 00:08:24 +00:00
|
|
|
session.exitBattle();
|
2017-11-14 00:07:06 +00:00
|
|
|
location.clearEncounter();
|
2017-06-27 15:42:28 +00:00
|
|
|
} else {
|
2018-01-16 00:08:24 +00:00
|
|
|
session.revertBattle();
|
2017-06-27 15:42:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-10-29 21:08:55 +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
|
|
|
|
2017-10-29 21:08:55 +00:00
|
|
|
checkPart(story, 1, /^Find your contact in .*$/);
|
2018-01-16 00:08:24 +00:00
|
|
|
goTo(session, (<MissionPartGoTo>story.current_part).destination);
|
2017-06-29 17:25:38 +00:00
|
|
|
|
2017-10-29 21:08:55 +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
|
|
|
|
2017-10-29 21:08:55 +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-12-12 22:17:25 +00:00
|
|
|
check.same(fleet.ships[fleet_size].critical, true);
|
|
|
|
check.greater(fleet.ships[fleet_size].getAttribute("hull_capacity"), 0);
|
2018-01-16 00:08:24 +00:00
|
|
|
goTo(session, (<MissionPartEscort>story.current_part).destination);
|
2017-07-02 18:21:04 +00:00
|
|
|
|
2017-10-29 21:08:55 +00:00
|
|
|
checkPart(story, 4, /^Listen to .*$/);
|
2017-09-11 23:29:15 +00:00
|
|
|
(<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
|
|
|
|
2017-10-29 21:08:55 +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-11-14 00:07:06 +00:00
|
|
|
session.setBattleEnded();
|
2017-09-11 23:29:15 +00:00
|
|
|
|
2017-10-26 21:47:13 +00:00
|
|
|
check.same(story.checkStatus(), false, "story not complete");
|
2017-06-27 15:42:28 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|