diff --git a/data/rooms.dat b/data/rooms.dat index be4ecab..dd396af 100644 --- a/data/rooms.dat +++ b/data/rooms.dat @@ -2,7 +2,7 @@ Room name: Circle Room Room Description: You are in a circular room. The windows to the east are covered with boards that
let in just enough light to see. You spot a man in a tailored suit moving some crates around. Locked: false Boarded: false -Items: Shavingcream +Items: Lightbulb, Candlestick Riddler: "Hello there. My name is Kevin and I am Sir Pellatt's butler. I understand that my master
Sir Pellatt has wrongfully imprisoned you. If you answer my riddle I can give you something to
help you with your escape - nothing comes for free you know!", "What goes moo?", "Cows", Lockpick Exit Rooms: W-Apple Hallway diff --git a/src/com/bayviewglen/zork/Room.java b/src/com/bayviewglen/zork/Room.java index 378ae73..329be96 100644 --- a/src/com/bayviewglen/zork/Room.java +++ b/src/com/bayviewglen/zork/Room.java @@ -197,12 +197,15 @@ class Room { boolean hasItems = false; String items = ""; String itemString = "Items in room: "; - for(int i = 0; i < this.getItems().size() - 1; i++) { - hasItems = true; - items += this.getItems().get(i).getName() + ", "; + if(this.getItems().size() > 0) { + hasItems = true; + for(int i = 0; i < this.getItems().size() - 1; i++) { + hasItems = true; + items += this.getItems().get(i).getName() + ", "; + } + items += this.getItems().get(this.getItems().size() - 1).getName(); } if(hasItems) { - items += this.getItems().get(this.getItems().size() - 1).getName(); return itemString + items; }else { return itemString + "none";