diff --git a/src/core/missions/MissionGenerator.spec.ts b/src/core/missions/MissionGenerator.spec.ts index 378cca6..935474c 100644 --- a/src/core/missions/MissionGenerator.spec.ts +++ b/src/core/missions/MissionGenerator.spec.ts @@ -12,11 +12,13 @@ module TS.SpaceTac.Specs { let mission = generator.generateEscort(); expect(mission.title).toBe("Escort a ship to a level 2 system"); - expect(mission.parts.length).toBe(1); - expect(mission.parts[0] instanceof MissionPartEscort).toBe(true); - let escort = mission.parts[0]; + expect(mission.parts.length).toBe(3); + expect(mission.parts[0] instanceof MissionPartConversation).toBe(true); + expect(mission.parts[1] instanceof MissionPartEscort).toBe(true); + let escort = mission.parts[1]; expect(escort.destination).toBe(loc2); expect(escort.ship.level.get()).toBe(2); + expect(mission.parts[2] instanceof MissionPartConversation).toBe(true); }) it("generates location cleaning missions", function () { @@ -29,15 +31,17 @@ module TS.SpaceTac.Specs { let mission = generator.generateCleanLocation(); expect(mission.title).toBe("Defeat a level 1 fleet in this system"); - expect(mission.parts.length).toBe(2); - expect(mission.parts[0] instanceof MissionPartCleanLocation).toBe(true); - let part1 = mission.parts[0]; + expect(mission.parts.length).toBe(4); + expect(mission.parts[0] instanceof MissionPartConversation).toBe(true); + expect(mission.parts[1] instanceof MissionPartCleanLocation).toBe(true); + let part1 = mission.parts[1]; expect(part1.destination).toBe(loc2); expect(part1.title).toEqual("Clean a planet in TTX system"); - expect(mission.parts[0] instanceof MissionPartGoTo).toBe(true); - let part2 = mission.parts[1]; + expect(mission.parts[2] instanceof MissionPartGoTo).toBe(true); + let part2 = mission.parts[2]; expect(part2.destination).toBe(loc1); 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 () { diff --git a/src/core/missions/MissionGenerator.ts b/src/core/missions/MissionGenerator.ts index f557f37..144c3c9 100644 --- a/src/core/missions/MissionGenerator.ts +++ b/src/core/missions/MissionGenerator.ts @@ -117,12 +117,32 @@ module TS.SpaceTac { */ generateEscort(): Mission { let mission = new Mission(this.universe); + let dest_star = this.random.choice(this.around.star.getNeighbors()); let destination = this.random.choice(dest_star.locations); 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`; 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; } @@ -131,6 +151,7 @@ module TS.SpaceTac { */ generateCleanLocation(): Mission { let mission = new Mission(this.universe); + let dest_star = this.random.choice(this.around.star.getNeighbors().concat([this.around.star])); let here = (dest_star == this.around.star); let choices = dest_star.locations; @@ -138,10 +159,31 @@ module TS.SpaceTac { choices = choices.filter(loc => loc != this.around); } let destination = this.random.choice(choices); - mission.addPart(new MissionPartCleanLocation(mission, destination)); - mission.addPart(new MissionPartGoTo(mission, this.around, "Go back to collect your reward")); + let ship = this.generateShip(1); + mission.title = `Defeat a level ${destination.star.level} fleet in ${here ? "this" : "a nearby"} system`; 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; } } diff --git a/src/ui/map/MissionsDialog.ts b/src/ui/map/MissionsDialog.ts index cbfb2b3..b6783d9 100644 --- a/src/ui/map/MissionsDialog.ts +++ b/src/ui/map/MissionsDialog.ts @@ -47,7 +47,7 @@ module TS.SpaceTac.UI { proposed.forEach(mission => { this.addMission(offset, mission, 2, () => { this.shop.acceptMission(mission, this.player); - this.refresh(); + this.close(); this.on_change(); }); offset += 110;