From a42e0e2d53231fb23635418ff2bebb80ca4ac4e8 Mon Sep 17 00:00:00 2001 From: Susan Yuen <susan_loves_cheese@hotmail.com> Date: Wed, 30 Nov 2016 00:38:44 -0500 Subject: [PATCH] Fixed bug in Game Over --- src/Blaze-Brigade/Blaze_Brigade/Game.cs | 4 ++-- src/Blaze-Brigade/Blaze_Brigade/GameFunction.cs | 17 +++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Blaze-Brigade/Blaze_Brigade/Game.cs b/src/Blaze-Brigade/Blaze_Brigade/Game.cs index ebbc503..4d06e77 100644 --- a/src/Blaze-Brigade/Blaze_Brigade/Game.cs +++ b/src/Blaze-Brigade/Blaze_Brigade/Game.cs @@ -306,7 +306,7 @@ namespace Controller GameFunction.removeUnit(graph, player1, unit); break; } - if (GameFunction.isGameOver(player1, player2)) + if (GameFunction.isGameOver()) { GameState.gameOver = true; break; @@ -321,7 +321,7 @@ namespace Controller GameFunction.removeUnit(graph, player2, unit); break; } - if (GameFunction.isGameOver(player1, player2)) + if (GameFunction.isGameOver()) { GameState.gameOver = true; break; diff --git a/src/Blaze-Brigade/Blaze_Brigade/GameFunction.cs b/src/Blaze-Brigade/Blaze_Brigade/GameFunction.cs index 297dae4..9e97fcd 100644 --- a/src/Blaze-Brigade/Blaze_Brigade/GameFunction.cs +++ b/src/Blaze-Brigade/Blaze_Brigade/GameFunction.cs @@ -68,7 +68,10 @@ namespace Controller GameState.attackConfirmOpen = false; GameState.beforeMove = true; - updateCamera(camera); + if (!isGameOver()) + { + updateCamera(camera); + } } /** @@ -111,22 +114,20 @@ namespace Controller /** Returns a boolean value indicating whether or not the game is over, based off win conditions. These conditions include whether or not one of the players in the game has any live units left. \n\n \b Exceptions: \n - - The function requires that the players passed through are valid player objects in the game and are non-null. - - The function assumes that the two players being passed through are both different objects. - \param player1 Player 1 of the current game. - \param player2 Player 2 of the current game. + - The function requires that Player1 and Player2 stored in GameState are non-null. + - The function assumes that the two players stored in GameState are both different objects. */ - public static bool isGameOver(Player player1, Player player2) + public static bool isGameOver() { // if player1 does not have anymore units, game is over - if (player1.getNumOfUnits() <= 0) + if (GameState.Player1.getNumOfUnits() <= 0) { GameState.winningPlayer = 2; return true; } // if player2 does not have anymore units, game is over - if (player2.getNumOfUnits() <= 0) + if (GameState.Player2.getNumOfUnits() <= 0) { GameState.winningPlayer = 1; return true; -- GitLab