Max Gerbeth
2 years ago
28 changed files with 932 additions and 343 deletions
-
3src/main/java/org/bitbiome/Boot.java
-
96src/main/java/org/bitbiome/classes/BlackJack.java
-
106src/main/java/org/bitbiome/classes/Colors.java
-
24src/main/java/org/bitbiome/classes/CreateLocations.java
-
38src/main/java/org/bitbiome/classes/InteractionLoop.java
-
37src/main/java/org/bitbiome/classes/JsonParser.java
-
11src/main/java/org/bitbiome/classes/TravelEngine.java
-
109src/main/java/org/bitbiome/commands/BlackJackCommand.java
-
4src/main/java/org/bitbiome/commands/CommandAPI.java
-
4src/main/java/org/bitbiome/commands/CommandListener.java
-
4src/main/java/org/bitbiome/commands/HelpCommand.java
-
4src/main/java/org/bitbiome/commands/QuitCommand.java
-
106src/main/java/org/bitbiome/commands/QuizCommand.java
-
15src/main/java/org/bitbiome/commands/TravelCommand.java
-
10src/main/java/org/bitbiome/entities/Item.java
-
8src/main/java/org/bitbiome/entities/Location.java
-
4src/main/java/org/bitbiome/entities/Mob.java
-
11src/main/java/org/bitbiome/entities/Player.java
-
31src/main/resources/playerconfig.json
-
405src/main/resources/quiz.json
-
44src/test/java/org/bitbiome/classes/BlackJackTest.java
-
23src/test/java/org/bitbiome/classes/ColorsTest.java
-
2src/test/java/org/bitbiome/commands/HelpCommandTest.java
-
36src/test/java/org/bitbiome/commands/QuizCommandTest.java
-
38src/test/java/org/bitbiome/entitiesTest/ItemTest.java
-
24src/test/java/org/bitbiome/entitiesTest/LocationTest.java
-
35src/test/java/org/bitbiome/entitiesTest/MobTest.java
-
43src/test/java/org/bitbiome/entitiesTest/PlayerTest.java
@ -0,0 +1,96 @@ |
|||
package org.bitbiome.classes; |
|||
|
|||
import java.util.Random; |
|||
|
|||
public class BlackJack { |
|||
|
|||
public enum Entity { |
|||
PLAYER(1), BOT(2); |
|||
private int value; |
|||
|
|||
private Entity(int value) { |
|||
this.value = value; |
|||
} |
|||
|
|||
public int getValue() { |
|||
return value; |
|||
} |
|||
//Just for testing from some SO answers, but no use |
|||
public void setValue(int value) { |
|||
this.value = value; |
|||
} |
|||
|
|||
public static Entity getEventStatusById(int id) { |
|||
|
|||
Entity entity = null; |
|||
|
|||
switch (id) { |
|||
case 1 -> entity = PLAYER; |
|||
case 2 -> entity = BOT; |
|||
default -> { |
|||
} |
|||
} |
|||
return entity; |
|||
} |
|||
} |
|||
|
|||
private String playerName; |
|||
private int playerPoints; |
|||
private int botPoints; |
|||
private boolean playerIn; |
|||
private boolean botIn; |
|||
|
|||
public BlackJack(String playerName) { |
|||
this.playerName = playerName; |
|||
this.playerPoints = 0; |
|||
this.botPoints = 0; |
|||
this.playerIn = true; |
|||
this.botIn = true; |
|||
} |
|||
|
|||
public String getPlayerName(Entity entity) { |
|||
return entity == Entity.PLAYER ? playerName : "BitBiome"; |
|||
} |
|||
|
|||
public int getPoints(Entity entity) { |
|||
return entity == Entity.PLAYER ? playerPoints : botPoints; |
|||
} |
|||
|
|||
public boolean isIn(Entity entity) { |
|||
return entity == Entity.PLAYER ? playerIn : botIn; |
|||
} |
|||
|
|||
public Entity getEntity(int ID) { |
|||
return Entity.getEventStatusById(ID); |
|||
} |
|||
|
|||
public void addPoints(Entity entity, int points) { |
|||
if (entity == Entity.BOT) botPoints += points; |
|||
if (entity == Entity.PLAYER) playerPoints += points; |
|||
} |
|||
|
|||
public boolean botWantsToPlay() { |
|||
if (botIn) { |
|||
if (botPoints <= 10) { |
|||
return true; |
|||
} else if (botPoints <= 17) { |
|||
int r = new Random().nextInt(1, 9); |
|||
if (r <= 3) { |
|||
botIn = false; |
|||
return false; |
|||
} else { |
|||
return true; |
|||
} |
|||
} else { |
|||
botIn = false; |
|||
return false; |
|||
} |
|||
} else { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
public void playerOut() { |
|||
this.playerIn = false; |
|||
} |
|||
} |
@ -1,24 +0,0 @@ |
|||
package org.bitbiome.classes; |
|||
|
|||
import org.bitbiome.entities.Item; |
|||
import org.bitbiome.entities.Location; |
|||
import org.bitbiome.entities.Mob; |
|||
|
|||
import java.util.ArrayList; |
|||
|
|||
public class CreateLocations { |
|||
|
|||
public static Location createForest() { |
|||
ArrayList<Item> items = new ArrayList<>(); |
|||
ArrayList<Mob> mobs = new ArrayList<>(); |
|||
String name = "Wald"; |
|||
return new Location(name, mobs, items); |
|||
} |
|||
|
|||
public static Location createBeach() { |
|||
ArrayList<Item> items = new ArrayList<>(); |
|||
ArrayList<Mob> mobs = new ArrayList<>(); |
|||
String name = "Strand"; |
|||
return new Location(name, mobs, items); |
|||
} |
|||
} |
@ -0,0 +1,109 @@ |
|||
package org.bitbiome.commands; |
|||
|
|||
|
|||
import org.bitbiome.classes.BlackJack; |
|||
import org.bitbiome.classes.TravelEngine; |
|||
|
|||
import java.util.Random; |
|||
import java.util.Scanner; |
|||
|
|||
public class BlackJackCommand implements CommandAPI { |
|||
private boolean over; |
|||
@Override |
|||
public void performCommand(Scanner scanner, boolean isRunning, String message, TravelEngine travelEngine) { |
|||
|
|||
System.out.println("Du hast das Spiel BlackJack gestartet. Die Spielregeln lauten wie folgt: Du und dein Gegner bekommen jede Runde Zahlen von 4 - 11. \nDerjenige, der zuerst 21 Punkte hat gewinnt. Derjenige, der über 21 Punkte hat verliert. Möchte keiner mehr Karten ziehen, gewinnt der mit dem höchsten Blatt!\nViel Spaß!"); |
|||
|
|||
over = false; |
|||
spielen(); |
|||
} |
|||
|
|||
public void spielen() { |
|||
BlackJack bj = new BlackJack("Dave"); |
|||
Scanner sc = new Scanner(System.in); |
|||
BlackJack.Entity player = bj.getEntity(1); |
|||
while (!over) { |
|||
int r = new Random().nextInt(4, 11); |
|||
bj.addPoints(player, r); |
|||
System.out.println(bj.getPlayerName(player) + " hat " + r + " bekommen. Er hat insgesamt " + bj.getPoints(player) + "."); |
|||
|
|||
if (bj.getPoints(player) >= 21) { |
|||
over21(player, bj); |
|||
has21(player, bj); |
|||
over = true; |
|||
break; |
|||
} |
|||
System.out.print("Weiter?"); |
|||
|
|||
if (player == BlackJack.Entity.BOT) { |
|||
if (bj.botWantsToPlay()) { |
|||
System.out.println("Na klar!"); |
|||
} else { |
|||
System.out.println("Nope, ich bin fertig."); |
|||
} |
|||
} else { |
|||
String eingabe = sc.nextLine(); |
|||
if (!eingabe.toLowerCase().startsWith("j")) { |
|||
bj.playerOut(); |
|||
} |
|||
} |
|||
|
|||
|
|||
player = switchPlayer(player, bj); |
|||
|
|||
} |
|||
} |
|||
|
|||
public void over21(BlackJack.Entity player, BlackJack bj) { |
|||
if (bj.getPoints(player) > 21) { |
|||
over = true; |
|||
System.out.println(bj.getPlayerName(player) + " hat über 21 Punkte und damit verloren."); |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
public void has21(BlackJack.Entity player, BlackJack bj) { |
|||
if (bj.getPoints(player) == 21) { |
|||
System.out.println(bj.getPlayerName(player) + " hat gewonnen! Du hast 21 Punkte!"); |
|||
over = true; |
|||
} |
|||
} |
|||
|
|||
public BlackJack.Entity switchPlayer(BlackJack.Entity player, BlackJack bj) { |
|||
BlackJack.Entity BOT = BlackJack.Entity.BOT; |
|||
BlackJack.Entity PLAYER = BlackJack.Entity.PLAYER; |
|||
if (bj.isIn(BOT) || bj.isIn(PLAYER)) { |
|||
if (player == PLAYER) { |
|||
if (bj.isIn(BOT)) { |
|||
return BOT; |
|||
} |
|||
return PLAYER; |
|||
} else { |
|||
if (bj.isIn(PLAYER)) { |
|||
return PLAYER; |
|||
} |
|||
return BOT; |
|||
} |
|||
} else { |
|||
over = true; |
|||
getWinner(bj); |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
|
|||
public void getWinner(BlackJack bj) { |
|||
BlackJack.Entity entity; |
|||
if (bj.getPoints(BlackJack.Entity.BOT) < bj.getPoints(BlackJack.Entity.PLAYER)) { |
|||
entity = BlackJack.Entity.PLAYER; |
|||
System.out.println(bj.getPlayerName(entity) + " hat gewonnen, da er mehr Punkte hat!"); |
|||
} else if (bj.getPoints(BlackJack.Entity.BOT) == bj.getPoints(BlackJack.Entity.PLAYER)){ |
|||
System.out.println("Es ist Gleichstand!"); |
|||
} else { |
|||
entity = BlackJack.Entity.BOT; |
|||
System.out.println(bj.getPlayerName(entity) + " hat gewonnen, da er mehr Punkte hat!"); |
|||
} |
|||
|
|||
} |
|||
} |
@ -0,0 +1,106 @@ |
|||
package org.bitbiome.commands; |
|||
|
|||
|
|||
import org.bitbiome.classes.JsonParser; |
|||
import org.json.JSONArray; |
|||
import org.json.JSONObject; |
|||
import org.bitbiome.classes.TravelEngine; |
|||
|
|||
|
|||
import java.util.Date; |
|||
import java.util.Random; |
|||
import java.util.Scanner; |
|||
|
|||
public class QuizCommand implements CommandAPI { |
|||
private Scanner quizScanner; |
|||
@Override |
|||
public void performCommand(Scanner scanner, boolean isRunning, String message, TravelEngine travelEngine) { |
|||
quizScanner = new Scanner(System.in); |
|||
|
|||
String path = "src/main/resources/quiz.json"; |
|||
JSONObject quiz = JsonParser.getJSONObject(path); |
|||
|
|||
long diffTime = canPlayAgain(quiz.getLong("lastPlayed")); |
|||
if (diffTime > 0) { |
|||
print("Du darfst erst in " + diffTime / 1000 / 60 + " Minuten spielen."); |
|||
return; |
|||
} |
|||
|
|||
JSONArray fragen = quiz.getJSONArray("Quiz"); |
|||
JSONObject frage = fragen.getJSONObject(random(fragen.length())); |
|||
|
|||
JSONArray antworten = frage.getJSONArray("antworten"); |
|||
|
|||
|
|||
String korrekteAntwort = frage.getString("korrekteAntwort"); |
|||
|
|||
print(starterMessage()); |
|||
|
|||
print(generateQuestion(frage, antworten)); |
|||
|
|||
int eingabe = quizScanner.nextInt(); |
|||
|
|||
if (answerIsCorrect(eingabe, korrekteAntwort, antworten)) { |
|||
int neuerStand = addGold(); |
|||
print("Richtig! Du hast 5 Münzen verdient.\nDein Münzstand beträgt: " + neuerStand); |
|||
} else { |
|||
print("Leider falsch... Richtig ist: " + korrekteAntwort + "\n"); |
|||
} |
|||
|
|||
print(endMessage()); |
|||
|
|||
Date d = new Date(); |
|||
long lastPlayed = d.getTime(); |
|||
quiz.put("lastPlayed", lastPlayed); |
|||
JsonParser.writeObject(path, quiz); |
|||
} |
|||
|
|||
public static boolean answerIsCorrect(int picked, String answer, JSONArray answers) { |
|||
return answers.getString(picked - 1).equalsIgnoreCase(answer); |
|||
} |
|||
|
|||
public static String print(String message) { |
|||
System.out.println(message); |
|||
return message; |
|||
} |
|||
|
|||
public static int random(int length) { |
|||
return new Random().nextInt(length); |
|||
} |
|||
|
|||
public static String generateQuestion(JSONObject frage, JSONArray answers) { |
|||
StringBuilder sb = new StringBuilder(); |
|||
sb.append(frage.getString("frage")).append("\n"); |
|||
for (int i = 0; i < answers.length(); i++) { |
|||
sb.append(i+1).append(". ").append(answers.getString(i)).append("\n"); |
|||
} |
|||
return sb.toString(); |
|||
} |
|||
|
|||
public static int addGold() { |
|||
String playerpath = "src/main/resources/ssplayerconfig.json"; |
|||
JSONObject playerconfig = JsonParser.getJSONObject(playerpath); |
|||
int gold = playerconfig.getInt("gold"); |
|||
gold = gold + 5; |
|||
playerconfig.put("gold", gold); |
|||
JsonParser.writeObject(playerpath, playerconfig); |
|||
return gold; |
|||
} |
|||
|
|||
public static long canPlayAgain(long lastPlayedTime) { |
|||
long currentTime = System.currentTimeMillis(); |
|||
long minTime = lastPlayedTime + (60 * 5 * 1000); |
|||
return minTime - currentTime; |
|||
} |
|||
|
|||
public static String starterMessage(){ |
|||
return "Du hast das Quiz gestartet! Hinweis: Wähle deine Antwort, indem du die Zahl (1-4) eingibst. Ist deine Lösung richtig, erhälst du 5 Münzen. Viel Erfolg! \n"; |
|||
|
|||
} |
|||
|
|||
public static String endMessage(){ |
|||
return "Das Quiz ist vorbei!"; |
|||
} |
|||
} |
|||
|
|||
|
@ -1,17 +1,18 @@ |
|||
{ |
|||
"name": "null", |
|||
"gold": 0, |
|||
"hp": 10, |
|||
"currentLocation": "Wald", |
|||
"inventory": [ |
|||
{ |
|||
"name": "Holz", |
|||
"amount": "5", |
|||
"durability": 1000 |
|||
},{ |
|||
"name": "Stein", |
|||
"amount": "5", |
|||
"durability": 1000 |
|||
} |
|||
] |
|||
"gold": 0, |
|||
"name": "Dave", |
|||
"hp": 10, |
|||
"inventory": [ |
|||
{ |
|||
"amount": "5", |
|||
"durability": 1000, |
|||
"name": "Holz" |
|||
}, |
|||
{ |
|||
"amount": "5", |
|||
"durability": 1000, |
|||
"name": "Stein" |
|||
} |
|||
], |
|||
"currentLocation": "Wald" |
|||
} |
@ -1,204 +1,205 @@ |
|||
{ |
|||
"Quiz": [ |
|||
{ |
|||
"frage": "Wie lang ist der Äquator der Erde?", |
|||
"antworten": [ |
|||
"20.000m", |
|||
"30km", |
|||
"60.000km", |
|||
"40.000km" |
|||
], |
|||
"korrekteAntwort": "40.000km" |
|||
}, |
|||
{ |
|||
"frage": "Was ist der längste Fluss der Welt?", |
|||
"antworten": [ |
|||
"Amazonas", |
|||
"Nil", |
|||
"Rhein", |
|||
"Niger" |
|||
], |
|||
"korrekteAntwort": "Nil" |
|||
}, |
|||
{ |
|||
"frage": "Wie viele Tasten hat ein Klavier?", |
|||
"antworten": [ |
|||
"74", |
|||
"86", |
|||
"82", |
|||
"88" |
|||
], |
|||
"korrekteAntwort": "88" |
|||
}, |
|||
{ |
|||
"frage": "Von wem wird der Bundespräsident gewählt?", |
|||
"antworten": [ |
|||
"Vom Europäischen Parlament", |
|||
"Vom Bundeskanzler", |
|||
"Vom Bundestag", |
|||
"Von der Bundesversammlung" |
|||
], |
|||
"korrekteAntwort": "von der Bundesversammlung" |
|||
}, |
|||
{ |
|||
"frage": "Welches Land produziert jährlich die meisten Filme?", |
|||
"antworten": [ |
|||
"USA", |
|||
"Indien", |
|||
"Japan", |
|||
"Nigeria" |
|||
], |
|||
"korrekteAntwort": "Indien" |
|||
}, |
|||
{ |
|||
"frage": "Wie heißt der am schnellsten schwimmende Fisch auf Erden?", |
|||
"antworten": [ |
|||
"Flugfisch", |
|||
"Tigerhai", |
|||
"Segelfisch", |
|||
"Windfisch" |
|||
], |
|||
"korrekteAntwort": "Segelfisch" |
|||
}, |
|||
{ |
|||
"frage": "Was ist KEIN Gewächs?", |
|||
"antworten": [ |
|||
"Geranie", |
|||
"Moosfarn", |
|||
"Incolornis", |
|||
"Strandflieder" |
|||
], |
|||
"korrekteAntwort": "Incolornis" |
|||
}, |
|||
{ |
|||
"frage": "Was nutzt eine Fledermaus zur Orientierung in der Luft?", |
|||
"antworten": [ |
|||
"Infrarot", |
|||
"Röntgenstrahlen", |
|||
"Speichel", |
|||
"Ultraschall" |
|||
], |
|||
"korrekteAntwort": "Ultraschall" |
|||
}, |
|||
{ |
|||
"frage": "Von wem stammt der berühmte Satz: 'Ich denke, also bin ich'?", |
|||
"antworten": [ |
|||
"John Fitzgerald Kennedy", |
|||
"George Walker Bush", |
|||
"René Descartes", |
|||
"Julius Caesar" |
|||
], |
|||
"korrekteAntwort": "René Descartes" |
|||
}, |
|||
{ |
|||
"frage": "Welches Lebensmittel enthält das meiste Wasser?", |
|||
"antworten": [ |
|||
"Gurke", |
|||
"Wassermelone", |
|||
"Zitrone", |
|||
"Paprika" |
|||
], |
|||
"korrekteAntwort": "Gurke" |
|||
}, |
|||
{ |
|||
"frage": "Welches Lebensmittel gehört im botanischen Sinne zu den Früchten?", |
|||
"antworten": [ |
|||
"Möhre", |
|||
"Kartoffel", |
|||
"Tomate", |
|||
"Weißkohl" |
|||
], |
|||
"korrekteAntwort": "Tomate" |
|||
}, |
|||
{ |
|||
"frage": "Haptische Wahrnehmung beruht auf dem...?", |
|||
"antworten": [ |
|||
"Greifreflex", |
|||
"Gleichgewichtssinn", |
|||
"Hörsinn", |
|||
"Tastsinn" |
|||
], |
|||
"korrekteAntwort": "Tastsinn" |
|||
}, |
|||
{ |
|||
"frage": "Wie nennt man den letzten Tanz einer Tanzveranstaltung?", |
|||
"antworten": [ |
|||
"Voraus", |
|||
"Garaus", |
|||
"Kehraus", |
|||
"Durchaus" |
|||
], |
|||
"korrekteAntwort": "Kehraus" |
|||
}, |
|||
{ |
|||
"frage": "Wie nennt man ein tiefes, enges Tal, durch das ein Gebirgsbach fließt?", |
|||
"antworten": [ |
|||
"Klamm", |
|||
"Feucht", |
|||
"Nass", |
|||
"Schwamm" |
|||
], |
|||
"korrekteAntwort": "Klamm" |
|||
}, |
|||
{ |
|||
"frage": "Wer oder was ist Gerbera?", |
|||
"antworten": [ |
|||
"eine europäische Landschaft", |
|||
"eine Pflanze", |
|||
"die erste Präsidentin von Südafrika", |
|||
"eine Stadt in Lichtenstein" |
|||
], |
|||
"korrekteAntwort": "eine Pflanze" |
|||
}, |
|||
{ |
|||
"frage": "Nach wem wurde ein Gesellschaftsanzug benannt?", |
|||
"antworten": [ |
|||
"Richard von Weizsäcker", |
|||
"Gustav Heinemann", |
|||
"Jürgen Klinsmann", |
|||
"Gustav Stresemann" |
|||
], |
|||
"korrekteAntwort": "Gustav Stresemann" |
|||
}, |
|||
{ |
|||
"frage": "Was ist Speckstein?", |
|||
"antworten": [ |
|||
"eine Fischart, die sich als Stein tarnt", |
|||
"ein Gericht aus dem Mittelalter", |
|||
"eine Skulptur im Römischen Reich unter Nero", |
|||
"ein besonders weicher Stein" |
|||
], |
|||
"korrekteAntwort": "ein besonders weicher Stein" |
|||
}, |
|||
{ |
|||
"frage": "In welcher Religion gibt es Gurus?", |
|||
"antworten": [ |
|||
"im Christentum", |
|||
"im Hinduismus", |
|||
"im Islam", |
|||
"im Judentum" |
|||
], |
|||
"korrekteAntwort": "im Hinduismus" |
|||
}, |
|||
{ |
|||
"frage": "Was versteht man unter Brunsbüttel?", |
|||
"antworten": [ |
|||
"eine Industriestadt an der Unterelbe", |
|||
"einen Plakatkleber", |
|||
"eine 630 Mark-Kraft", |
|||
"ein Staatssekretär" |
|||
], |
|||
"korrekteAntwort": "eine Industriestadt an der Unterelbe" |
|||
}, |
|||
{ |
|||
"frage": "Welcher im 11. Jahrhundert gegründeter Orden rettet und pfelgt auch noch heute Verletzte und Kranke?", |
|||
"antworten": [ |
|||
"die Dominikaner", |
|||
"die Augustiner", |
|||
"die Zisterzienser", |
|||
"die Johanniter" |
|||
], |
|||
"korrekteAntwort": "die Johanniter" |
|||
} |
|||
] |
|||
"Quiz": [ |
|||
{ |
|||
"frage": "Wie lang ist der Äquator der Erde?", |
|||
"korrekteAntwort": "40.000km", |
|||
"antworten": [ |
|||
"20.000m", |
|||
"30km", |
|||
"60.000km", |
|||
"40.000km" |
|||
] |
|||
}, |
|||
{ |
|||
"frage": "Was ist der längste Fluss der Welt?", |
|||
"korrekteAntwort": "Nil", |
|||
"antworten": [ |
|||
"Amazonas", |
|||
"Nil", |
|||
"Rhein", |
|||
"Niger" |
|||
] |
|||
}, |
|||
{ |
|||
"frage": "Wie viele Tasten hat ein Klavier?", |
|||
"korrekteAntwort": "88", |
|||
"antworten": [ |
|||
"74", |
|||
"86", |
|||
"82", |
|||
"88" |
|||
] |
|||
}, |
|||
{ |
|||
"frage": "Von wem wird der Bundespräsident gewählt?", |
|||
"korrekteAntwort": "von der Bundesversammlung", |
|||
"antworten": [ |
|||
"Vom Europäischen Parlament", |
|||
"Vom Bundeskanzler", |
|||
"Vom Bundestag", |
|||
"Von der Bundesversammlung" |
|||
] |
|||
}, |
|||
{ |
|||
"frage": "Welches Land produziert jährlich die meisten Filme?", |
|||
"korrekteAntwort": "Indien", |
|||
"antworten": [ |
|||
"USA", |
|||
"Indien", |
|||
"Japan", |
|||
"Nigeria" |
|||
] |
|||
}, |
|||
{ |
|||
"frage": "Wie heißt der am schnellsten schwimmende Fisch auf Erden?", |
|||
"korrekteAntwort": "Segelfisch", |
|||
"antworten": [ |
|||
"Flugfisch", |
|||
"Tigerhai", |
|||
"Segelfisch", |
|||
"Windfisch" |
|||
] |
|||
}, |
|||
{ |
|||
"frage": "Was ist KEIN Gewächs?", |
|||
"korrekteAntwort": "Incolornis", |
|||
"antworten": [ |
|||
"Geranie", |
|||
"Moosfarn", |
|||
"Incolornis", |
|||
"Strandflieder" |
|||
] |
|||
}, |
|||
{ |
|||
"frage": "Was nutzt eine Fledermaus zur Orientierung in der Luft?", |
|||
"korrekteAntwort": "Ultraschall", |
|||
"antworten": [ |
|||
"Infrarot", |
|||
"Röntgenstrahlen", |
|||
"Speichel", |
|||
"Ultraschall" |
|||
] |
|||
}, |
|||
{ |
|||
"frage": "Von wem stammt der berühmte Satz: 'Ich denke, also bin ich'?", |
|||
"korrekteAntwort": "René Descartes", |
|||
"antworten": [ |
|||
"John Fitzgerald Kennedy", |
|||
"George Walker Bush", |
|||
"René Descartes", |
|||
"Julius Caesar" |
|||
] |
|||
}, |
|||
{ |
|||
"frage": "Welches Lebensmittel enthält das meiste Wasser?", |
|||
"korrekteAntwort": "Gurke", |
|||
"antworten": [ |
|||
"Gurke", |
|||
"Wassermelone", |
|||
"Zitrone", |
|||
"Paprika" |
|||
] |
|||
}, |
|||
{ |
|||
"frage": "Welches Lebensmittel gehört im botanischen Sinne zu den Früchten?", |
|||
"korrekteAntwort": "Tomate", |
|||
"antworten": [ |
|||
"Möhre", |
|||
"Kartoffel", |
|||
"Tomate", |
|||
"Weißkohl" |
|||
] |
|||
}, |
|||
{ |
|||
"frage": "Haptische Wahrnehmung beruht auf dem...?", |
|||
"korrekteAntwort": "Tastsinn", |
|||
"antworten": [ |
|||
"Greifreflex", |
|||
"Gleichgewichtssinn", |
|||
"Hörsinn", |
|||
"Tastsinn" |
|||
] |
|||
}, |
|||
{ |
|||
"frage": "Wie nennt man den letzten Tanz einer Tanzveranstaltung?", |
|||
"korrekteAntwort": "Kehraus", |
|||
"antworten": [ |
|||
"Voraus", |
|||
"Garaus", |
|||
"Kehraus", |
|||
"Durchaus" |
|||
] |
|||
}, |
|||
{ |
|||
"frage": "Wie nennt man ein tiefes, enges Tal, durch das ein Gebirgsbach fließt?", |
|||
"korrekteAntwort": "Klamm", |
|||
"antworten": [ |
|||
"Klamm", |
|||
"Feucht", |
|||
"Nass", |
|||
"Schwamm" |
|||
] |
|||
}, |
|||
{ |
|||
"frage": "Wer oder was ist Gerbera?", |
|||
"korrekteAntwort": "eine Pflanze", |
|||
"antworten": [ |
|||
"eine europäische Landschaft", |
|||
"eine Pflanze", |
|||
"die erste Präsidentin von Südafrika", |
|||
"eine Stadt in Lichtenstein" |
|||
] |
|||
}, |
|||
{ |
|||
"frage": "Nach wem wurde ein Gesellschaftsanzug benannt?", |
|||
"korrekteAntwort": "Gustav Stresemann", |
|||
"antworten": [ |
|||
"Richard von Weizsäcker", |
|||
"Gustav Heinemann", |
|||
"Jürgen Klinsmann", |
|||
"Gustav Stresemann" |
|||
] |
|||
}, |
|||
{ |
|||
"frage": "Was ist Speckstein?", |
|||
"korrekteAntwort": "ein besonders weicher Stein", |
|||
"antworten": [ |
|||
"eine Fischart, die sich als Stein tarnt", |
|||
"ein Gericht aus dem Mittelalter", |
|||
"eine Skulptur im Römischen Reich unter Nero", |
|||
"ein besonders weicher Stein" |
|||
] |
|||
}, |
|||
{ |
|||
"frage": "In welcher Religion gibt es Gurus?", |
|||
"korrekteAntwort": "im Hinduismus", |
|||
"antworten": [ |
|||
"im Christentum", |
|||
"im Hinduismus", |
|||
"im Islam", |
|||
"im Judentum" |
|||
] |
|||
}, |
|||
{ |
|||
"frage": "Was versteht man unter Brunsbüttel?", |
|||
"korrekteAntwort": "eine Industriestadt an der Unterelbe", |
|||
"antworten": [ |
|||
"eine Industriestadt an der Unterelbe", |
|||
"einen Plakatkleber", |
|||
"eine 630 Mark-Kraft", |
|||
"ein Staatssekretär" |
|||
] |
|||
}, |
|||
{ |
|||
"frage": "Welcher im 11. Jahrhundert gegründeter Orden rettet und pfelgt auch noch heute Verletzte und Kranke?", |
|||
"korrekteAntwort": "die Johanniter", |
|||
"antworten": [ |
|||
"die Dominikaner", |
|||
"die Augustiner", |
|||
"die Zisterzienser", |
|||
"die Johanniter" |
|||
] |
|||
} |
|||
], |
|||
"lastPlayed": 1675768444160 |
|||
} |
@ -0,0 +1,44 @@ |
|||
package org.bitbiome.classes; |
|||
|
|||
import org.junit.jupiter.api.BeforeAll; |
|||
import org.junit.jupiter.api.Test; |
|||
|
|||
import static org.junit.jupiter.api.Assertions.*; |
|||
|
|||
public class BlackJackTest { |
|||
|
|||
private static BlackJack bj; |
|||
@BeforeAll |
|||
public static void setUpTest() { |
|||
bj = new BlackJack("UnitTest"); |
|||
} |
|||
@Test |
|||
public void testGetEntity() { |
|||
assertEquals(BlackJack.Entity.PLAYER, bj.getEntity(1)); |
|||
} |
|||
|
|||
@Test |
|||
public void testGetEntityBot() { |
|||
assertEquals(BlackJack.Entity.BOT, bj.getEntity(2)); |
|||
} |
|||
|
|||
@Test |
|||
public void testPlayerName() { |
|||
assertEquals("UnitTest", bj.getPlayerName(BlackJack.Entity.PLAYER)); |
|||
} |
|||
|
|||
@Test |
|||
public void testBotName() { |
|||
assertEquals("BitBiome", bj.getPlayerName(BlackJack.Entity.BOT)); |
|||
} |
|||
|
|||
@Test |
|||
public void testPlayerIsIn() { |
|||
assertTrue(bj.isIn(BlackJack.Entity.PLAYER)); |
|||
} |
|||
|
|||
@Test |
|||
public void testBotIsIn() { |
|||
assertTrue(bj.isIn(BlackJack.Entity.BOT)); |
|||
} |
|||
} |
@ -0,0 +1,23 @@ |
|||
package org.bitbiome.classes; |
|||
|
|||
import static org.junit.jupiter.api.Assertions.assertEquals; |
|||
|
|||
import org.junit.jupiter.api.Test; |
|||
|
|||
public class ColorsTest { |
|||
|
|||
@Test |
|||
public void testResetCode() { |
|||
assertEquals("\u001B[0m", Colors.ANSI_RESET); |
|||
} |
|||
|
|||
@Test |
|||
public void testBlueCode() { |
|||
assertEquals("\u001B[34m", Colors.ANSI_BLUE); |
|||
} |
|||
|
|||
@Test |
|||
public void testCyanCode() { |
|||
assertEquals("\u001B[36m", Colors.ANSI_CYAN); |
|||
} |
|||
} |
@ -0,0 +1,36 @@ |
|||
package org.bitbiome.commands; |
|||
|
|||
import org.junit.jupiter.api.Test; |
|||
|
|||
|
|||
import static org.junit.jupiter.api.Assertions.*; |
|||
|
|||
public class QuizCommandTest { |
|||
|
|||
@Test |
|||
public void testStartMessage() { |
|||
assertEquals("Du hast das Quiz gestartet! Hinweis: Wähle deine Antwort, indem du die Zahl (1-4) eingibst. Ist deine Lösung richtig, erhälst du 5 Münzen. Viel Erfolg! \n", QuizCommand.starterMessage()); |
|||
} |
|||
|
|||
@Test |
|||
public void testEndMessage() { |
|||
assertEquals("Das Quiz ist vorbei!", QuizCommand.endMessage()); |
|||
} |
|||
|
|||
@Test |
|||
public void testLastTimePlayed() { |
|||
long lastTimePlayed = System.currentTimeMillis(); |
|||
assertTrue(QuizCommand.canPlayAgain(lastTimePlayed) < lastTimePlayed); |
|||
} |
|||
|
|||
@Test |
|||
public void testRandomNumberGenerator() { |
|||
int getRandom = QuizCommand.random(3); |
|||
assertTrue(getRandom >= 0 && getRandom <= 3); |
|||
} |
|||
|
|||
@Test |
|||
public void testPrintFunction() { |
|||
assertEquals("I am a unit test!", QuizCommand.print("I am a unit test!")); |
|||
} |
|||
} |
@ -0,0 +1,38 @@ |
|||
package org.bitbiome.entitiesTest; |
|||
import static org.junit.jupiter.api.Assertions.assertEquals; |
|||
import static org.junit.jupiter.api.Assumptions.assumeTrue; |
|||
|
|||
import org.bitbiome.entities.Item; |
|||
import org.junit.jupiter.api.BeforeAll; |
|||
import org.junit.jupiter.api.Test; |
|||
|
|||
|
|||
public class ItemTest { |
|||
|
|||
private static Item item; |
|||
|
|||
@BeforeAll |
|||
public static void setItem() { |
|||
item = new Item(); |
|||
item.setName("Unit"); |
|||
item.setDamage(12.5F); |
|||
item.changeDoesDamage(true); |
|||
} |
|||
|
|||
@Test |
|||
public void testGetName() { |
|||
assertEquals("Unit", item.getName()); |
|||
} |
|||
|
|||
@Test |
|||
public void testGetDamage() { |
|||
assertEquals(12.5, item.getDamage()); |
|||
} |
|||
|
|||
@Test |
|||
public void testDoesDamage() { |
|||
boolean doesDamage = item.doesDamage(); |
|||
assumeTrue(item.getDamage() > 0); |
|||
assumeTrue(doesDamage); |
|||
} |
|||
} |
@ -0,0 +1,24 @@ |
|||
package org.bitbiome.entitiesTest; |
|||
|
|||
import static org.junit.jupiter.api.Assertions.assertEquals; |
|||
|
|||
import org.bitbiome.entities.Location; |
|||
import org.junit.jupiter.api.BeforeAll; |
|||
import org.junit.jupiter.api.Test; |
|||
|
|||
public class LocationTest { |
|||
|
|||
private static Location location; |
|||
|
|||
|
|||
@BeforeAll |
|||
public static void setLocation() { |
|||
location = new Location(); |
|||
location.setName("NewUnitWorld"); |
|||
} |
|||
|
|||
@Test |
|||
public void testLocationName() { |
|||
assertEquals("NewUnitWorld", location.getName()); |
|||
} |
|||
} |
@ -0,0 +1,35 @@ |
|||
package org.bitbiome.entitiesTest; |
|||
import static org.junit.jupiter.api.Assertions.assertEquals; |
|||
import org.bitbiome.entities.Mob; |
|||
import org.junit.jupiter.api.BeforeAll; |
|||
import org.junit.jupiter.api.Test; |
|||
|
|||
|
|||
public class MobTest { |
|||
|
|||
private static Mob mob; |
|||
|
|||
@BeforeAll |
|||
public static void setMob() { |
|||
mob = new Mob(); |
|||
mob.setFriendly(true); |
|||
mob.setDamage(0F); |
|||
mob.setHp(561.45F); |
|||
} |
|||
|
|||
|
|||
@Test |
|||
public void testFriendly() { |
|||
assertEquals(mob.isFriendly(), true); |
|||
} |
|||
|
|||
@Test |
|||
public void testDamage() { |
|||
assertEquals(mob.getDamage(), 0F); |
|||
} |
|||
|
|||
@Test |
|||
public void testHp() { |
|||
assertEquals(mob.getHp(), 561.45F); |
|||
} |
|||
} |
@ -0,0 +1,43 @@ |
|||
package org.bitbiome.entitiesTest; |
|||
|
|||
import static org.junit.jupiter.api.Assertions.assertEquals; |
|||
|
|||
import org.bitbiome.entities.Location; |
|||
import org.bitbiome.entities.Player; |
|||
import org.junit.jupiter.api.BeforeAll; |
|||
import org.junit.jupiter.api.Test; |
|||
|
|||
public class PlayerTest { |
|||
|
|||
private static Player player; |
|||
private static Location location; |
|||
|
|||
@BeforeAll |
|||
public static void setPlayer() { |
|||
player = new Player(); |
|||
location = new Location(); |
|||
|
|||
location.setName("NewUnitWorld"); |
|||
|
|||
player.setName("UnitPlayer"); |
|||
player.setLocation(location); |
|||
player.setHp(100F); |
|||
} |
|||
|
|||
@Test |
|||
public void testPlayerName() { |
|||
assertEquals("UnitPlayer", player.getName()); |
|||
} |
|||
|
|||
|
|||
@Test |
|||
public void testPlayerHp() { |
|||
assertEquals(100F, player.getHp()); |
|||
} |
|||
|
|||
@Test |
|||
public void testLocationNameFromPlayer() { |
|||
assertEquals("NewUnitWorld", player.getLocation().getName()); |
|||
} |
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue