From 2d40e5954a6cf4d795a48f10b70783a9e92498f3 Mon Sep 17 00:00:00 2001 From: Luca Carnegie <41924665+lcarnegie@users.noreply.github.com> Date: Tue, 28 May 2019 23:28:34 -0400 Subject: [PATCH] Fixed some parser things --- src/com/bayviewglen/zork/CommandWords.java | 2 +- src/com/bayviewglen/zork/Game.java | 20 +++++++++++--------- src/com/bayviewglen/zork/Room.java | 4 +++- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/com/bayviewglen/zork/CommandWords.java b/src/com/bayviewglen/zork/CommandWords.java index 64bc734..de1ff85 100644 --- a/src/com/bayviewglen/zork/CommandWords.java +++ b/src/com/bayviewglen/zork/CommandWords.java @@ -47,7 +47,7 @@ class CommandWords { return false; } } - // Check if given string is direction + // Check if given string is a direction public static boolean isDirection(String aString) { try { return m_words.get(aString).equals("direction"); diff --git a/src/com/bayviewglen/zork/Game.java b/src/com/bayviewglen/zork/Game.java index 977cda5..df4004e 100644 --- a/src/com/bayviewglen/zork/Game.java +++ b/src/com/bayviewglen/zork/Game.java @@ -265,7 +265,7 @@ class Game { if(nextRoom.getLocked()) { nextRoom.setLocked(false); player.removeFromInventory(new Lockpick()); - System.out.println("With great effort, you unlocked the door!"); + System.out.println("After a little bit of picking, a click is heard and the door opens slightly!"); }else{ System.out.println("That door is already unlocked!"); } @@ -273,7 +273,7 @@ class Game { System.out.println("There is no door there!"); } }else if(!command.hasDirection()){ - System.out.println("You must specify a direction!"); + System.out.println("In what direction do you want to go in?"); }else { System.out.println("What do you want to open the door with?"); } @@ -293,7 +293,7 @@ class Game { case "quit": return true; case "die": - System.out.println("If you insist... \n Poof! You're gone. You're out of the castle now, but now a new, grand new adventure begins..."); + System.out.println("If you insist... \nPoof! You're gone. You're out of the castle now, but now a new, grand new adventure begins..."); return true; case "eat": @@ -311,19 +311,19 @@ class Game { } } if(object.isConsumable() && hasItem) { - System.out.println("Yum!"); + System.out.println("Nom Nom Nom..."); player.eat(); - System.out.println("Your health is now " + player.getHealth() + "%"); + System.out.println("Your health is now at " + player.getHealth() + "%"); player.removeFromInventory(object); if(currentCombat != null) currentCombat.setEnemyTurn(); }else if(object.isConsumable()) { - System.out.println("You do not have a " + command.getItem()); + System.out.println("You don't have a " + command.getItem()); }else { - System.out.println("You cannot eat a " + command.getItem()); + System.out.println("Sorry, you can't eat a " + command.getItem()); } } catch(Exception e) { - System.out.println("You cannot eat a " + command.getItem()); + System.out.println("Sorry, you can't eat a " + command.getItem()); } }else { System.out.println("Eat what?"); @@ -344,7 +344,7 @@ class Game { currentRoom.removeItem(object); System.out.println("Taken"); }else { - System.out.println("You cannot carry any more!"); + System.out.println("You can't carry any more stuff!"); } } catch(Exception e) { @@ -466,6 +466,8 @@ class Game { } } break; + case "read": + default: return false; } diff --git a/src/com/bayviewglen/zork/Room.java b/src/com/bayviewglen/zork/Room.java index b332efe..513b4ff 100644 --- a/src/com/bayviewglen/zork/Room.java +++ b/src/com/bayviewglen/zork/Room.java @@ -176,9 +176,11 @@ class Room { String returnString = "Exits:"; String curr = ""; Set keys = exits.keySet(); - for (Iterator iter = keys.iterator(); iter.hasNext();) + + for (Iterator iter = keys.iterator(); iter.hasNext();) { curr = (String) iter.next(); returnString += " " + curr.substring(0,1).toUpperCase() + curr.substring(1); + } return returnString; }