From 48f9d828ff71ea451923416ac1be1e34423674ab Mon Sep 17 00:00:00 2001 From: vleevalerio Date: Wed, 29 May 2019 13:34:11 -0400 Subject: [PATCH 1/3] fixed some errors --- data/rooms.dat | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/data/rooms.dat b/data/rooms.dat index 46e4e35..c94b4d3 100644 --- a/data/rooms.dat +++ b/data/rooms.dat @@ -6,7 +6,7 @@ Riddle: "Who is never hungry during Christmas?", "The turkey because he is alway Exit Rooms: W-Apple Hallway Room name: Apple Hallway -Room Description: You are in an empty hallway. Many closed doors surround you. To the west is the Circle Room and north is the Porcupine Stairs. The door to the stairs is locked. There is no key to the door. +Room Description: You are in an empty hallway. Many closed doors surround you. To the east is the Circle Room and north is the Porcupine Stairs. The door to the stairs is locked and there is not key. Locked: false Items: Riddle: @@ -31,7 +31,7 @@ Room Description: You are in the Bulb Room. There is a ragged red rug with a not Locked: false Items:Garlic Riddle: -Exit Rooms: E-Porcupine Stairs (2nd Floor), W-Lady Pellatt's Bedroom +Exit Rooms: E-Porcupine Stairs (2nd Floor), W-Lady Pellatt's Bedroom, S-Linen Closet Room name: Lady Pellatt's Bedroom Room Description: You are now in Lady Pellatt's Bedroom. A four-post bed with elegant pink bedsheets lies in the middle of the room. A golden wardrobe sits along the east wall with a few robes hanging out. @@ -50,12 +50,12 @@ Exit Rooms: S-Lady Pellatt's Bedroom Room name: Pipe Room Room Description: Welcome to the Pipe Room. A misty smell fills the room. Strange items lay in a pile near the north wall. I suggest you take a look... Locked: false -Items: +Items:Clock,Lightbulb,Keyboard Riddle: Exit Rooms: W-Porcupine Stairs (2nd Floor), S-Landing, N-East Sitting Room, E-Round Room Room name: Round Room -Room Description: You are now into the Round Room. Nothing is out of the ordinary in here... +Room Description: You are now in the Round Room. Nothing is out of the ordinary in here... Locked: false Items: Riddle: @@ -64,19 +64,19 @@ Exit Rooms: W-Pipe Room, N-Elm Bedroom, S-Oak Bedroom Room name: Elm Bedroom Room Description: You are in the Elm Bedroom. The walls are all wooden and a few windows face north. A bed sits in the middle of the room. A few pillows are on the ground. It looks like someone was in here... Locked: false -Items: Water bottle,Pen,Book +Items:Water bottle,Pen,Book Riddle: Exit Rooms: S-Round Room, W-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. +Room Description: Welcome to the East Sitting Room. Boring name for a not-so-boring room. Take a look at the paintings, admire the art. Locked: false Items:Painting Riddle: Exit Rooms: S-Pipe Room, E-Elm Bedroom Room name: Oak Bedroom -Room Description: You are now in the Oak Bedroom. The walls are covered with pink floral wallpaper and a few socks are strewn about the room. A small four-post bedroom lies in the south-east corner of the room. +Room Description: You are now in the Oak Bedroom. The walls are covered with pink floral wallpaper and a few socks are strewn about the room. A small four-post bedroom lies in the south-east corner. Locked: false Items:Socks Riddle: @@ -87,7 +87,7 @@ Room Description: You are now outside on the Landing. A cold gust of wind sweeps Locked: false Items: Riddle: -Exit Rooms: W-Sir Henry Mill Pellatt's Bedroom, E-Oak Bedroom +Exit Rooms: W-Sir Henry Mill Pellatt's Bedroom, E-Oak Bedroom, N-Pipe Room Room name: Sir Henry Mill Pellatt's Bedroom Room Description: Welcome to Sir Henry Mill Pellatt's Bedroom. As the master of this castle, Sir Pellatt isn't in this room very often. Only some clothes, a bed, and a desk reside here. Oh, and don't touch his notebook. @@ -108,7 +108,7 @@ Room Description: A whiff of lavender-scented laundry detergent enters your nost Locked: false Items:Clothes Riddle: -Exit Rooms: E-Sir Henry Mill Pellatt's Bedroom, W-Guest Bedroom, S-Willow Bedroom +Exit Rooms: E-Sir Henry Mill Pellatt's Bedroom, W-Guest Bedroom, S-Willow Bedroom, N-Bulb Room Room name: Willow Bedroom Room Description: This is the Willow Bedroom. Pretty ordinary, if you ask me. Say, doesn't this look like the Oak Bedroom? @@ -118,7 +118,7 @@ Riddle: Exit Rooms: N-Linen Closet, S-Silver Stairs (2nd Floor), W-Another Sitting Area Room name: Silver Stairs (2nd Floor) -Room Description: You are now in the Silver Stairs on the second floor. The bottom of the stairs is blocked by a door. Looks like you need to have something in order to open it. Better find it quick! +Room Description: Congratulations! You made it to the Silver Stairs. The bright staircase will light your way towards the first floor. Locked: true Items: Riddle: @@ -139,21 +139,21 @@ Riddle: Exit Rooms: E-Evergreen Bedroom, N-Another Sitting Area Room name: Another Sitting Area -Room Description: You are now in Another Sitting Area. Yes, that is really its name. Sir Pellatt lacks creativity. This is quite a spectactular room, however. Sitting down for a bit, get comfortable. But not too comfortable, you need to escape. +Room Description: You are now in Another Sitting Area. Yes, that is really its name. Sir Pellatt lacks creativity. This is quite a spectactular room, however. Sit down for a bit, get comfortable. But not too comfortable, you need to escape before Sir Pellatt finds you! Locked: false Items: Riddle: Exit Rooms: S-Apsen Bedroom, E-Willow Bedroom Room name: Guest Bedroom -Room Description: Welcome to the guest bedroom, where guests like yourself stay for the night. Except Sir Pellatt has other plans for you... There is faint writing on the west wall. Might want to take a look... +Room Description: Welcome to the guest bedroom, where guests like yourself stay for the night. There is faint writing on the west wall. You might want to take a look... Locked: false Items: -Riddle: "What letter comes next in this sequence: o,t,t,f,f?", "s" -Exit Rooms: E-Linen Closet, S-Another Sitting Area +Riddle: "What are the next 3 letters in this sequence: o,t,t,f,f,s,s?", "e,n,t" +Exit Rooms: E-Linen Closet, S-Another Sitting Area, N-Lady Pellatt's Bedroom Room name: Silver Stairs (1st Floor) -Room Description: Welcome to the First Floor. You made it this far, don't give up now. Quite a few doors are open down here. Someone even left a few lights on. Could be the servants. +Room Description: Welcome to the First Floor. You made it this far, don't give up now. Quite a few doors are open down here. Someone even left a few lights on although it could just be the servants. Locked: false Items: Riddle: @@ -167,7 +167,7 @@ Riddle: Exit Rooms: N-Silver Stairs (1st Floor), W-Kitchen Room name: Kitchen -Room Description: You are in the Kitchen. The stove, toaster, and microwave along the walls are all turned off. A few pots are soaking in the sink. Warm bread rests in the oven. The sweet smell of yeast fills the room. +Room Description: You are in the Kitchen. The stove, toaster, and microwave along the walls are all turned off. A few pots are soaking in the sink. Warm bread rests in the oven and the sweet smell of yeast fills the room. Locked: false Items:Warm Bread Riddle: @@ -185,7 +185,7 @@ Room Description: You are now in the Serving and Breakfast Room. A small wood ta Locked: false Items:Butter Riddle: -Exit Rooms: N-Dining Room, E-Study, S- Supply Closet +Exit Rooms: N-Dining Room, E-Study, S-Supply Closet Room name: Dining Room Room Description: Welcome to the Dining Room. The old wood boards squeak below you. An elegant chandelier hangs in the center of the room, although it is turned off. A gigantic long wood table sits in the center of the room with 12 cushioned chairs sitting around it. A cello rests in the corner of the room, along with a small stool and a music stand. @@ -195,10 +195,10 @@ Riddle: Exit Rooms: S-Serving and Breakfast Room, E-Library, W-Conservatory Room name: Conservatory -Room Description: You are now in the Conservatory. The walls and ceilings are all glass, which gives you a gorgeous view of the outdoors. A few potted plants lay directly in the sunlight. It looks like there's a scroll on the ground. Check it out, you're running out of time. +Room Description: You are now in the Conservatory. The walls and ceilings are all glass, which gives you a gorgeous view of the outdoors. A few potted plants lay directly in the sunlight. There is faint writing on the south wall. Locked: false -Items:Scroll 3 -Riddle: +Items: +Riddle: "Marking mortal privation, when firmly in place. An enduring summation, inscribed in my face. What am I?", "tombstone" Exit Rooms: E-Dining Room Room name: Library @@ -216,7 +216,7 @@ Riddle: Exit Rooms: S-Entry, W-Library, E-Oak Drawing Room Room name: Oak Drawing Room -Room Description: Welcome to the Oak Drawing Room. A large red carpet covers the floor. Giant floor-to-ceiling windows face north, letting in lots of sunlight. A sword is perched on a small table in the center of the room. Interesting choice of decor... +Room Description: Welcome to the Oak Drawing Room. A large red carpet covers the floor. Giant floor-to-ceiling windows face north, letting in lots of sunlight. A sword is perched on a small table in the center of the room. What an interesting choice of decor... Locked: false Items:Sword Riddle: @@ -229,7 +229,7 @@ Items:Blanket Riddle: Exit Rooms: N-Oak Drawing Room, S-Billiard Room, W-Entry -Room name: Billards Room +Room name: Billiard Room Room Description: You are in the Billiard Room. The only thing in this room would be the pool table in the center. There aren't any balls or poles around though, so I guess no game today! Locked: false Items: @@ -237,7 +237,7 @@ Riddle: Exit Rooms: N-Smoking Room Room name: Entry -Room Description: Welcome to the entrance of Casa Loma. This is where you escape! Oh wait, that door is bolted shut. Plus, it doesn't even have a lock! Shucks, how will you get out now??? +Room Description: CONGRATULATIONS!!! You have escaped alive! I guess Sir Pellatt will have to find another victim tomorrow. Locked: true Items: Riddle: From 01bfc4d473bd5b0f7e9d67cf54806cb9dc33f0e6 Mon Sep 17 00:00:00 2001 From: vleevalerio Date: Wed, 29 May 2019 13:41:53 -0400 Subject: [PATCH 2/3] fixed some more --- data/rooms.dat | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/data/rooms.dat b/data/rooms.dat index f318cae..8dfab84 100644 --- a/data/rooms.dat +++ b/data/rooms.dat @@ -57,12 +57,8 @@ Exit Rooms: S-Lady Pellatt's Bedroom Room name: Pipe Room Room Description: Welcome to the Pipe Room. A misty smell fills the room. Strange items lay in a pile near the north wall. I suggest you take a look... Locked: false -<<<<<<< HEAD -Items:Clock,Lightbulb,Keyboard -======= -Boarded: false -Items: ->>>>>>> branch 'master' of https://github.com/jslightham/Zork/ +Boarded: false +Items:Clock,Lightbulb,Keyboard Riddle: Exit Rooms: W-Porcupine Stairs (2nd Floor), S-Landing, N-East Sitting Room, E-Round Room @@ -77,12 +73,8 @@ Exit Rooms: W-Pipe Room, N-Elm Bedroom, S-Oak Bedroom Room name: Elm Bedroom Room Description: You are in the Elm Bedroom. The walls are all wooden and a few windows face north. A bed sits in the middle of the room. A few pillows are on the ground. It looks like someone was in here... Locked: false -<<<<<<< HEAD -Items:Water bottle,Pen,Book -======= -Boarded: false -Items: Water bottle,Pen,Book ->>>>>>> branch 'master' of https://github.com/jslightham/Zork/ +Boarded: false +Items:Water bottle,Pen,Book Riddle: Exit Rooms: S-Round Room, W-East Sitting Room @@ -177,16 +169,10 @@ Exit Rooms: S-Apsen Bedroom, E-Willow Bedroom Room name: Guest Bedroom Room Description: Welcome to the guest bedroom, where guests like yourself stay for the night. There is faint writing on the west wall. You might want to take a look... Locked: false -<<<<<<< HEAD +Boarded: false Items: Riddle: "What are the next 3 letters in this sequence: o,t,t,f,f,s,s?", "e,n,t" -Exit Rooms: E-Linen Closet, S-Another Sitting Area, N-Lady Pellatt's Bedroom -======= -Boarded: false -Items: Scroll 2 -Riddle: "What letter comes next in this sequence: o,t,t,f,f?", "s" -Exit Rooms: E-Linen Closet, S-Another Sitting Area ->>>>>>> branch 'master' of https://github.com/jslightham/Zork/ +Exit Rooms: E-Linen Closet, S-Another Sitting Area, N-Lady Pellatt's Bedroom Room name: Silver Stairs (1st Floor) Room Description: Welcome to the First Floor. You made it this far, don't give up now. Quite a few doors are open down here. Someone even left a few lights on although it could just be the servants. @@ -239,14 +225,9 @@ Exit Rooms: S-Serving and Breakfast Room, E-Library, W-Conservatory Room name: Conservatory Room Description: You are now in the Conservatory. The walls and ceilings are all glass, which gives you a gorgeous view of the outdoors. A few potted plants lay directly in the sunlight. There is faint writing on the south wall. Locked: false -<<<<<<< HEAD +Boarded: false Items: -Riddle: "Marking mortal privation, when firmly in place. An enduring summation, inscribed in my face. What am I?", "tombstone" -======= -Boarded: false -Items:Scroll 3 -Riddle: ->>>>>>> branch 'master' of https://github.com/jslightham/Zork/ +Riddle: "Marking mortal privation, when firmly in place. An enduring summation, inscribed in my face. What am I?", "tombstone" Exit Rooms: E-Dining Room Room name: Library From c50c63477cb6a75075655dfe5346089c30e68bf0 Mon Sep 17 00:00:00 2001 From: Luca Carnegie <41924665+lcarnegie@users.noreply.github.com> Date: Wed, 29 May 2019 13:42:53 -0400 Subject: [PATCH 3/3] made riddler for rooms, etc... --- data/rooms.dat | 2 +- src/com/bayviewglen/zork/Command.java | 7 ++++- src/com/bayviewglen/zork/CommandWords.java | 27 +----------------- src/com/bayviewglen/zork/Entities/Riddle.java | 27 ++++++++++++++++++ .../bayviewglen/zork/Entities/Riddler.java | 13 +++++++++ src/com/bayviewglen/zork/Game.java | 12 ++++---- src/com/bayviewglen/zork/Items/Riddle.java | 28 ------------------- src/com/bayviewglen/zork/Parser.java | 1 + src/com/bayviewglen/zork/Room.java | 8 ++++-- 9 files changed, 61 insertions(+), 64 deletions(-) create mode 100644 src/com/bayviewglen/zork/Entities/Riddle.java create mode 100644 src/com/bayviewglen/zork/Entities/Riddler.java delete mode 100644 src/com/bayviewglen/zork/Items/Riddle.java diff --git a/data/rooms.dat b/data/rooms.dat index 1b5d364..9368ff7 100644 --- a/data/rooms.dat +++ b/data/rooms.dat @@ -1,5 +1,5 @@ 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.
There seems to be some writing on the wall. +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. Locked: false Items:Lockpick,Milk Riddle: "Who is never hungry during Christmas?", "The turkey because he is always stuffed." diff --git a/src/com/bayviewglen/zork/Command.java b/src/com/bayviewglen/zork/Command.java index fc08494..64bf834 100644 --- a/src/com/bayviewglen/zork/Command.java +++ b/src/com/bayviewglen/zork/Command.java @@ -29,13 +29,14 @@ class Command { private ArrayList otherWords; private String item; private String enemy; + private String riddler; /** * Create a command object. First and second word must be supplied, but * either one (or both) can be null. The command word should be null to * indicate that this was a command that is not recognised by this game. */ - public Command(String firstWord, ArrayList otherWords, String direction, String item, String enemy) { + public Command(String firstWord, ArrayList otherWords, String direction, String item, String enemy, String riddler) { commandWord = firstWord; this.otherWords = otherWords; this.direction = direction; @@ -53,6 +54,7 @@ class Command { this.direction = "down"; this.item = item; this.enemy = enemy; + this.riddler = riddler; } /** @@ -104,6 +106,9 @@ class Command { } public String getEnemy() { return enemy; + } + public boolean hasRiddler() { + } public boolean hasEnemy() { return !enemy.equals(""); diff --git a/src/com/bayviewglen/zork/CommandWords.java b/src/com/bayviewglen/zork/CommandWords.java index 7605c77..de1ff85 100644 --- a/src/com/bayviewglen/zork/CommandWords.java +++ b/src/com/bayviewglen/zork/CommandWords.java @@ -16,8 +16,7 @@ import java.util.Scanner; */ class CommandWords { // a constant array that holds all valid command words - private static HashMap m_words = new HashMap(); - private static HashMap m_synonyms = new HashMap(); + private static HashMap m_words = new HashMap();; /** * Constructor - initialise the command words. */ @@ -34,18 +33,6 @@ class CommandWords { }catch (Exception e) { e.printStackTrace(); } - - try { - Scanner in = new Scanner(new File("data/synonyms.dat")); - while(in.hasNext()){ - String text = in.nextLine(); - String[] textarr = text.split(","); - m_synonyms.put(textarr[0], textarr[1].substring(1)); - } - in.close(); - }catch (Exception e) { - e.printStackTrace(); - } } /** @@ -95,16 +82,4 @@ class CommandWords { } System.out.println(); } - - public static String replaceSynonym(String word) { - try { - String words = m_synonyms.get(word); - if(words == null) - throw new Exception(); - else - return words; - } catch(Exception e) { - return word; - } - } } \ No newline at end of file diff --git a/src/com/bayviewglen/zork/Entities/Riddle.java b/src/com/bayviewglen/zork/Entities/Riddle.java new file mode 100644 index 0000000..ee32fe4 --- /dev/null +++ b/src/com/bayviewglen/zork/Entities/Riddle.java @@ -0,0 +1,27 @@ +package com.bayviewglen.zork.Entities; + +public class Riddle { + private String question; + private String answer; + + public Riddle() { + this.question = "The quick brown fox jumped over the lazy dog"; + this.answer = "Okay"; + } + + public Riddle(String question, String answer) { + this.question = question; + this.answer = answer; + } + + public String getQuestion() { + return question; + } + + public String getAnswer() { + return answer; + } + + + +} diff --git a/src/com/bayviewglen/zork/Entities/Riddler.java b/src/com/bayviewglen/zork/Entities/Riddler.java new file mode 100644 index 0000000..d185c44 --- /dev/null +++ b/src/com/bayviewglen/zork/Entities/Riddler.java @@ -0,0 +1,13 @@ +package com.bayviewglen.zork.Entities; + +public class Riddler extends Entity { + Riddle riddle; + String message; + + public Riddler(double health, double hunger, Riddle riddle) { + super(health, hunger); + this.riddle = riddle; + this.message = "I can help you in your quest, but only if you answer my riddle."; + } + +} diff --git a/src/com/bayviewglen/zork/Game.java b/src/com/bayviewglen/zork/Game.java index d208291..2f75a01 100644 --- a/src/com/bayviewglen/zork/Game.java +++ b/src/com/bayviewglen/zork/Game.java @@ -7,6 +7,8 @@ import java.util.HashMap; import java.util.Scanner; import com.bayviewglen.zork.Entities.Player; +import com.bayviewglen.zork.Entities.Riddle; +import com.bayviewglen.zork.Entities.Riddler; import com.bayviewglen.zork.Entities.Enemies.Enemy; import com.bayviewglen.zork.Items.*; @@ -77,8 +79,9 @@ class Game { try { String question = riddle.split(",")[0].trim().substring(1, riddle.split(",")[0].length()-1).replaceAll("", ","); String answer = riddle.split(",")[1].trim().substring(1, riddle.split(",")[1].length()-2).replaceAll("", ","); - Riddle r = new Riddle(question, answer); - room.addRiddle(r); + Riddle riddleObj = new Riddle(question, answer); + Riddler butler = new Riddler(100, 100, riddleObj); + room.addRiddler(butler); }catch(Exception e) { } @@ -329,6 +332,8 @@ class Game { System.out.println("Eat what?"); } break; + case "talk": + case "take": boolean hasAll = false; for(String a : command.getOtherWords()) { @@ -480,9 +485,6 @@ class Game { } } } - break; - case "read": - break; default: return false; diff --git a/src/com/bayviewglen/zork/Items/Riddle.java b/src/com/bayviewglen/zork/Items/Riddle.java deleted file mode 100644 index 62edbdf..0000000 --- a/src/com/bayviewglen/zork/Items/Riddle.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.bayviewglen.zork.Items; - -public class Riddle extends Item{ - private String question; - private String answer; - - public Riddle() { - super(36, "Riddle", "A faded engraving on the wall. It may help you, or hurt you.", false, 0, 0); - this.question = "The quick brown fox jumped over the lazy dog"; - } - - public Riddle(String question, String answer) { - super(36, "Riddle", "A faded engraving on the wall. It may help you, or hurt you.", false, 0, 0); - this.question = question; - this.answer = answer; - } - - public String getQuestion() { - return question; - } - - public String getAnswer() { - return answer; - } - - - -} diff --git a/src/com/bayviewglen/zork/Parser.java b/src/com/bayviewglen/zork/Parser.java index 1582bc0..71eedb7 100644 --- a/src/com/bayviewglen/zork/Parser.java +++ b/src/com/bayviewglen/zork/Parser.java @@ -36,6 +36,7 @@ class Parser { String direction = ""; String item = ""; String enemy = ""; + String boolean open = false; //String word2; ArrayList words = new ArrayList(); diff --git a/src/com/bayviewglen/zork/Room.java b/src/com/bayviewglen/zork/Room.java index 513b4ff..9e4d790 100644 --- a/src/com/bayviewglen/zork/Room.java +++ b/src/com/bayviewglen/zork/Room.java @@ -18,6 +18,8 @@ import java.util.Set; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; + +import com.bayviewglen.zork.Entities.*; import com.bayviewglen.zork.Items.*; class Room { @@ -25,7 +27,7 @@ class Room { private String description; private HashMap exits; // stores exits of this room. private ArrayList items; - private Riddle riddle; + private Riddler riddler; private boolean locked; /** @@ -86,8 +88,8 @@ class Room { /* * Assigns a Riddle object to the Room */ - public void addRiddle(Riddle riddle) { - this.riddle = riddle; + public void addRiddler(Riddler riddler) { + this.riddler = riddler; } /*