This commit is contained in:
jslightham
2019-06-01 00:50:34 -04:00
4 changed files with 58 additions and 10 deletions

View File

@@ -59,6 +59,9 @@ class Game {
// Read the Description
String roomDescription = roomScanner.nextLine();
room.setDescription(roomDescription.split(": ")[1].replaceAll("<br>", "\n").trim());
//Read room description after riddler is removed.
String newRoomDescription = roomScanner.nextLine();
room.setNewRoomDescription(newRoomDescription.substring(newRoomDescription.indexOf(":") + 1,newRoomDescription.length()).replaceAll("<br>", "\n").trim());
// Read the locked state
boolean locked = Boolean.parseBoolean(roomScanner.nextLine().split(": ")[1].replaceAll("<br>", "\n").trim());
room.setLocked(locked);
@@ -464,6 +467,8 @@ class Game {
} else {
System.out.println("Sorry, you can't carry any more, but a " + prize.getName() + " has been added to your room.");
currentRoom.addItem(prize);
System.out.println("I've got to go find Mr. Pellatt now. Good luck with your escape!");
currentRoom.removeRiddler();
}
} else {
System.out.println("Sorry, that isn't the answer. Think about it, then try again.");

View File

@@ -25,6 +25,7 @@ import com.bayviewglen.zork.Items.*;
class Room {
private String roomName;
private String description;
private String newDescription;
private HashMap<String, Room> exits; // stores exits of this room.
private ArrayList<Item> items;
private Riddler riddler; //needs to altered outside of the class so that riddler can be set to null.
@@ -253,6 +254,7 @@ class Room {
public void removeRiddler() {
riddler = null;
this.description = newDescription;
}
@@ -263,5 +265,10 @@ class Room {
}
return false;
}
public void setNewRoomDescription(String newRoomDesc) {
this.newDescription = newRoomDesc;
}
}