From 0ba9bd4e7b37d0d2ff08a767d0a0acef848867dc Mon Sep 17 00:00:00 2001 From: fdai7430 Date: Mon, 30 Jan 2023 10:16:52 +0100 Subject: [PATCH] refactoring: Added Player object in performCommand() --- src/main/java/org/bitbiome/commands/UseCommand.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/bitbiome/commands/UseCommand.java b/src/main/java/org/bitbiome/commands/UseCommand.java index 5da2190..633fc22 100644 --- a/src/main/java/org/bitbiome/commands/UseCommand.java +++ b/src/main/java/org/bitbiome/commands/UseCommand.java @@ -12,22 +12,23 @@ private boolean combat = false; @Override public void performCommand(Scanner scanner, boolean isRunning, String message, TravelEngine engine) { - getEnemies(engine.getPlayer().getLocation().getMobList()); + Player player = engine.getPlayer(); + getEnemies(player.getLocation().getMobList()); System.out.println(getUseMessage(message.split(" ", 2)[1], engine)); while(enemies.size() > 0 && combat) { - if(engine.getPlayer().getHp() <= 0) + if(player.getHp() <= 0) System.exit(0); for(int i = 0; i