From 4e990e2d04321291f620cfeb23b416874abb1419 Mon Sep 17 00:00:00 2001 From: David Hermann Date: Mon, 6 Feb 2023 10:17:22 +0100 Subject: [PATCH] refactoring: Outsourced code in InteractionLoop Whether the player is new or not will be checked in new outsourced function --- src/main/java/org/bitbiome/classes/InteractionLoop.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/bitbiome/classes/InteractionLoop.java b/src/main/java/org/bitbiome/classes/InteractionLoop.java index bbf513d..5cd9a59 100644 --- a/src/main/java/org/bitbiome/classes/InteractionLoop.java +++ b/src/main/java/org/bitbiome/classes/InteractionLoop.java @@ -11,7 +11,7 @@ public class InteractionLoop { public void run(TravelEngine travelEngine) { boolean isRunning = true; - if (travelEngine.getPlayer().getName().equals("null")) { + if (playerIsNew(travelEngine.getPlayer().getName())) { print(Colors.ANSI_BLUE + "Oh, ein Fremder!\nBist du bereit für dein womöglich größtes Abenteuer?\nDann sag mir doch zunächst wie du heißt: " + Colors.ANSI_RESET); String name = input.nextLine(); JsonParser jp = new JsonParser(); @@ -34,6 +34,10 @@ public class InteractionLoop { return true; } + public boolean playerIsNew(String name) { + return name.equalsIgnoreCase("null"); + } + }