From 33970098509b4f9d3897e5438185ae8c860c7bdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Sun, 5 Feb 2017 23:03:35 +0100 Subject: [PATCH] Fixed going back to menu after quick battle --- TODO | 3 +++ src/game/GameSession.ts | 7 +++++++ src/view/BaseView.ts | 10 ++++++++++ src/view/Router.ts | 7 +++++-- src/view/battle/BattleView.ts | 4 ---- 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/TODO b/TODO index c9ee7ee..c637a8d 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,4 @@ +* Add drones to apply temporary zone effects * Allow to cancel last moves * Effect should be random in a range (eg. "damage target 50-75") * Add an overload/cooling system @@ -14,3 +15,5 @@ * Add a defeat screen (game over for now) * Add a victory screen, with loot display * Add retreat from battle +* Map : restore ability to jump to other systems +* Map : add stores diff --git a/src/game/GameSession.ts b/src/game/GameSession.ts index 9fc2cfa..0dc9ab0 100644 --- a/src/game/GameSession.ts +++ b/src/game/GameSession.ts @@ -55,5 +55,12 @@ module TS.SpaceTac.Game { getBattle(): Battle { return this.player.getBattle(); } + + /** + * Return true if the session has a universe to explore + */ + hasUniverse(): boolean { + return this.universe.stars.length > 0; + } } } diff --git a/src/view/BaseView.ts b/src/view/BaseView.ts index ef82563..ed8ea2d 100644 --- a/src/view/BaseView.ts +++ b/src/view/BaseView.ts @@ -36,6 +36,16 @@ module TS.SpaceTac.View { // Input manager this.inputs = new InputManager(this); + + // Browser console variable (for debugging purpose) + if (typeof window != "undefined") { + let session = this.gameui.session; + if (session) { + (window).universe = session.universe; + (window).player = session.player; + (window).battle = session.player.getBattle(); + } + } } } } diff --git a/src/view/Router.ts b/src/view/Router.ts index 6629441..0d567b7 100644 --- a/src/view/Router.ts +++ b/src/view/Router.ts @@ -6,7 +6,7 @@ module TS.SpaceTac.View { var session = ui.session; if (!session) { - // No universe, go back to main menu + // No session, go back to main menu this.game.state.start("mainmenu", true, false); } else if (session.getBattle()) { // A battle is raging, go to it @@ -14,9 +14,12 @@ module TS.SpaceTac.View { } else if (ui.getFocusedStar()) { // Go to the focused star system this.game.state.start("starsystem", true, false, ui.star, session.player); - } else { + } else if (session.hasUniverse()) { // Go to the universe map this.game.state.start("universe", true, false, session.universe, session.player); + } else { + // No battle, no universe, go back to menu + this.game.state.start("mainmenu", true, false); } } } diff --git a/src/view/battle/BattleView.ts b/src/view/battle/BattleView.ts index 5aa8176..a11af03 100644 --- a/src/view/battle/BattleView.ts +++ b/src/view/battle/BattleView.ts @@ -53,10 +53,6 @@ module TS.SpaceTac.View { this.ship_hovered = null; this.log_processor = null; this.background = null; - - if (typeof window != "undefined") { - (window).battle = this.battle; - } } // Create view graphics