1
0
Fork 0

Added small conversations to generated missions

This commit is contained in:
Michaël Lemaire 2017-07-16 20:25:36 +02:00
parent 81f7174b58
commit 5d83cb8f1e
3 changed files with 58 additions and 12 deletions

View file

@ -12,11 +12,13 @@ module TS.SpaceTac.Specs {
let mission = generator.generateEscort(); let mission = generator.generateEscort();
expect(mission.title).toBe("Escort a ship to a level 2 system"); expect(mission.title).toBe("Escort a ship to a level 2 system");
expect(mission.parts.length).toBe(1); expect(mission.parts.length).toBe(3);
expect(mission.parts[0] instanceof MissionPartEscort).toBe(true); expect(mission.parts[0] instanceof MissionPartConversation).toBe(true);
let escort = <MissionPartEscort>mission.parts[0]; expect(mission.parts[1] instanceof MissionPartEscort).toBe(true);
let escort = <MissionPartEscort>mission.parts[1];
expect(escort.destination).toBe(loc2); expect(escort.destination).toBe(loc2);
expect(escort.ship.level.get()).toBe(2); expect(escort.ship.level.get()).toBe(2);
expect(mission.parts[2] instanceof MissionPartConversation).toBe(true);
}) })
it("generates location cleaning missions", function () { it("generates location cleaning missions", function () {
@ -29,15 +31,17 @@ module TS.SpaceTac.Specs {
let mission = generator.generateCleanLocation(); let mission = generator.generateCleanLocation();
expect(mission.title).toBe("Defeat a level 1 fleet in this system"); expect(mission.title).toBe("Defeat a level 1 fleet in this system");
expect(mission.parts.length).toBe(2); expect(mission.parts.length).toBe(4);
expect(mission.parts[0] instanceof MissionPartCleanLocation).toBe(true); expect(mission.parts[0] instanceof MissionPartConversation).toBe(true);
let part1 = <MissionPartCleanLocation>mission.parts[0]; expect(mission.parts[1] instanceof MissionPartCleanLocation).toBe(true);
let part1 = <MissionPartCleanLocation>mission.parts[1];
expect(part1.destination).toBe(loc2); expect(part1.destination).toBe(loc2);
expect(part1.title).toEqual("Clean a planet in TTX system"); expect(part1.title).toEqual("Clean a planet in TTX system");
expect(mission.parts[0] instanceof MissionPartGoTo).toBe(true); expect(mission.parts[2] instanceof MissionPartGoTo).toBe(true);
let part2 = <MissionPartGoTo>mission.parts[1]; let part2 = <MissionPartGoTo>mission.parts[2];
expect(part2.destination).toBe(loc1); expect(part2.destination).toBe(loc1);
expect(part2.title).toEqual("Go back to collect your reward"); expect(part2.title).toEqual("Go back to collect your reward");
expect(mission.parts[3] instanceof MissionPartConversation).toBe(true);
}) })
it("helps to evaluate mission difficulty", function () { it("helps to evaluate mission difficulty", function () {

View file

@ -117,12 +117,32 @@ module TS.SpaceTac {
*/ */
generateEscort(): Mission { generateEscort(): Mission {
let mission = new Mission(this.universe); let mission = new Mission(this.universe);
let dest_star = this.random.choice(this.around.star.getNeighbors()); let dest_star = this.random.choice(this.around.star.getNeighbors());
let destination = this.random.choice(dest_star.locations); let destination = this.random.choice(dest_star.locations);
let ship = this.generateShip(dest_star.level); let ship = this.generateShip(dest_star.level);
mission.addPart(new MissionPartEscort(mission, destination, ship));
mission.title = `Escort a ship to a level ${dest_star.level} system`; mission.title = `Escort a ship to a level ${dest_star.level} system`;
this.setDifficulty(mission, 1000, dest_star.level); this.setDifficulty(mission, 1000, dest_star.level);
let conversation = new MissionPartConversation(mission, [ship]);
conversation.addPiece(ship, this.random.choice([
"I'm very grateful you accepted to escort me! These systems are not safe to travel anymore.",
"Thank you for bringing me along, I'm afraid not to be up to the dangers ahead.",
"Always a pleasure to travel with battle-ready companions, it is not a triviality these days!",
]));
mission.addPart(conversation);
mission.addPart(new MissionPartEscort(mission, destination, ship));
conversation = new MissionPartConversation(mission, [ship]);
conversation.addPiece(ship, this.random.choice([
"Thank you! Have your reward, you deserved it.",
"Never could have made it safely without your help, take this as a token of my gratitude.",
"Thanks so much... May we meet again in the future. For now, please accept this small reward.",
]));
mission.addPart(conversation);
return mission; return mission;
} }
@ -131,6 +151,7 @@ module TS.SpaceTac {
*/ */
generateCleanLocation(): Mission { generateCleanLocation(): Mission {
let mission = new Mission(this.universe); let mission = new Mission(this.universe);
let dest_star = this.random.choice(this.around.star.getNeighbors().concat([this.around.star])); let dest_star = this.random.choice(this.around.star.getNeighbors().concat([this.around.star]));
let here = (dest_star == this.around.star); let here = (dest_star == this.around.star);
let choices = dest_star.locations; let choices = dest_star.locations;
@ -138,10 +159,31 @@ module TS.SpaceTac {
choices = choices.filter(loc => loc != this.around); choices = choices.filter(loc => loc != this.around);
} }
let destination = this.random.choice(choices); let destination = this.random.choice(choices);
mission.addPart(new MissionPartCleanLocation(mission, destination)); let ship = this.generateShip(1);
mission.addPart(new MissionPartGoTo(mission, this.around, "Go back to collect your reward"));
mission.title = `Defeat a level ${destination.star.level} fleet in ${here ? "this" : "a nearby"} system`; mission.title = `Defeat a level ${destination.star.level} fleet in ${here ? "this" : "a nearby"} system`;
this.setDifficulty(mission, here ? 300 : 500, dest_star.level); this.setDifficulty(mission, here ? 300 : 500, dest_star.level);
let conversation = new MissionPartConversation(mission, [ship]);
conversation.addPiece(ship, this.random.choice([
`We need you to clean a ${capitalize(StarLocationType[destination.type].toLowerCase())} for us. It is of vital importance.`,
"It would be very kind of you to remove these pesky rogues from the location we pointed on your map. Have no mercy!",
"One of those uninvited fleets is blocking a strategic point for our supplies. Send them back to hell.",
]));
mission.addPart(conversation);
mission.addPart(new MissionPartCleanLocation(mission, destination));
mission.addPart(new MissionPartGoTo(mission, this.around, "Go back to collect your reward"));
conversation = new MissionPartConversation(mission, [ship]);
conversation.addPiece(ship, this.random.choice([
"You really are efficient! Feel free to have a look at our other jobs, while we load your reward.",
"We know it will be a temporary respite, but thank you nonetheless.",
"A job well done, is a job well paid! Looking forward to working with you again.",
]));
mission.addPart(conversation);
return mission; return mission;
} }
} }

View file

@ -47,7 +47,7 @@ module TS.SpaceTac.UI {
proposed.forEach(mission => { proposed.forEach(mission => {
this.addMission(offset, mission, 2, () => { this.addMission(offset, mission, 2, () => {
this.shop.acceptMission(mission, this.player); this.shop.acceptMission(mission, this.player);
this.refresh(); this.close();
this.on_change(); this.on_change();
}); });
offset += 110; offset += 110;