diff --git a/src/main/java/org/bitbiome/commands/UseCommand.java b/src/main/java/org/bitbiome/commands/UseCommand.java index 1ec7bbf..bf09152 100644 --- a/src/main/java/org/bitbiome/commands/UseCommand.java +++ b/src/main/java/org/bitbiome/commands/UseCommand.java @@ -9,9 +9,11 @@ import org.bitbiome.entities.*; public class UseCommand implements CommandAPI { @Override public void performCommand(Scanner scanner, boolean isRunning, String message, TravelEngine engine) { - System.out.println(getUseMessage(message.split(" ", 2)[1], engine)); - if(engine.getPlayer().getHp() <= 0) - System.exit(0); + do { + System.out.println(getUseMessage(message.split(" ", 2)[1], engine)); + if(engine.getPlayer().getHp() <= 0) + System.exit(0); + } while(getNumOfEnemyMobs(engine) > 0); } private String getUseMessage(String msg, TravelEngine engine) { @@ -64,4 +66,16 @@ public class UseCommand implements CommandAPI { target.setFriendly(false); return "You used " + item.getName() + " on " + target.getName(); } + + private int getNumOfEnemyMobs(TravelEngine engine) { + Location loc = engine.getPlayer().getLocation(); + ArrayList mobs = loc.getMobList(); + int count = 0; + for(int i = 0; i