diff --git a/cicaprojekt/FlowOfTime.java b/cicaprojekt/FlowOfTime.java index 79427e7..6a6bb06 100644 --- a/cicaprojekt/FlowOfTime.java +++ b/cicaprojekt/FlowOfTime.java @@ -18,4 +18,9 @@ public class FlowOfTime extends Timer { public void start(long delay) { schedule(new GameOver(), delay); } + + public void stopTime() { + cancel(); + purge(); + } } diff --git a/cicaprojekt/Game.java b/cicaprojekt/Game.java index 503485a..b77754a 100644 --- a/cicaprojekt/Game.java +++ b/cicaprojekt/Game.java @@ -84,10 +84,12 @@ public class Game { public void moveONeill(Direction direction) { oneill.move(direction); + checkZPMStatus(); } public void moveJaffa(Direction direction) { jaffa.move(direction); + checkZPMStatus(); } public void rotateOneillLeft() { @@ -136,4 +138,18 @@ public class Game { Control.ioErrorMessage(); } } + + private void checkZPMStatus() + { + if (oneill.getZPMCount() >= dungeon.getZPMsToWin()) + { + flowoftime.stopTime(); + stopGame(GameoverCause.ONEILLWON); + } + else if (jaffa.getZPMCount() >= dungeon.getZPMsToWin()) + { + flowoftime.stopTime(); + stopGame(GameoverCause.JAFFAWON); + } + } } diff --git a/exampledungeon.dungeon b/exampledungeon.dungeon index a3cfe47..e12c9be 100644 --- a/exampledungeon.dungeon +++ b/exampledungeon.dungeon @@ -1,5 +1,5 @@ 5x5 -10 +100 W W W W W W O B S W diff --git a/mastertest.dungeon b/mastertest.dungeon index 03c69f0..81f2c28 100644 --- a/mastertest.dungeon +++ b/mastertest.dungeon @@ -1,9 +1,9 @@ 5x5 -5 +150 W W W W W W F F F W W F O F W -W F F F W +W F F Z W W W W W W