From 0da2e954253e0e9e708a67abd93e39d2785b3517 Mon Sep 17 00:00:00 2001 From: Luca Carnegie <41924665+lcarnegie@users.noreply.github.com> Date: Thu, 30 May 2019 23:41:20 -0400 Subject: [PATCH] added a removeRiddler() method. --- data/rooms.dat | 4 ++-- src/com/bayviewglen/zork/Game.java | 3 ++- src/com/bayviewglen/zork/Room.java | 7 ++++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/data/rooms.dat b/data/rooms.dat index c087a81..c3f6eb4 100644 --- a/data/rooms.dat +++ b/data/rooms.dat @@ -2,8 +2,8 @@ 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:Lockpick,Milk -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", 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 Room name: Apple Hallway diff --git a/src/com/bayviewglen/zork/Game.java b/src/com/bayviewglen/zork/Game.java index 7ac4744..850f1e3 100644 --- a/src/com/bayviewglen/zork/Game.java +++ b/src/com/bayviewglen/zork/Game.java @@ -385,7 +385,7 @@ class Game { if(player.addToInventory(prize)) { player.addToInventory(prize); System.out.println("A " + prizeName + " has been added to your inventory."); - currentRoom.riddler = null; + currentRoom.removeRiddler(); System.out.println("I've got to go find Mr. Pellatt now. Good luck with your escape!"); }else { System.out.println("Sorry, you can't carry any more "); @@ -543,6 +543,7 @@ class Game { return false; } + // implementations of user commands: /** * Print out some help information. Here we print some stupid, cryptic diff --git a/src/com/bayviewglen/zork/Room.java b/src/com/bayviewglen/zork/Room.java index 97a6866..aca9213 100644 --- a/src/com/bayviewglen/zork/Room.java +++ b/src/com/bayviewglen/zork/Room.java @@ -27,7 +27,7 @@ class Room { private String description; private HashMap exits; // stores exits of this room. private ArrayList items; - Riddler riddler; //needs to altered outside of the class so that riddler can be set to null. + private Riddler riddler; //needs to altered outside of the class so that riddler can be set to null. private boolean locked; // Otherwise you can repeatedly solve the riddle and get unlimited items private boolean boarded; @@ -239,5 +239,10 @@ class Room { public Riddler getRiddler() { return riddler; } + + public void removeRiddler() { + riddler = null; + + } }