//1
public void makeAdjList(BoardCell cell, int r, int c) {
...
//now, cells are doorways
if(cell.isDoorway()) {
DoorDirection doorDir = cell.getDoorDirection();
if (doorDir != DoorDirection.UP && r > 0 && gameBoard[r-1][c].getRoomChar() == 'W' && !gameBoard[r-1][c].isOccupied()) { <-----
cell.addAdjacency(gameBoard[r-1][c]);
// moving up
//if it is an "unused spot"
}
if (doorDir != DoorDirection.DOWN && r < this.numRows-1 && gameBoard[r+1][c].getRoomChar() == 'W' && !gameBoard[r+1][c].isOccupied()) {
cell.addAdjacency(gameBoard[r+1][c]);
//moving down
}
if (doorDir != DoorDirection.LEFT && c > 0 && gameBoard[r][c-1].getRoomChar() == 'W' && !gameBoard[r][c-1].isOccupied()) {
cell.addAdjacency(gameBoard[r][c-1]);
}
if (doorDir != DoorDirection.RIGHT && c < this.numColumns-1 && gameBoard[r][c+1].getRoomChar() == 'W' && !gameBoard[r][c+1].isOccupied()) {
cell.addAdjacency(gameBoard[r][c+1]);
}
...
}
//2
public BoardCell(int inRow, int inColumn, boolean isLabel, boolean isRoomCenter, boolean isDoorway, boolean isRoom, Character secretPassage, DoorDirection doorDirection, Character room) { <--------
this.row = inRow;
this.column = inColumn;
this.adjList = new HashSet<BoardCell>();
this.isRoom = isRoom; // assume that each cell is just a room by default
this.isOccupied = false;
this.isLabel = isLabel;
this.isRoomCenter = isRoomCenter;
this.isDoorway = isDoorway;
this.secretPassage = secretPassage;
this.doorDirection = doorDirection;
this.roomChar = room;
}
//3
public void loadLayoutConfig() throws FileNotFoundException, BadConfigFormatException {
...
for(int x = 0; x < this.numRows; x++) {
String[] curRow = fileIn.get(x);
for(int y = 0; y < this.numColumns; y++) {
...
Character secretPassage = 'z'; <------
...
if(curCol.length() > 1) {
switch(curCol.charAt(1)) {
...
default:
secretPassage = curCol.charAt(1);
break;
}
}
gameBoard[x][y] = new BoardCell(x, y, isLabel, isRoomCenter, isDoorway, isRoom, secretPassage, doorDirection, curCol.charAt(0));
}
...
}
//4
public class Room {
...
public void addDoor(BoardCell cell) {
this.doors.add(cell);
}
...
}
//5
public void calcTargets(BoardCell startCell, int pathlength) {
...
findAllTargets(startCell, pathlength);
this.targets.remove(startCell); <------
}