now ending outcomes of the game work purrfectly

This commit is contained in:
Kjistóf 2016-05-13 20:54:44 +02:00
parent cb99f84ded
commit 1a2d0fdfeb
4 changed files with 24 additions and 3 deletions

View File

@ -18,4 +18,9 @@ public class FlowOfTime extends Timer {
public void start(long delay) { public void start(long delay) {
schedule(new GameOver(), delay); schedule(new GameOver(), delay);
} }
public void stopTime() {
cancel();
purge();
}
} }

View File

@ -84,10 +84,12 @@ public class Game {
public void moveONeill(Direction direction) { public void moveONeill(Direction direction) {
oneill.move(direction); oneill.move(direction);
checkZPMStatus();
} }
public void moveJaffa(Direction direction) { public void moveJaffa(Direction direction) {
jaffa.move(direction); jaffa.move(direction);
checkZPMStatus();
} }
public void rotateOneillLeft() { public void rotateOneillLeft() {
@ -136,4 +138,18 @@ public class Game {
Control.ioErrorMessage(); 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);
}
}
} }

View File

@ -1,5 +1,5 @@
5x5 5x5
10 100
W W W W W W W W W W
W O B S W W O B S W

View File

@ -1,9 +1,9 @@
5x5 5x5
5 150
W W W W W W W W W W
W F F F W W F F F W
W F O F W W F O F W
W F F F W W F F Z W
W W W W W W W W W W