This commit is contained in:
Luca Carnegie
2019-05-31 21:34:04 -04:00

View File

@@ -269,20 +269,31 @@ class Game {
case "open":
case "unlock":
boolean hasLockPick = false;
boolean hasKey = false;
for (int i = 0; i < player.getInventory().size(); i++) {
if (player.getInventory().get(i).equals(new Lockpick())) {
hasLockPick = true;
break;
}
if (player.getInventory().get(i).equals(new Key())) {
hasKey = true;
break;
}
}
if (command.hasDirection() && hasLockPick) {
if (command.hasDirection() && (hasLockPick || hasKey)) {
Room nextRoom = currentRoom.nextRoom(command.getDirection());
try {
if(nextRoom.getLocked()) {
nextRoom.setLocked(false);
if(hasLockPick) {
player.removeFromInventory(new Lockpick());
System.out.println("After a little bit of picking, a click is heard and the door opens slightly!");
}
if(hasKey) {
player.removeFromInventory(new Key());
System.out.println("With great force, you turn the key in the keyhole and the door unclocks! However, the key broke in the keyhole.");
}
if(!nextRoom.getBoarded())
break;
}else{
@@ -314,7 +325,7 @@ class Game {
System.out.println(
"With great effort, you pry the boards off the door with the crowbar! However, it breaks and is no longer useable.");
} else {
System.out.println("That door is already unlocked!");
System.out.println("That door is already unboarded!");
}
} catch (Exception e) {
System.out.println("There is no door there!");
@@ -322,7 +333,7 @@ class Game {
} else if (!command.hasDirection()) {
} else {
System.out.println("What do you want to unboard the door with?");
}
break;
case "go":