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