diff --git a/src/main/java/org/bitbiome/commands/MapCommand.java b/src/main/java/org/bitbiome/commands/MapCommand.java index 2c5906a..9c77559 100644 --- a/src/main/java/org/bitbiome/commands/MapCommand.java +++ b/src/main/java/org/bitbiome/commands/MapCommand.java @@ -2,19 +2,24 @@ package org.bitbiome.commands; import org.bitbiome.classes.TravelEngine; import org.json.JSONArray; import java.util.Scanner; +import org.bitbiome.classes.Colors; public class MapCommand implements CommandAPI{ @Override public void performCommand(Scanner scanner, boolean isRunning, String message, TravelEngine travelEngine) { System.out.println(getMapMessage(travelEngine)); } + public static String getLocationMessage(TravelEngine travelEngine) { + return "Du befindest dich gerade hier: " + travelEngine.getPlayer().getLocation().getName(); + } public static String getMapMessage(TravelEngine travelEngine) { StringBuilder outputMessage = new StringBuilder(); JSONArray locations = travelEngine.getLocationList(); outputMessage - .append("Map:\n") - .append(locations.getJSONObject(5).getString("name") + " " + locations.getJSONObject(4).getString("name") + " " + locations.getJSONObject(2).getString("name") + "\n\n") - .append(locations.getJSONObject(1).getString("name") + " " + locations.getJSONObject(0).getString("name") + " " + locations.getJSONObject(3).getString("name") + "\n\n"); + .append(Colors.ANSI_BLUE + getLocationMessage(travelEngine) + "\n" + Colors.ANSI_RESET) + .append(Colors.ANSI_BLUE + "Deine Karte:\n" + Colors.ANSI_RESET) + .append(Colors.ANSI_BLUE + locations.getJSONObject(5).getString("name") + " " + locations.getJSONObject(4).getString("name") + " " + locations.getJSONObject(2).getString("name") + "\n\n" + Colors.ANSI_RESET) + .append(Colors.ANSI_BLUE + locations.getJSONObject(1).getString("name") + " " + locations.getJSONObject(0).getString("name") + " " + locations.getJSONObject(3).getString("name") + "\n\n" + Colors.ANSI_RESET); return outputMessage.toString(); } diff --git a/src/test/java/org/bitbiome/commands/MapCommandTest.java b/src/test/java/org/bitbiome/commands/MapCommandTest.java index 10f2407..02c896e 100644 --- a/src/test/java/org/bitbiome/commands/MapCommandTest.java +++ b/src/test/java/org/bitbiome/commands/MapCommandTest.java @@ -1,5 +1,6 @@ package org.bitbiome.commands; +import org.bitbiome.classes.Colors; import org.bitbiome.classes.TravelEngine; import org.bitbiome.entities.Player; import org.junit.jupiter.api.Test; @@ -14,9 +15,11 @@ public class MapCommandTest { String mapMessage = MapCommand.getMapMessage(outputtest); StringBuilder outputMessage = new StringBuilder(); outputMessage - .append("Map:\n") - .append("Wueste Gruenland Winterland\n\n") - .append("Strand Wald Berge\n\n"); + .append(Colors.ANSI_BLUE + "Du befindest dich gerade hier: Wald" + "\n" + Colors.ANSI_RESET) + .append(Colors.ANSI_BLUE + "Deine Karte:\n" + Colors.ANSI_RESET) + .append(Colors.ANSI_BLUE + "Wueste" + " " + "Gruenland" + " " + "Winterland" + "\n\n" + Colors.ANSI_RESET) + .append(Colors.ANSI_BLUE + "Strand" + " " + "Wald" + " " + "Berge" + "\n\n" + Colors.ANSI_RESET); + assertEquals(outputMessage.toString(), mapMessage); } }