Fixed some parser things

This commit is contained in:
Luca Carnegie
2019-05-28 23:28:34 -04:00
parent 5ba426b51b
commit 2d40e5954a
3 changed files with 15 additions and 11 deletions

View File

@@ -47,7 +47,7 @@ class CommandWords {
return false; return false;
} }
} }
// Check if given string is direction // Check if given string is a direction
public static boolean isDirection(String aString) { public static boolean isDirection(String aString) {
try { try {
return m_words.get(aString).equals("direction"); return m_words.get(aString).equals("direction");

View File

@@ -265,7 +265,7 @@ class Game {
if(nextRoom.getLocked()) { if(nextRoom.getLocked()) {
nextRoom.setLocked(false); nextRoom.setLocked(false);
player.removeFromInventory(new Lockpick()); 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{ }else{
System.out.println("That door is already unlocked!"); System.out.println("That door is already unlocked!");
} }
@@ -273,7 +273,7 @@ class Game {
System.out.println("There is no door there!"); System.out.println("There is no door there!");
} }
}else if(!command.hasDirection()){ }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 { }else {
System.out.println("What do you want to open the door with?"); System.out.println("What do you want to open the door with?");
} }
@@ -293,7 +293,7 @@ class Game {
case "quit": case "quit":
return true; return true;
case "die": 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; return true;
case "eat": case "eat":
@@ -311,19 +311,19 @@ class Game {
} }
} }
if(object.isConsumable() && hasItem) { if(object.isConsumable() && hasItem) {
System.out.println("Yum!"); System.out.println("Nom Nom Nom...");
player.eat(); player.eat();
System.out.println("Your health is now " + player.getHealth() + "%"); System.out.println("Your health is now at " + player.getHealth() + "%");
player.removeFromInventory(object); player.removeFromInventory(object);
if(currentCombat != null) if(currentCombat != null)
currentCombat.setEnemyTurn(); currentCombat.setEnemyTurn();
}else if(object.isConsumable()) { }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 { }else {
System.out.println("You cannot eat a " + command.getItem()); System.out.println("Sorry, you can't eat a " + command.getItem());
} }
} catch(Exception e) { } catch(Exception e) {
System.out.println("You cannot eat a " + command.getItem()); System.out.println("Sorry, you can't eat a " + command.getItem());
} }
}else { }else {
System.out.println("Eat what?"); System.out.println("Eat what?");
@@ -344,7 +344,7 @@ class Game {
currentRoom.removeItem(object); currentRoom.removeItem(object);
System.out.println("Taken"); System.out.println("Taken");
}else { }else {
System.out.println("You cannot carry any more!"); System.out.println("You can't carry any more stuff!");
} }
} catch(Exception e) { } catch(Exception e) {
@@ -466,6 +466,8 @@ class Game {
} }
} }
break; break;
case "read":
default: default:
return false; return false;
} }

View File

@@ -176,9 +176,11 @@ class Room {
String returnString = "Exits:"; String returnString = "Exits:";
String curr = ""; String curr = "";
Set keys = exits.keySet(); Set keys = exits.keySet();
for (Iterator iter = keys.iterator(); iter.hasNext();)
for (Iterator iter = keys.iterator(); iter.hasNext();) {
curr = (String) iter.next(); curr = (String) iter.next();
returnString += " " + curr.substring(0,1).toUpperCase() + curr.substring(1); returnString += " " + curr.substring(0,1).toUpperCase() + curr.substring(1);
}
return returnString; return returnString;
} }