zuul1
This commit is contained in:
@@ -36,7 +36,7 @@ public class Game
|
||||
*/
|
||||
private void createRooms()
|
||||
{
|
||||
Room marketsquare, templePyramid, tavern, sacrificialSite, hut, jungle, secretPassage, cave, beach;
|
||||
Room marketsquare, templePyramid, tavern, sacrificialSite, hut, jungle, secretPassage, cave, beach, basement, wizardsRoom;
|
||||
|
||||
// create the rooms
|
||||
marketsquare = new Room("on the market square");
|
||||
@@ -48,17 +48,21 @@ public class Game
|
||||
secretPassage = new Room("in a secret passage");
|
||||
cave = new Room("in a cave");
|
||||
beach = new Room("on the beach");
|
||||
basement = new Room("in a basement");
|
||||
wizardsRoom = new Room("in a wizards room");
|
||||
|
||||
// initialise room exits
|
||||
marketsquare.setExits(tavern, templePyramid, null, sacrificialSite);
|
||||
templePyramid.setExits(hut, null, null, marketsquare);
|
||||
tavern.setExits(null, hut, marketsquare, null);
|
||||
sacrificialSite.setExits(null, marketsquare, null , null);
|
||||
hut.setExits(null, jungle, templePyramid, tavern);
|
||||
jungle.setExits(null, null, null, hut);
|
||||
secretPassage.setExits(null, null, null, cave);
|
||||
cave.setExits(null, secretPassage, beach, null);
|
||||
beach.setExits(cave, null, null, null);
|
||||
marketsquare.setExits(tavern, templePyramid, null, sacrificialSite, null, null);
|
||||
templePyramid.setExits(hut, null, null, marketsquare, wizardsRoom, basement);
|
||||
tavern.setExits(null, hut, marketsquare, null, null, null);
|
||||
sacrificialSite.setExits(null, marketsquare, null , null, null, cave);
|
||||
hut.setExits(null, jungle, templePyramid, tavern, null, null);
|
||||
jungle.setExits(null, null, null, hut, null, null);
|
||||
secretPassage.setExits(null, basement, null, cave, null, null);
|
||||
cave.setExits(null, secretPassage, beach, null, sacrificialSite, null);
|
||||
beach.setExits(cave, null, null, null, null, null);
|
||||
basement.setExits(null, null, null, secretPassage, templePyramid, null);
|
||||
wizardsRoom.setExits(null, null, null, null, null, templePyramid);
|
||||
|
||||
currentRoom = marketsquare; // start game on marketsquare
|
||||
}
|
||||
@@ -166,6 +170,12 @@ public class Game
|
||||
if(direction.equals("west")) {
|
||||
nextRoom = currentRoom.westExit;
|
||||
}
|
||||
if(direction.equals("up")) {
|
||||
nextRoom = currentRoom.upExit;
|
||||
}
|
||||
if(direction.equals("down")) {
|
||||
nextRoom = currentRoom.downExit;
|
||||
}
|
||||
|
||||
if (nextRoom == null) {
|
||||
System.out.println("There is no door!");
|
||||
@@ -207,6 +217,12 @@ public class Game
|
||||
if(currentRoom.westExit != null) {
|
||||
System.out.print("west ");
|
||||
}
|
||||
if(currentRoom.upExit != null) {
|
||||
System.out.print("up ");
|
||||
}
|
||||
if(currentRoom.downExit != null) {
|
||||
System.out.print("down ");
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ public class Room
|
||||
public Room southExit;
|
||||
public Room eastExit;
|
||||
public Room westExit;
|
||||
public Room upExit;
|
||||
public Room downExit;
|
||||
|
||||
/**
|
||||
* Create a room described "description". Initially, it has
|
||||
@@ -40,8 +42,10 @@ public class Room
|
||||
* @param east The east east.
|
||||
* @param south The south exit.
|
||||
* @param west The west exit.
|
||||
* @param up The up exit.
|
||||
* @param down The down exit.
|
||||
*/
|
||||
public void setExits(Room north, Room east, Room south, Room west)
|
||||
public void setExits(Room north, Room east, Room south, Room west, Room up, Room down)
|
||||
{
|
||||
if(north != null) {
|
||||
northExit = north;
|
||||
@@ -55,6 +59,12 @@ public class Room
|
||||
if(west != null) {
|
||||
westExit = west;
|
||||
}
|
||||
if(up != null) {
|
||||
upExit = up;
|
||||
}
|
||||
if(down != null) {
|
||||
downExit = down;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user