fixed everything related to the end of the game

This commit is contained in:
Kjistóf 2016-05-15 00:02:29 +02:00
parent 15d964468c
commit 4054d4a728
3 changed files with 25 additions and 6 deletions

View File

@ -50,6 +50,10 @@ public class Game {
public void playerDestroyed(Player caller) { public void playerDestroyed(Player caller) {
dungeon.setZPMsToWin(dungeon.getZPMsToWin() - caller.getZPMCount()); dungeon.setZPMsToWin(dungeon.getZPMsToWin() - caller.getZPMCount());
Game.instance.updateDisplay(); Game.instance.updateDisplay();
if (jaffa.isDestroyed() && oneill.isDestroyed()) {
flowoftime.stopTime();
stopGame(GameoverCause.ANUBIS);
}
} }
public void setDungeon(Dungeon dungeon) { public void setDungeon(Dungeon dungeon) {
@ -107,6 +111,15 @@ public class Game {
"Game over", "Game over",
JOptionPane.INFORMATION_MESSAGE, JOptionPane.INFORMATION_MESSAGE,
new ImageIcon("Anubis.png")); new ImageIcon("Anubis.png"));
Application.frameInstance.backToMapSelection();
break;
case ANUBIS:
JOptionPane.showMessageDialog(null, "There is no one left to stop Anubis from enslaving the world",
"Game over",
JOptionPane.INFORMATION_MESSAGE,
new ImageIcon("Anubis.png"));
Application.frameInstance.backToMapSelection();
break;
} }
display.stopMusic(); display.stopMusic();
@ -173,15 +186,20 @@ public class Game {
} }
} }
private void checkZPMStatus() private void checkZPMStatus() {
{
if (oneill.getZPMCount() + jaffa.getZPMCount() >= dungeon.getZPMsToWin()) { if (oneill.getZPMCount() + jaffa.getZPMCount() >= dungeon.getZPMsToWin()) {
if (oneill.getZPMCount() > jaffa.getZPMCount()) if (oneill.getZPMCount() > jaffa.getZPMCount()) {
flowoftime.stopTime();
stopGame(GameoverCause.ONEILLWON); stopGame(GameoverCause.ONEILLWON);
else if (oneill.getZPMCount() < jaffa.getZPMCount()) }
else if (oneill.getZPMCount() < jaffa.getZPMCount()) {
flowoftime.stopTime();
stopGame(GameoverCause.JAFFAWON); stopGame(GameoverCause.JAFFAWON);
else }
else {
flowoftime.stopTime();
stopGame(GameoverCause.DRAW); stopGame(GameoverCause.DRAW);
}
return; return;
} }

View File

@ -1,5 +1,5 @@
package cicaprojekt; package cicaprojekt;
public enum GameoverCause { public enum GameoverCause {
TIMEOUT, ONEILLWON, JAFFAWON, DRAW TIMEOUT, ONEILLWON, JAFFAWON, DRAW, ANUBIS
} }

View File

@ -13,6 +13,7 @@ public class Player extends PlayerBase {
if(hasBox()) if(hasBox())
boxLifted.destroy(); boxLifted.destroy();
Game.instance.playerDestroyed(this); Game.instance.playerDestroyed(this);
zpmContainer.clear();
} }
public Player(String name, Tile startTile, Direction startDirection) { public Player(String name, Tile startTile, Direction startDirection) {