From 35d77a5e5da109291bf4eb4b606601e1e39ab49c Mon Sep 17 00:00:00 2001 From: Tanja Herche Date: Sun, 5 Feb 2023 13:20:17 +0100 Subject: [PATCH] Unittest: colored traveloption Strandmap --- .../org/bitbiome/commands/MapCommand.java | 16 ++++++++++++ .../org/bitbiome/commands/MapCommandTest.java | 26 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/src/main/java/org/bitbiome/commands/MapCommand.java b/src/main/java/org/bitbiome/commands/MapCommand.java index 0c271de..3128531 100644 --- a/src/main/java/org/bitbiome/commands/MapCommand.java +++ b/src/main/java/org/bitbiome/commands/MapCommand.java @@ -30,6 +30,22 @@ public class MapCommand implements CommandAPI{ .append("| " + Colors.ANSI_BLUE + locations.getJSONObject(1).getString("name") + Colors.ANSI_RESET + " | " + Colors.ANSI_BRIGHT_BLACK + locations.getJSONObject(0).getString("name") + Colors.ANSI_RESET + " | " + Colors.ANSI_BLUE + locations.getJSONObject(3).getString("name") + Colors.ANSI_RESET + " |" + "\n") .append("| | | |\n") .append("|________________________________|________________________________|________________________________|\n"); + } else if (travelEngine.getPlayer().getLocation().getName().equalsIgnoreCase("Strand")) { + outputMessage + .append(Colors.ANSI_BLUE + getLocationMessage(travelEngine) + "\n" + "Zu den blau markierten Standorten kannst du reisen\n" + Colors.ANSI_RESET) + .append(Colors.ANSI_BLUE + "Deine Karte:\n\n" + Colors.ANSI_RESET) + .append(" __________________________________________________________________________________________________\n") + .append("| | | |\n") + .append("| | | |\n") + .append("| " + Colors.ANSI_BLUE + locations.getJSONObject(5).getString("name") + Colors.ANSI_RESET + " | " + Colors.ANSI_BRIGHT_BLACK + locations.getJSONObject(4).getString("name") + Colors.ANSI_RESET + " | " + Colors.ANSI_BRIGHT_BLACK + locations.getJSONObject(2).getString("name") + Colors.ANSI_RESET + " |" + "\n") + .append("| | | |\n") + .append("|________________________________|________________________________|________________________________|\n") + .append("| | | |\n") + .append("| | | |\n") + .append("| " + Colors.ANSI_BRIGHT_BLACK + locations.getJSONObject(1).getString("name") + Colors.ANSI_RESET + " | " + Colors.ANSI_BLUE + locations.getJSONObject(0).getString("name") + Colors.ANSI_RESET + " | " + Colors.ANSI_BRIGHT_BLACK + locations.getJSONObject(3).getString("name") + Colors.ANSI_RESET + " |" + "\n") + .append("| | | |\n") + .append("|________________________________|________________________________|________________________________|\n"); + } else { outputMessage .append(Colors.ANSI_BLUE + getLocationMessage(travelEngine) + "\n" + Colors.ANSI_RESET) diff --git a/src/test/java/org/bitbiome/commands/MapCommandTest.java b/src/test/java/org/bitbiome/commands/MapCommandTest.java index 599dd8b..a4c5acf 100644 --- a/src/test/java/org/bitbiome/commands/MapCommandTest.java +++ b/src/test/java/org/bitbiome/commands/MapCommandTest.java @@ -36,6 +36,32 @@ public class MapCommandTest { .append("|________________________________|________________________________|________________________________|\n"); + assertEquals(outputMessage.toString(), mapMessage); + } + @Test + public void testStrandMapCommand() { + Player Test = new Player("name"); + TravelEngine outputtest = new TravelEngine(Test); + Location Strand = outputtest.getLocationByName("Strand"); + outputtest.travelTo(Strand); + String mapMessage = MapCommand.getMapMessage(outputtest); + StringBuilder outputMessage = new StringBuilder(); + outputMessage + .append(Colors.ANSI_BLUE + "Du befindest dich gerade hier: Strand" + "\n" + "Zu den blau markierten Standorten kannst du reisen\n" + Colors.ANSI_RESET) + .append(Colors.ANSI_BLUE + "Deine Karte:\n\n" + Colors.ANSI_RESET) + .append(" __________________________________________________________________________________________________\n") + .append("| | | |\n") + .append("| | | |\n") + .append("| " + Colors.ANSI_BLUE + "Wueste" + Colors.ANSI_RESET + " | " + Colors.ANSI_BRIGHT_BLACK + "Gruenland" + Colors.ANSI_RESET + " | " + Colors.ANSI_BRIGHT_BLACK + "Winterland" + Colors.ANSI_RESET + " |" + "\n") + .append("| | | |\n") + .append("|________________________________|________________________________|________________________________|\n") + .append("| | | |\n") + .append("| | | |\n") + .append("| " + Colors.ANSI_BRIGHT_BLACK + "Strand" + Colors.ANSI_RESET + " | " + Colors.ANSI_BLUE + "Wald" + Colors.ANSI_RESET + " | " + Colors.ANSI_BRIGHT_BLACK + "Berge" + Colors.ANSI_RESET + " |" + "\n") + .append("| | | |\n") + .append("|________________________________|________________________________|________________________________|\n"); + + assertEquals(outputMessage.toString(), mapMessage); } @Test