Browse Source

Unittest: colored traveloption Waldmap

remotes/origin/map
Tanja Herche 2 years ago
parent
commit
3789cfb6ec
  1. 18
      src/main/java/org/bitbiome/commands/MapCommand.java
  2. 35
      src/test/java/org/bitbiome/commands/MapCommandTest.java

18
src/main/java/org/bitbiome/commands/MapCommand.java

@ -15,6 +15,22 @@ public class MapCommand implements CommandAPI{
public static String getMapMessage(TravelEngine travelEngine) {
StringBuilder outputMessage = new StringBuilder();
JSONArray locations = travelEngine.getLocationList();
if (travelEngine.getPlayer().getLocation().getName().equalsIgnoreCase("Wald")) {
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_BRIGHT_BLACK + locations.getJSONObject(5).getString("name") + Colors.ANSI_RESET + " | " + Colors.ANSI_BLUE + 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_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 {
outputMessage
.append(Colors.ANSI_BLUE + getLocationMessage(travelEngine) + "\n" + Colors.ANSI_RESET)
.append(Colors.ANSI_BLUE + "Deine Karte:\n\n" + Colors.ANSI_RESET)
@ -29,7 +45,7 @@ public class MapCommand implements CommandAPI{
.append("| " + Colors.ANSI_BLUE + locations.getJSONObject(1).getString("name") + Colors.ANSI_RESET + " | " + Colors.ANSI_BLUE + locations.getJSONObject(0).getString("name") + Colors.ANSI_RESET + " | " + Colors.ANSI_BLUE + locations.getJSONObject(3).getString("name") + Colors.ANSI_RESET + " |" + "\n")
.append("| | | |\n")
.append("|________________________________|________________________________|________________________________|\n");
}
return outputMessage.toString();
}

35
src/test/java/org/bitbiome/commands/MapCommandTest.java

@ -2,20 +2,52 @@ package org.bitbiome.commands;
import org.bitbiome.classes.Colors;
import org.bitbiome.classes.TravelEngine;
import org.bitbiome.entities.Location;
import org.bitbiome.entities.Mob;
import org.bitbiome.entities.Player;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class MapCommandTest {
@Test
public void testWaldMapCommand() {
Player Test = new Player("name");
TravelEngine outputtest = new TravelEngine(Test);
Location Wald = outputtest.getLocationByName("Wald");
outputtest.travelTo(Wald);
String mapMessage = MapCommand.getMapMessage(outputtest);
StringBuilder outputMessage = new StringBuilder();
outputMessage
.append(Colors.ANSI_BLUE + "Du befindest dich gerade hier: Wald" + "\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_BRIGHT_BLACK + "Wueste" + Colors.ANSI_RESET + " | " + Colors.ANSI_BLUE + "Gruenland" + Colors.ANSI_RESET + " | " + Colors.ANSI_BRIGHT_BLACK + "Winterland" + Colors.ANSI_RESET + " |" + "\n")
.append("| | | |\n")
.append("|________________________________|________________________________|________________________________|\n")
.append("| | | |\n")
.append("| | | |\n")
.append("| " + Colors.ANSI_BLUE + "Strand" + Colors.ANSI_RESET + " | " + Colors.ANSI_BRIGHT_BLACK + "Wald" + Colors.ANSI_RESET + " | " + Colors.ANSI_BLUE + "Berge" + Colors.ANSI_RESET + " |" + "\n")
.append("| | | |\n")
.append("|________________________________|________________________________|________________________________|\n");
assertEquals(outputMessage.toString(), mapMessage);
}
@Test
public void testMapCommand() {
Player Test = new Player("name");
TravelEngine outputtest = new TravelEngine(Test);
Location Winter = outputtest.getLocationByName("Winterland");
outputtest.travelTo(Winter);
String mapMessage = MapCommand.getMapMessage(outputtest);
StringBuilder outputMessage = new StringBuilder();
outputMessage
.append(Colors.ANSI_BLUE + "Du befindest dich gerade hier: Wald" + "\n" + Colors.ANSI_RESET)
.append(Colors.ANSI_BLUE + "Du befindest dich gerade hier: Winterland" + "\n" + Colors.ANSI_RESET)
.append(Colors.ANSI_BLUE + "Deine Karte:\n\n" + Colors.ANSI_RESET)
.append(" __________________________________________________________________________________________________\n")
.append("| | | |\n")
@ -33,3 +65,4 @@ public class MapCommandTest {
assertEquals(outputMessage.toString(), mapMessage);
}
}
Loading…
Cancel
Save