diff --git a/cicaprojekt/Game.java b/cicaprojekt/Game.java index ae76fe2..8e8004d 100644 --- a/cicaprojekt/Game.java +++ b/cicaprojekt/Game.java @@ -50,6 +50,10 @@ public class Game { public void playerDestroyed(Player caller) { dungeon.setZPMsToWin(dungeon.getZPMsToWin() - caller.getZPMCount()); Game.instance.updateDisplay(); + if (jaffa.isDestroyed() && oneill.isDestroyed()) { + flowoftime.stopTime(); + stopGame(GameoverCause.ANUBIS); + } } public void setDungeon(Dungeon dungeon) { @@ -107,6 +111,15 @@ public class Game { "Game over", JOptionPane.INFORMATION_MESSAGE, 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(); @@ -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()) + if (oneill.getZPMCount() > jaffa.getZPMCount()) { + flowoftime.stopTime(); stopGame(GameoverCause.ONEILLWON); - else if (oneill.getZPMCount() < jaffa.getZPMCount()) + } + else if (oneill.getZPMCount() < jaffa.getZPMCount()) { + flowoftime.stopTime(); stopGame(GameoverCause.JAFFAWON); - else + } + else { + flowoftime.stopTime(); stopGame(GameoverCause.DRAW); + } return; } diff --git a/cicaprojekt/GameoverCause.java b/cicaprojekt/GameoverCause.java index 766921d..4a6ac00 100644 --- a/cicaprojekt/GameoverCause.java +++ b/cicaprojekt/GameoverCause.java @@ -1,5 +1,5 @@ package cicaprojekt; public enum GameoverCause { - TIMEOUT, ONEILLWON, JAFFAWON, DRAW + TIMEOUT, ONEILLWON, JAFFAWON, DRAW, ANUBIS } diff --git a/cicaprojekt/Player.java b/cicaprojekt/Player.java index e6e5d86..e0ff2f9 100644 --- a/cicaprojekt/Player.java +++ b/cicaprojekt/Player.java @@ -13,6 +13,7 @@ public class Player extends PlayerBase { if(hasBox()) boxLifted.destroy(); Game.instance.playerDestroyed(this); + zpmContainer.clear(); } public Player(String name, Tile startTile, Direction startDirection) {