package net.bytten.metazelda;

import java.util.Random;

public class Room {

    public Condition precond;
    public final Coords coords;
    protected Symbol item;
    protected Edge[] edges; // index with Direction.{N,E,S,W}
    
    public Room(Coords coords, Symbol item, Condition precond) {
        this.coords = coords;
        this.item = item;
        this.edges = new Edge[Direction.NUM_DIRS];
        this.precond = precond;
        // all edges initially null
    }
    
    public Room(int x, int y, Symbol item, Condition precond) {
        this(new Coords(x,y), item, precond);
    }

    public Symbol getItem() {
        return item;
    }

    public void setItem(Symbol item) {
        this.item = item;
    }

    public Edge[] getEdges() {
        return edges;
    }
    
    public Edge getEdge(int d) {
        return edges[d];
    }
    
    public boolean isStart() {
        return item != null && item.isStart();
    }
    
    public boolean isGoal() {
        return item != null && item.isGoal();
    }
    
    public Integer getRandomFreeEdgeDirection(Random rand) {
        // Return a random direction for which there is no outgoing edge in the room
        int d = rand.nextInt(Direction.NUM_DIRS),
            tries = 0;
        while (edges[d] != null && tries < Direction.NUM_DIRS){
            d = (d+1) % Direction.NUM_DIRS;
            ++tries;
        }
        if (edges[d] == null)
            return d;
        return null;
    }

    public Condition getPrecond() {
        return precond;
    }
}

@@ -28,34 +28,8 @@
 a;%0A%0A
-import java.util.Random;%0A%0A
 publ
@@ -1012,446 +1012,8 @@
    %0A
-    public Integer getRandomFreeEdgeDirection(Random rand) %7B%0A        // Return a random direction for which there is no outgoing edge in the room%0A        int d = rand.nextInt(Direction.NUM_DIRS),%0A            tries = 0;%0A        while (edges%5Bd%5D != null && tries %3C Direction.NUM_DIRS)%7B%0A            d = (d+1) %25 Direction.NUM_DIRS;%0A            ++tries;%0A        %7D%0A        if (edges%5Bd%5D == null)%0A            return d;%0A        return null;%0A    %7D%0A%0A
     

Remove unused method on Room.