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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user