From 2d16686a06b2533de8d27ffb67df6150a1f404ce Mon Sep 17 00:00:00 2001 From: jslightham <31053827+jslightham@users.noreply.github.com> Date: Fri, 31 May 2019 21:49:04 -0400 Subject: [PATCH] battering ram break boards --- src/com/bayviewglen/zork/Game.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/com/bayviewglen/zork/Game.java b/src/com/bayviewglen/zork/Game.java index 54da8f8..c1a6329 100644 --- a/src/com/bayviewglen/zork/Game.java +++ b/src/com/bayviewglen/zork/Game.java @@ -314,20 +314,29 @@ class Game { System.out.println("What do you want to open the door with?"); } boolean hasCrowbar = false; + boolean hasBatteringRam = false; for (int i = 0; i < player.getInventory().size(); i++) { if (player.getInventory().get(i).equals(new Crowbar())) { hasCrowbar = true; 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()); try { if (nextRoom.getBoarded()) { nextRoom.setBoarded(false); + if(hasCrowbar) { player.removeFromInventory(new Crowbar()); - System.out.println( - "With great effort, you pry the boards off the door with the crowbar! However, it breaks and is no longer useable."); + System.out.println("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 { System.out.println("That door is already unboarded!"); }