Browse Source
Merge branch 'develop' of https://github.com/RedEagle-dh/BitBiome into develop
remotes/origin/develop
Merge branch 'develop' of https://github.com/RedEagle-dh/BitBiome into develop
remotes/origin/develop
Juliakn66
2 years ago
15 changed files with 713 additions and 84 deletions
-
4playerconfig.json
-
52src/main/java/org/bitbiome/classes/TravelEngine.java
-
2src/main/java/org/bitbiome/commands/CommandListener.java
-
23src/main/java/org/bitbiome/commands/GoldCommand.java
-
9src/main/java/org/bitbiome/commands/HelpCommand.java
-
94src/main/java/org/bitbiome/commands/MapCommand.java
-
77src/main/java/org/bitbiome/commands/TravelCommand.java
-
8src/main/java/org/bitbiome/entities/Player.java
-
64src/main/resources/gameconfig.json
-
157src/main/resources/items.json
-
59src/main/resources/mobs.json
-
2src/main/resources/playerconfig.json
-
0src/test/java/org/bitbiome/commands/HelpCommandTest.java
-
2src/test/java/org/bitbiome/commands/LocationCommandTest.java
-
172src/test/java/org/bitbiome/commands/MapCommandTest.java
@ -0,0 +1,23 @@ |
|||||
|
package org.bitbiome.commands; |
||||
|
|
||||
|
import java.util.Scanner; |
||||
|
|
||||
|
import org.bitbiome.classes.TravelEngine; |
||||
|
import org.bitbiome.entities.Player; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
public class GoldCommand implements CommandAPI{ |
||||
|
|
||||
|
|
||||
|
public static String getGoldMessage(Player player) { |
||||
|
return "Du hast " + player.getGold() + " Gold"; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void performCommand(Scanner scanner, boolean isRunning, String message, TravelEngine travelEngine) { |
||||
|
System.out.println(getGoldMessage(travelEngine.getPlayer())); |
||||
|
return; |
||||
|
} |
||||
|
} |
@ -0,0 +1,94 @@ |
|||||
|
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: " + Colors.ANSI_GREEN + travelEngine.getPlayer().getLocation().getName() + "\n" + Colors.ANSI_RESET; |
||||
|
} |
||||
|
private static String textColor(String text, String color) { |
||||
|
return color + text + Colors.ANSI_RESET; |
||||
|
} |
||||
|
|
||||
|
private static String textBlack(String text) { |
||||
|
return textColor(text,Colors.ANSI_BRIGHT_BLACK); |
||||
|
} |
||||
|
private static String textBlue(String text) { |
||||
|
return textColor(text,Colors.ANSI_BLUE); |
||||
|
} |
||||
|
private static String textGreen(String text) { |
||||
|
return textColor(text,Colors.ANSI_GREEN); |
||||
|
} |
||||
|
private static String signup() { |
||||
|
return (" __________________________________________________________________________________________________\n"); |
||||
|
} |
||||
|
private static String signdown() { |
||||
|
return ("|________________________________|________________________________|________________________________|\n"); |
||||
|
} |
||||
|
private static String signmiddle() { |
||||
|
return ("| | | |\n"); |
||||
|
} |
||||
|
private static String mapup(TravelEngine travelEngine) { |
||||
|
return getLocationMessage(travelEngine) + "Zu den " + textBlue("blau ") + "markierten Standorten kannst du reisen\n\nDeine Karte:\n\n" + signup() + signmiddle() + signmiddle(); |
||||
|
} |
||||
|
private static String mapmiddle() { |
||||
|
return signmiddle() + signdown() + signmiddle() + signmiddle(); |
||||
|
} |
||||
|
private static String mapdown() { |
||||
|
return signmiddle() + signdown(); |
||||
|
} |
||||
|
public static String getMapMessage(TravelEngine travelEngine) { |
||||
|
StringBuilder outputMessage = new StringBuilder(); |
||||
|
JSONArray locations = travelEngine.getLocationList(); |
||||
|
String locationWueste = locations.getJSONObject(5).getString("name"); |
||||
|
String locationGruenland = locations.getJSONObject(4).getString("name"); |
||||
|
String locationWinterland = locations.getJSONObject(2).getString("name"); |
||||
|
String locationStrand = locations.getJSONObject(1).getString("name"); |
||||
|
String locationWald = locations.getJSONObject(0).getString("name"); |
||||
|
String locationBerge = locations.getJSONObject(3).getString("name"); |
||||
|
|
||||
|
if (travelEngine.getPlayer().getLocation().getName().equalsIgnoreCase("Wald")) { |
||||
|
outputMessage |
||||
|
.append(mapup(travelEngine)).append("| ").append(textBlack(locationWueste)).append(" | ").append(textBlue(locationGruenland)).append(" | ").append(textBlack(locationWinterland)).append(" |").append("\n") |
||||
|
.append(mapmiddle()).append("| ").append(textBlue(locationStrand)).append(" | ").append(textGreen(locationWald)).append(" | ").append(textBlue(locationBerge)).append(" |").append("\n") |
||||
|
.append(mapdown()); |
||||
|
} else if (travelEngine.getPlayer().getLocation().getName().equalsIgnoreCase("Strand")) { |
||||
|
outputMessage |
||||
|
.append(mapup(travelEngine)).append("| ").append(textBlue(locationWueste)).append(" | ").append(textBlack(locationGruenland)).append(" | ").append(textBlack(locationWinterland)).append(" |").append("\n") |
||||
|
.append(mapmiddle()).append("| ").append(textGreen(locationStrand)).append(" | ").append(textBlue(locationWald)).append(" | ").append(textBlack(locationBerge)).append(" |").append("\n") |
||||
|
.append(mapdown()); |
||||
|
|
||||
|
} else if (travelEngine.getPlayer().getLocation().getName().equalsIgnoreCase("Berge")) { |
||||
|
outputMessage |
||||
|
.append(mapup(travelEngine)).append("| ").append(textBlack(locationWueste)).append(" | ").append(textBlack(locationGruenland)).append(" | ").append(textBlue(locationWinterland)).append(" |").append("\n") |
||||
|
.append(mapmiddle()).append("| ").append(textBlack(locationStrand)).append(" | ").append(textBlue(locationWald)).append(" | ").append(textGreen(locationBerge)).append(" |").append("\n") |
||||
|
.append(mapdown()); |
||||
|
|
||||
|
} else if (travelEngine.getPlayer().getLocation().getName().equalsIgnoreCase("Wueste")) { |
||||
|
outputMessage |
||||
|
.append(mapup(travelEngine)).append("| ").append(textGreen(locationWueste)).append(" | ").append(textBlue(locationGruenland)).append(" | ").append(textBlack(locationWinterland)).append(" |").append("\n") |
||||
|
.append(mapmiddle()).append("| ").append(textBlue(locationStrand)).append(" | ").append(textBlack(locationWald)).append(" | ").append(textBlack(locationBerge)).append(" |").append("\n") |
||||
|
.append(mapdown()); |
||||
|
|
||||
|
} else if (travelEngine.getPlayer().getLocation().getName().equalsIgnoreCase("Gruenland")) { |
||||
|
outputMessage |
||||
|
.append(mapup(travelEngine)).append("| ").append(textBlue(locationWueste)).append(" | ").append(textGreen(locationGruenland)).append(" | ").append(textBlue(locationWinterland)).append(" |").append("\n") |
||||
|
.append(mapmiddle()).append("| ").append(textBlack(locationStrand)).append(" | ").append(textBlue(locationWald)).append(" | ").append(textBlack(locationBerge)).append(" |").append("\n") |
||||
|
.append(mapdown()); |
||||
|
|
||||
|
} else { |
||||
|
outputMessage |
||||
|
.append(mapup(travelEngine)).append("| ").append(textBlack(locationWueste)).append(" | ").append(textBlue(locationGruenland)).append(" | ").append(textGreen(locationWinterland)).append(" |").append("\n") |
||||
|
.append(mapmiddle()).append("| ").append(textBlack(locationStrand)).append(" | ").append(textBlack(locationWald)).append(" | ").append(textBlue(locationBerge)).append(" |").append("\n") |
||||
|
.append(mapdown()); |
||||
|
} |
||||
|
return outputMessage.toString(); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,59 @@ |
|||||
|
[ |
||||
|
{ |
||||
|
"name": "Big Foot", |
||||
|
"hp": 50, |
||||
|
"damage": "15", |
||||
|
"isFriendly": true, |
||||
|
"items": [ |
||||
|
"Fell" |
||||
|
] |
||||
|
}, |
||||
|
{ |
||||
|
"name": "Riesenkrabbe", |
||||
|
"hp": 50, |
||||
|
"damage": "9", |
||||
|
"isFriendly": false, |
||||
|
"items": [ |
||||
|
"Krabbenschere" |
||||
|
] |
||||
|
}, |
||||
|
{ |
||||
|
"name": "Yeti", |
||||
|
"hp": 55, |
||||
|
"damage": "17", |
||||
|
"isFriendly": true, |
||||
|
"items": [ |
||||
|
"Fell", |
||||
|
"Yetikralle" |
||||
|
] |
||||
|
}, |
||||
|
{ |
||||
|
"name": "Loewe", |
||||
|
"hp": 30, |
||||
|
"damage": "15", |
||||
|
"isFriendly": false, |
||||
|
"items": [ |
||||
|
"Fell", |
||||
|
"Loewenkralle" |
||||
|
] |
||||
|
}, |
||||
|
{ |
||||
|
"name": "Drache", |
||||
|
"hp": 55, |
||||
|
"damage": "20", |
||||
|
"isFriendly": false, |
||||
|
"items": [ |
||||
|
"Drachenzahn", |
||||
|
"Drachenhaut" |
||||
|
] |
||||
|
}, |
||||
|
{ |
||||
|
"name": "Mumie", |
||||
|
"hp": 40, |
||||
|
"damage": "12", |
||||
|
"isFriendly": false, |
||||
|
"items": [ |
||||
|
"Knochen" |
||||
|
] |
||||
|
} |
||||
|
] |
@ -0,0 +1,172 @@ |
|||||
|
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("Du befindest dich gerade hier: " + Colors.ANSI_GREEN + "Wald" + "\n" + Colors.ANSI_RESET + "Zu den " + Colors.ANSI_BLUE + "blau " + Colors.ANSI_RESET + "markierten Standorten kannst du reisen\n\n") |
||||
|
.append("Deine Karte:\n\n") |
||||
|
.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_GREEN + "Wald" + Colors.ANSI_RESET + " | " + Colors.ANSI_BLUE + "Berge" + Colors.ANSI_RESET + " |" + "\n") |
||||
|
.append("| | | |\n") |
||||
|
.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("Du befindest dich gerade hier: " + Colors.ANSI_GREEN + "Strand" + "\n" + Colors.ANSI_RESET + "Zu den " + Colors.ANSI_BLUE + "blau " + Colors.ANSI_RESET + "markierten Standorten kannst du reisen\n\n") |
||||
|
.append("Deine Karte:\n\n") |
||||
|
.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_GREEN + "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 |
||||
|
public void testBergeMapCommand() { |
||||
|
Player Test = new Player("name"); |
||||
|
TravelEngine outputtest = new TravelEngine(Test); |
||||
|
Location Berge = outputtest.getLocationByName("Berge"); |
||||
|
outputtest.travelTo(Berge); |
||||
|
String mapMessage = MapCommand.getMapMessage(outputtest); |
||||
|
StringBuilder outputMessage = new StringBuilder(); |
||||
|
outputMessage |
||||
|
.append("Du befindest dich gerade hier: " + Colors.ANSI_GREEN + "Berge" + "\n" + Colors.ANSI_RESET + "Zu den " + Colors.ANSI_BLUE + "blau " + Colors.ANSI_RESET + "markierten Standorten kannst du reisen\n\n") |
||||
|
.append("Deine Karte:\n\n") |
||||
|
.append(" __________________________________________________________________________________________________\n") |
||||
|
.append("| | | |\n") |
||||
|
.append("| | | |\n") |
||||
|
.append("| " + Colors.ANSI_BRIGHT_BLACK + "Wueste" + Colors.ANSI_RESET + " | " + Colors.ANSI_BRIGHT_BLACK + "Gruenland" + Colors.ANSI_RESET + " | " + Colors.ANSI_BLUE + "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_GREEN + "Berge" + Colors.ANSI_RESET + " |" + "\n") |
||||
|
.append("| | | |\n") |
||||
|
.append("|________________________________|________________________________|________________________________|\n"); |
||||
|
|
||||
|
|
||||
|
assertEquals(outputMessage.toString(), mapMessage); |
||||
|
} |
||||
|
@Test |
||||
|
public void testWuesteMapCommand() { |
||||
|
Player Test = new Player("name"); |
||||
|
TravelEngine outputtest = new TravelEngine(Test); |
||||
|
Location Wueste = outputtest.getLocationByName("Wueste"); |
||||
|
outputtest.travelTo(Wueste); |
||||
|
String mapMessage = MapCommand.getMapMessage(outputtest); |
||||
|
StringBuilder outputMessage = new StringBuilder(); |
||||
|
outputMessage |
||||
|
.append("Du befindest dich gerade hier: " + Colors.ANSI_GREEN + "Wueste" + "\n" + Colors.ANSI_RESET + "Zu den " + Colors.ANSI_BLUE + "blau " + Colors.ANSI_RESET + "markierten Standorten kannst du reisen\n\n") |
||||
|
.append("Deine Karte:\n\n") |
||||
|
.append(" __________________________________________________________________________________________________\n") |
||||
|
.append("| | | |\n") |
||||
|
.append("| | | |\n") |
||||
|
.append("| " + Colors.ANSI_GREEN + "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_BRIGHT_BLACK + "Berge" + Colors.ANSI_RESET + " |" + "\n") |
||||
|
.append("| | | |\n") |
||||
|
.append("|________________________________|________________________________|________________________________|\n"); |
||||
|
|
||||
|
|
||||
|
assertEquals(outputMessage.toString(), mapMessage); |
||||
|
} |
||||
|
@Test |
||||
|
public void testGruenlandMapCommand() { |
||||
|
Player Test = new Player("name"); |
||||
|
TravelEngine outputtest = new TravelEngine(Test); |
||||
|
Location Gruenland = outputtest.getLocationByName("Gruenland"); |
||||
|
outputtest.travelTo(Gruenland); |
||||
|
String mapMessage = MapCommand.getMapMessage(outputtest); |
||||
|
StringBuilder outputMessage = new StringBuilder(); |
||||
|
outputMessage |
||||
|
.append("Du befindest dich gerade hier: " + Colors.ANSI_GREEN + "Gruenland" + "\n" + Colors.ANSI_RESET + "Zu den " + Colors.ANSI_BLUE + "blau " + Colors.ANSI_RESET + "markierten Standorten kannst du reisen\n\n") |
||||
|
.append("Deine Karte:\n\n") |
||||
|
.append(" __________________________________________________________________________________________________\n") |
||||
|
.append("| | | |\n") |
||||
|
.append("| | | |\n") |
||||
|
.append("| " + Colors.ANSI_BLUE + "Wueste" + Colors.ANSI_RESET + " | " + Colors.ANSI_GREEN + "Gruenland" + Colors.ANSI_RESET + " | " + Colors.ANSI_BLUE + "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 |
||||
|
public void testWinterlandMapCommand() { |
||||
|
Player Test = new Player("name"); |
||||
|
TravelEngine outputtest = new TravelEngine(Test); |
||||
|
Location Winterland = outputtest.getLocationByName("Winterland"); |
||||
|
outputtest.travelTo(Winterland); |
||||
|
String mapMessage = MapCommand.getMapMessage(outputtest); |
||||
|
StringBuilder outputMessage = new StringBuilder(); |
||||
|
outputMessage |
||||
|
.append("Du befindest dich gerade hier: " + Colors.ANSI_GREEN + "Winterland" + "\n" + Colors.ANSI_RESET + "Zu den " + Colors.ANSI_BLUE + "blau " + Colors.ANSI_RESET + "markierten Standorten kannst du reisen\n\n") |
||||
|
.append("Deine Karte:\n\n") |
||||
|
.append(" __________________________________________________________________________________________________\n") |
||||
|
.append("| | | |\n") |
||||
|
.append("| | | |\n") |
||||
|
.append("| " + Colors.ANSI_BRIGHT_BLACK + "Wueste" + Colors.ANSI_RESET + " | " + Colors.ANSI_BLUE + "Gruenland" + Colors.ANSI_RESET + " | " + Colors.ANSI_GREEN + "Winterland" + Colors.ANSI_RESET + " |" + "\n") |
||||
|
.append("| | | |\n") |
||||
|
.append("|________________________________|________________________________|________________________________|\n") |
||||
|
.append("| | | |\n") |
||||
|
.append("| | | |\n") |
||||
|
.append("| " + Colors.ANSI_BRIGHT_BLACK + "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); |
||||
|
} |
||||
|
} |
||||
|
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue