battering ram break boards
This commit is contained in:
@@ -314,20 +314,29 @@ class Game {
|
|||||||
System.out.println("What do you want to open the door with?");
|
System.out.println("What do you want to open the door with?");
|
||||||
}
|
}
|
||||||
boolean hasCrowbar = false;
|
boolean hasCrowbar = false;
|
||||||
|
boolean hasBatteringRam = false;
|
||||||
for (int i = 0; i < player.getInventory().size(); i++) {
|
for (int i = 0; i < player.getInventory().size(); i++) {
|
||||||
if (player.getInventory().get(i).equals(new Crowbar())) {
|
if (player.getInventory().get(i).equals(new Crowbar())) {
|
||||||
hasCrowbar = true;
|
hasCrowbar = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (player.getInventory().get(i).equals(new Batteringram())) {
|
||||||
|
hasBatteringRam = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (command.hasDirection() && hasCrowbar) {
|
if (command.hasDirection() && (hasCrowbar || hasBatteringRam)) {
|
||||||
Room nextRoom = currentRoom.nextRoom(command.getDirection());
|
Room nextRoom = currentRoom.nextRoom(command.getDirection());
|
||||||
try {
|
try {
|
||||||
if (nextRoom.getBoarded()) {
|
if (nextRoom.getBoarded()) {
|
||||||
nextRoom.setBoarded(false);
|
nextRoom.setBoarded(false);
|
||||||
|
if(hasCrowbar) {
|
||||||
player.removeFromInventory(new Crowbar());
|
player.removeFromInventory(new Crowbar());
|
||||||
System.out.println(
|
System.out.println("With great effort, you pry the boards off the door with the crowbar! However, it breaks and is no longer useable.");
|
||||||
"With great effort, you pry the boards off the door with the crowbar! However, it breaks and is no longer useable.");
|
}
|
||||||
|
if(hasBatteringRam) {
|
||||||
|
System.out.println("With the battering ram, you smash through the boards on the door!");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
System.out.println("That door is already unboarded!");
|
System.out.println("That door is already unboarded!");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user