diff --git a/cicaprojekt/Direction.java b/cicaprojekt/Direction.java index 5b0e96f..c0bdc8e 100644 --- a/cicaprojekt/Direction.java +++ b/cicaprojekt/Direction.java @@ -1,5 +1,7 @@ package cicaprojekt; +import java.util.Random; + public enum Direction { NORTH, SOUTH, EAST, WEST; @@ -17,4 +19,8 @@ public enum Direction { return NORTH; } } + + public static Direction getRandom() { + return Direction.values()[new Random().nextInt(Direction.values().length)]; + } } diff --git a/cicaprojekt/Game.java b/cicaprojekt/Game.java index a011dfb..63043eb 100644 --- a/cicaprojekt/Game.java +++ b/cicaprojekt/Game.java @@ -41,9 +41,9 @@ public class Game { Stargate.init(); Map players = dungeon.buildDungeon(dungeonFile, display); - oneill = new Player("O'Neill", players.get("oneill"), getRandomDirection()); - jaffa = new Player("Jaffa", players.get("jaffa"), getRandomDirection()); - replicator = new PlayerBase("Replicator", players.get("replicator"), getRandomDirection()); + oneill = new Player("O'Neill", players.get("oneill"), Direction.getRandom()); + jaffa = new Player("Jaffa", players.get("jaffa"), Direction.getRandom()); + replicator = new PlayerBase("Replicator", players.get("replicator"), Direction.getRandom()); display.addVisual(new PlayerDrawer(oneill)); display.addVisual(new PlayerDrawer(jaffa)); @@ -53,10 +53,6 @@ public class Game { flowoftime.start(dungeon.getTimeLimit()); } - private Direction getRandomDirection() { - return Direction.values()[random.nextInt(Direction.values().length)]; - } - public void stopGame(GameoverCause cause) { switch (cause){ @@ -92,6 +88,10 @@ public class Game { checkZPMStatus(); } + public void moveReplicator(Direction direction) { + replicator.move(direction); + } + public void rotateOneillLeft() { oneill.rotateLeft(); }