Skip to content
Snippets Groups Projects
Commit a42e0e2d authored by Susan Yuen's avatar Susan Yuen
Browse files

Fixed bug in Game Over

parent ab311e90
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment