refactored Game.getRandomDirection() to Direction.getRandom()
This commit is contained in:
		@@ -1,5 +1,7 @@
 | 
				
			|||||||
package cicaprojekt;
 | 
					package cicaprojekt;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.Random;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public enum Direction {
 | 
					public enum Direction {
 | 
				
			||||||
    NORTH, SOUTH, EAST, WEST;
 | 
					    NORTH, SOUTH, EAST, WEST;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -17,4 +19,8 @@ public enum Direction {
 | 
				
			|||||||
                return NORTH;
 | 
					                return NORTH;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static Direction getRandom() {
 | 
				
			||||||
 | 
					        return Direction.values()[new Random().nextInt(Direction.values().length)];
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -41,9 +41,9 @@ public class Game {
 | 
				
			|||||||
        Stargate.init();
 | 
					        Stargate.init();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Map<String, Tile> players = dungeon.buildDungeon(dungeonFile, display);
 | 
					        Map<String, Tile> players = dungeon.buildDungeon(dungeonFile, display);
 | 
				
			||||||
        oneill = new Player("O'Neill", players.get("oneill"), getRandomDirection());
 | 
					        oneill = new Player("O'Neill", players.get("oneill"), Direction.getRandom());
 | 
				
			||||||
        jaffa = new Player("Jaffa", players.get("jaffa"), getRandomDirection());
 | 
					        jaffa = new Player("Jaffa", players.get("jaffa"), Direction.getRandom());
 | 
				
			||||||
        replicator = new PlayerBase("Replicator", players.get("replicator"), getRandomDirection());
 | 
					        replicator = new PlayerBase("Replicator", players.get("replicator"), Direction.getRandom());
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        display.addVisual(new PlayerDrawer(oneill));
 | 
					        display.addVisual(new PlayerDrawer(oneill));
 | 
				
			||||||
        display.addVisual(new PlayerDrawer(jaffa));
 | 
					        display.addVisual(new PlayerDrawer(jaffa));
 | 
				
			||||||
@@ -53,10 +53,6 @@ public class Game {
 | 
				
			|||||||
        flowoftime.start(dungeon.getTimeLimit());
 | 
					        flowoftime.start(dungeon.getTimeLimit());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private Direction getRandomDirection() {
 | 
					 | 
				
			||||||
        return Direction.values()[random.nextInt(Direction.values().length)];
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public void stopGame(GameoverCause cause) {
 | 
					    public void stopGame(GameoverCause cause) {
 | 
				
			||||||
        switch (cause){
 | 
					        switch (cause){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -92,6 +88,10 @@ public class Game {
 | 
				
			|||||||
        checkZPMStatus();
 | 
					        checkZPMStatus();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void moveReplicator(Direction direction) {
 | 
				
			||||||
 | 
					        replicator.move(direction);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void rotateOneillLeft() {
 | 
					    public void rotateOneillLeft() {
 | 
				
			||||||
        oneill.rotateLeft();
 | 
					        oneill.rotateLeft();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user