Added Item-viewing functionality to the room class! Also changed some

descriptions
This commit is contained in:
Luca Carnegie
2019-05-27 20:34:11 -04:00
parent e4ba347415
commit 1d0888f0df
3 changed files with 14 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
Room name: Circle Room Room name: Circle Room
Room Description: You are in the circular room. The windows to the west are bolted shut and curtains cover them.<br>To the east, a hallway. A scroll hangs on the north wall. Writing is visible. Room Description: You are in a circular room (No corners). The windows to the west are bolted shut and curtains cover them.<br>To the east, a dimly lit hallway beckons you. However, a scroll hangs on the wall a few paces away. Writing is visible on it.
Locked: false Locked: false
Items:Lockpick,Milk,Scroll Items:Lockpick,Milk,Scroll
Exit Rooms: W-Apple Hallway Exit Rooms: W-Apple Hallway
@@ -49,7 +49,7 @@ Locked: false
Items: Water bottle,Pen,Book Items: Water bottle,Pen,Book
Exit Rooms: S-Round Room, W-East Sitting Room Exit Rooms: S-Round Room, W-East Sitting Room
Room name: East Sitting Room Room name: East Sitting Room
Room Description: Welcome to the East Sitting Room. Boring name but not so boring room. Take a look at the paintings, admire the art. It might be helpful later on. Room Description: Welcome to the East Sitting Room. Boring name but not so boring room. Take a look at the paintings, admire the art.
Locked: false Locked: false
Items:Painting Items:Painting
Exit Rooms: S-Pipe Room, E-Elm Bedroom Exit Rooms: S-Pipe Room, E-Elm Bedroom

View File

@@ -168,12 +168,14 @@ class Game {
System.out.print("> "); System.out.print("> ");
String i = in.nextLine(); String i = in.nextLine();
if(i.toLowerCase().equals("play")) { if(i.toLowerCase().equals("play")) {
return true; return true;
}else if(i.toLowerCase().equals("quit")) { }else if(i.toLowerCase().equals("quit")) {
in.close();
return false; return false;
} }
System.out.println("That is not a valid response. Type \"play\" to play the game. If you wish to close the game, type \"quit\"."); System.out.println("That is not a valid response. Type \"play\" to play the game. If you wish to close the game, type \"quit\".");
} }
in.close();
return false; return false;
@@ -191,6 +193,7 @@ class Game {
System.out.println("---------------------\n"); System.out.println("---------------------\n");
System.out.print(currentRoom.longDescription()); System.out.print(currentRoom.longDescription());
System.out.println(currentRoom.exitString()); System.out.println(currentRoom.exitString());
System.out.println(currentRoom.itemString());
boolean finished = false; boolean finished = false;
while (!finished) { while (!finished) {
if(currentCombat != null) { if(currentCombat != null) {

View File

@@ -1,4 +1,3 @@
package com.bayviewglen.zork; package com.bayviewglen.zork;
/* /*
@@ -172,6 +171,14 @@ class Room {
returnString += " " + iter.next(); returnString += " " + iter.next();
return returnString; return returnString;
} }
public String itemString(){
String items = "Items in Room: " + this.items.get(0).getName();
for(int i = 1; i < this.items.size(); i++) {
items += ", " + this.items.get(i).getName();
}
return items;
}
/** /**
* Return the room that is reached if we go from this room in direction * Return the room that is reached if we go from this room in direction