Browse Source

refactoring: common String locationName

remotes/origin/map
Tanja Herche 2 years ago
parent
commit
63193fde19
  1. 38
      src/main/java/org/bitbiome/commands/TravelCommand.java

38
src/main/java/org/bitbiome/commands/TravelCommand.java

@ -13,11 +13,19 @@ import java.util.Scanner;
public class TravelCommand implements CommandAPI {
public void exittravelCommand() {
System.out.println(Colors.ANSI_BLUE + "Du hast dein Travel-Pad weggesteckt." + Colors.ANSI_RESET);
}
public void travelCommand() {
}
@Override
public void performCommand(Scanner scanner, boolean isRunning, String message, TravelEngine travelEngine) {
System.out.println(Colors.ANSI_BLUE + "Du hast dein Travel-Pad gezückt. Wohin möchtest du reisen?" + Colors.ANSI_RESET);
JSONArray locations = travelEngine.getLocationList();
String locationName;
String locationWueste = locations.getJSONObject(5).getString("name");
String locationGruenland = locations.getJSONObject(4).getString("name");
String locationWinterland = locations.getJSONObject(2).getString("name");
@ -27,67 +35,73 @@ public class TravelCommand implements CommandAPI {
if (travelEngine.getPlayer().getLocation().getName().equalsIgnoreCase("Wald")) {
System.out.println("- " + locationStrand + "\n" + "- " + locationGruenland + "\n" + "- " + locationBerge);
String locationName = scanner.nextLine();
locationName = scanner.nextLine();
if (travelEngine.locationExistsWald(locationName)) {
travelEngine.travelTo(new Location(locationName, new ArrayList<Mob>(), new ArrayList<Item>()));
System.out.println(Colors.ANSI_BLUE + "Du bist nun hierhin gereist: " + locationName + "\n" + Colors.ANSI_RESET);
} else {
System.out.println(Colors.ANSI_BLUE + "Du hast dein Travel-Pad weggesteckt." + Colors.ANSI_RESET);
exittravelCommand();
return;
}
} else if (travelEngine.getPlayer().getLocation().getName().equalsIgnoreCase("Strand")) {
System.out.println("- " + locationWueste + "\n" + "- " + locationWald);
String locationName = scanner.nextLine();
locationName = scanner.nextLine();
if (travelEngine.locationExistsStrand(locationName)) {
travelEngine.travelTo(new Location(locationName, new ArrayList<Mob>(), new ArrayList<Item>()));
System.out.println(Colors.ANSI_BLUE + "Du bist nun hierhin gereist: " + locationName + "\n" + Colors.ANSI_RESET);
} else {
System.out.println(Colors.ANSI_BLUE + "Du hast dein Travel-Pad weggesteckt." + Colors.ANSI_RESET);
exittravelCommand();
return;
}
} else if (travelEngine.getPlayer().getLocation().getName().equalsIgnoreCase("Gruenland")) {
System.out.println("- " + locationWueste + "\n" + "- " + locationWald + "\n" + "- " + locationWinterland);
String locationName = scanner.nextLine();
locationName = scanner.nextLine();
if (travelEngine.locationExistsGruenland(locationName)) {
travelEngine.travelTo(new Location(locationName, new ArrayList<Mob>(), new ArrayList<Item>()));
System.out.println(Colors.ANSI_BLUE + "Du bist nun hierhin gereist: " + locationName + "\n" + Colors.ANSI_RESET);
} else {
System.out.println(Colors.ANSI_BLUE + "Du hast dein Travel-Pad weggesteckt." + Colors.ANSI_RESET);
exittravelCommand();
return;
}
} else if (travelEngine.getPlayer().getLocation().getName().equalsIgnoreCase("Berge")) {
System.out.println("- " + locationWald + "\n" + "- " + locationWinterland);
String locationName = scanner.nextLine();
locationName = scanner.nextLine();
if (travelEngine.locationExistsBerge(locationName)) {
travelEngine.travelTo(new Location(locationName, new ArrayList<Mob>(), new ArrayList<Item>()));
System.out.println(Colors.ANSI_BLUE + "Du bist nun hierhin gereist: " + locationName + "\n" + Colors.ANSI_RESET);
} else {
System.out.println(Colors.ANSI_BLUE + "Du hast dein Travel-Pad weggesteckt." + Colors.ANSI_RESET);
exittravelCommand();
return;
}
} else if (travelEngine.getPlayer().getLocation().getName().equalsIgnoreCase("Winterland")) {
System.out.println("- " + locationGruenland + "\n" + "- " + locationBerge);
String locationName = scanner.nextLine();
locationName = scanner.nextLine();
if (travelEngine.locationExistsWinterland(locationName)) {
travelEngine.travelTo(new Location(locationName, new ArrayList<Mob>(), new ArrayList<Item>()));
System.out.println(Colors.ANSI_BLUE + "Du bist nun hierhin gereist: " + locationName + "\n" + Colors.ANSI_RESET);
} else {
System.out.println(Colors.ANSI_BLUE + "Du hast dein Travel-Pad weggesteckt." + Colors.ANSI_RESET);
exittravelCommand();
return;
}
} else if (travelEngine.getPlayer().getLocation().getName().equalsIgnoreCase("Wueste")) {
System.out.println("- " + locationStrand + "\n" + "- " + locationGruenland);
String locationName = scanner.nextLine();
locationName = scanner.nextLine();
if (travelEngine.locationExistsWueste(locationName)) {
travelEngine.travelTo(new Location(locationName, new ArrayList<Mob>(), new ArrayList<Item>()));
System.out.println(Colors.ANSI_BLUE + "Du bist nun hierhin gereist: " + locationName + "\n" + Colors.ANSI_RESET);
} else {
System.out.println(Colors.ANSI_BLUE + "Du hast dein Travel-Pad weggesteckt." + Colors.ANSI_RESET);
exittravelCommand();
return;
}
}
}

Loading…
Cancel
Save