From 6426ea06c78c80b4a36c4e6a085608de8cd9bba2 Mon Sep 17 00:00:00 2001 From: fdai7430 Date: Sat, 28 Jan 2023 14:42:34 +0100 Subject: [PATCH] Combat only starts when player actually attacks someone --- src/main/java/org/bitbiome/commands/UseCommand.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/bitbiome/commands/UseCommand.java b/src/main/java/org/bitbiome/commands/UseCommand.java index a25a279..e734d8c 100644 --- a/src/main/java/org/bitbiome/commands/UseCommand.java +++ b/src/main/java/org/bitbiome/commands/UseCommand.java @@ -8,12 +8,13 @@ import org.bitbiome.entities.*; public class UseCommand implements CommandAPI { private ArrayList enemies = new ArrayList(); +private boolean combat = false; @Override public void performCommand(Scanner scanner, boolean isRunning, String message, TravelEngine engine) { getEnemies(engine.getPlayer().getLocation().getMobList()); - do { - System.out.println(getUseMessage(message.split(" ", 2)[1], engine)); + System.out.println(getUseMessage(message.split(" ", 2)[1], engine)); + while(enemies.size() > 0 && combat) { if(engine.getPlayer().getHp() <= 0) System.exit(0); for(int i = 0; i enemies = new ArrayList(); } engine.getPlayer().setHp(hp); } - } while(enemies.size() > 0); + //TODO get input from player + } } private String getUseMessage(String msg, TravelEngine engine) { @@ -71,6 +73,7 @@ private ArrayList enemies = new ArrayList(); } private String useItem(Item item, Mob target, Location location) { + combat = true; if(target.isFriendly()) enemies.add(target); float hp = target.getHp();