diff --git a/TODO.md b/TODO.md index 9055f2e..fd066eb 100644 --- a/TODO.md +++ b/TODO.md @@ -7,6 +7,7 @@ Menu/settings/saves * Save locally first, make saving to cloud an option * Allow to delete cloud saves * Fix cloud save games with "Level 0 - 0 ships" +* Store the game version in saves (for future work on compatibility) Map/story --------- @@ -20,6 +21,7 @@ Map/story * Forbid to end up with more than 5 ships in the fleet because of escorts * Fix problems when several dialogs are active at the same time * Handle case where cargo is full to give a reward (give money?) +* Fix question mark not being cleared on no encounter Character sheet --------------- diff --git a/src/core/missions/MainStory.spec.ts b/src/core/missions/MainStory.spec.ts index 754f53a..9d4ebd4 100644 --- a/src/core/missions/MainStory.spec.ts +++ b/src/core/missions/MainStory.spec.ts @@ -42,6 +42,14 @@ module TS.SpaceTac.Specs { expect(fleet.ships.length).toBe(fleet_size + 1); goTo(fleet, (story.current_part).destination); + checkPart(story, 4, "^Listen to .*$"); + (story.current_part).skip(); + expect(session.getBattle()).toBeNull(); + + checkPart(story, 5, "^Fight the arrived fleet$"); + expect(session.getBattle()).not.toBeNull(); + nn(session.getBattle()).endBattle(fleet); + expect(story.checkStatus()).toBe(false, "story not complete"); }) }) diff --git a/src/core/missions/MainStory.ts b/src/core/missions/MainStory.ts index 427bbbc..7b0be9e 100644 --- a/src/core/missions/MainStory.ts +++ b/src/core/missions/MainStory.ts @@ -37,12 +37,28 @@ module TS.SpaceTac { conversation.addPiece(null, "So where do we go from here? In your last message, you told us of a resistance group growing."); conversation.addPiece(contact_character, "Yes, some merchants and miners have rallied behind a retired TSF general, but I lost contact with them weeks ago."); conversation.addPiece(contact_character, "We may go to their last known location, but first I want you to see something in a nearby system."); + conversation.addPiece(contact_character, "If you need any equipment before going, there is a dockyard in this system. They often offer some missions if you need money too."); + conversation.addPiece(null, "Yes, we came here with basic equipment as to not raise suspicion, but it looks like we will need more to defend ourselves."); conversation.addPiece(null, "Ok, let's go..."); // Go take a look at the graveyard let nearby_systems = nna(start_location.star.getLinks().map(link => link.getPeer(contact_location.star))); let graveyard_location = randomLocation(random, [minBy(nearby_systems, system => system.level)]); this.addPart(new MissionPartEscort(this, graveyard_location, contact_character, `Go with ${contact_character.name} in ${graveyard_location.star.name} system`)); + conversation = this.addPart(new MissionPartConversation(this, [contact_character], `Listen to ${contact_character.name}`)); + conversation.addPiece(null, "What is all this junk?"); + conversation.addPiece(contact_character, "This was until recently an unofficial ship scrap yard. Lots of abandoned ship carcasses were floating in here, and many smugglers used to camouflage their activities amongst those."); + conversation.addPiece(contact_character, "I don't know what happened of the ship relics themselves, they disappeared, but all you see left are their quantum matrix computers."); + conversation.addPiece(null, "This makes no sense, ship bodies have no value without their brains!"); + conversation.addPiece(contact_character, "Exactly. Someone went through a lot of work, but I do not see the reason why."); + conversation.addPiece(null, "Do you have any clue on where the ships were taken?"); + conversation.addPiece(contact_character, "From what I gathered from locals, they were taken far away, maybe to the other side of the galaxy."); + conversation.addPiece(null, "So many ship structures stripped and transported elsewhere is weird. You're right, it's a LOT of work. We definitely need to know what is going on with it."); + conversation.addPiece(null, "..."); + conversation.addPiece(null, "But it seems that we will have to deal with something else first! My high-spectrum sensors just picked an incoming fleet that will emerge near us."); + + // Fight with the patrol + this.addPart(new MissionPartCleanLocation(this, graveyard_location, "Fight the arrived fleet")); } } } diff --git a/src/core/missions/MissionPartCleanLocation.spec.ts b/src/core/missions/MissionPartCleanLocation.spec.ts index 358e003..a8dc877 100644 --- a/src/core/missions/MissionPartCleanLocation.spec.ts +++ b/src/core/missions/MissionPartCleanLocation.spec.ts @@ -21,5 +21,21 @@ module TS.SpaceTac.Specs { destination.clearEncounter(); expect(part.checkCompleted()).toBe(true, "Encouter cleared"); }) + + it("generates the battle immediately if the fleet is already at the destination", function () { + let destination = new StarLocation(new Star(null, 0, 0, "Atanax")); + destination.clearEncounter(); + + let universe = new Universe(); + let fleet = new Fleet(); + fleet.setLocation(destination, true); + let part = new MissionPartCleanLocation(new Mission(universe, fleet), destination); + + expect(fleet.battle).toBeNull(); + part.onStarted(); + expect(fleet.battle).not.toBeNull(); + expect(nn(fleet.battle).fleets).toEqual([fleet, nn(destination.encounter)]); + expect(part.checkCompleted()).toBe(false); + }) }) } diff --git a/src/core/missions/MissionPartCleanLocation.ts b/src/core/missions/MissionPartCleanLocation.ts index f86276b..02317a7 100644 --- a/src/core/missions/MissionPartCleanLocation.ts +++ b/src/core/missions/MissionPartCleanLocation.ts @@ -17,6 +17,14 @@ module TS.SpaceTac { onStarted(): void { this.destination.setupEncounter(); + + if (this.fleet.location == this.destination) { + // Already there, re-enter the location to start the fight + let battle = this.destination.enterLocation(this.fleet); + if (battle) { + this.fleet.setBattle(battle); + } + } } } } diff --git a/src/ui/intro/IntroView.ts b/src/ui/intro/IntroView.ts index 85a75db..9573054 100644 --- a/src/ui/intro/IntroView.ts +++ b/src/ui/intro/IntroView.ts @@ -17,6 +17,9 @@ module TS.SpaceTac.UI { // For now, we create a random fleet this.gameui.session.setCampaignFleet(); this.backToRouter(); + return false; + } else { + return true; } }; @@ -25,6 +28,10 @@ module TS.SpaceTac.UI { this.inputs.bind("Home", "Rewind", () => steps.rewind()); this.inputs.bind("Space", "Next step", nextStep); this.inputs.bind("Enter", "Next step", nextStep); + this.inputs.bind("Escape", "Skip all", () => { + while (nextStep()) { + } + }); this.gameui.audio.startMusic("division"); } diff --git a/src/ui/intro/ProgressiveMessage.ts b/src/ui/intro/ProgressiveMessage.ts index 410e0e3..8649246 100644 --- a/src/ui/intro/ProgressiveMessage.ts +++ b/src/ui/intro/ProgressiveMessage.ts @@ -52,8 +52,19 @@ module TS.SpaceTac.UI { } } - this.addText(offset + (style.center ? width / 2 : style.padding), style.center ? height / 2 : style.padding, message, + let text = this.addText(offset + (style.center ? width / 2 : style.padding), style.center ? height / 2 : style.padding, message, style.text_color, style.text_size, style.text_bold, style.center, width - style.padding * 2, style.center); + + let i = 0; + let colorchar = () => { + text.clearColors(); + if (i < message.length) { + text.addColor("transparent", i); + i++; + this.view.timer.schedule(10, colorchar); + } + } + colorchar(); } } } \ No newline at end of file diff --git a/src/ui/map/UniverseMapView.ts b/src/ui/map/UniverseMapView.ts index cc03b9a..eaf511d 100644 --- a/src/ui/map/UniverseMapView.ts +++ b/src/ui/map/UniverseMapView.ts @@ -163,9 +163,13 @@ module TS.SpaceTac.UI { * Refresh the view */ refresh() { - this.setZoom(this.zoom); - this.character_sheet.updateFleet(this.player.fleet); - this.player_fleet.updateShipSprites(); + if (this.player.getBattle()) { + this.backToRouter(); + } else { + this.setZoom(this.zoom); + this.character_sheet.updateFleet(this.player.fleet); + this.player_fleet.updateShipSprites(); + } } /**