From fad85807f24da092eda0f6d002671bbd85edbfa5 Mon Sep 17 00:00:00 2001 From: fdai7430 Date: Sat, 4 Feb 2023 20:48:59 +0100 Subject: [PATCH] refactoring: Made a function which executes one cycle of combat --- src/main/java/org/bitbiome/commands/UseCommand.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/bitbiome/commands/UseCommand.java b/src/main/java/org/bitbiome/commands/UseCommand.java index cdef2f5..fe57e5c 100644 --- a/src/main/java/org/bitbiome/commands/UseCommand.java +++ b/src/main/java/org/bitbiome/commands/UseCommand.java @@ -16,7 +16,12 @@ private boolean combat = false; getEnemies(player.getLocation().getMobList()); System.out.println(use(scanner, engine)); while(enemies.size() > 0 && combat) { - if(player.getHp() <= 0) + combat(player, scanner, engine); + } + } + + public void combat(Player player, Scanner scanner, TravelEngine engine) { + if(player.getHp() <= 0) System.exit(0); for(int i = 0; i