refactored Game.getRandomDirection() to Direction.getRandom()
This commit is contained in:
parent
5db401d2ab
commit
4aa307a254
@ -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)];
|
||||
}
|
||||
}
|
||||
|
@ -41,9 +41,9 @@ public class Game {
|
||||
Stargate.init();
|
||||
|
||||
Map<String, Tile> 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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user