From dc77373d072d6d09f0816d9368322a7c749ea91e Mon Sep 17 00:00:00 2001 From: Juliakn66 <117075450+Juliakn66@users.noreply.github.com> Date: Mon, 16 Jan 2023 10:14:20 +0100 Subject: [PATCH 01/47] refactoring: static to non-static method --- src/main/java/org/bitbiome/classes/JsonParser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/bitbiome/classes/JsonParser.java b/src/main/java/org/bitbiome/classes/JsonParser.java index be0e9b8..e63dd87 100644 --- a/src/main/java/org/bitbiome/classes/JsonParser.java +++ b/src/main/java/org/bitbiome/classes/JsonParser.java @@ -22,7 +22,7 @@ public class JsonParser { https://github.com/stleary/JSON-java */ - public static JSONObject getJSONObject(String fileName) { + public JSONObject getJSONObject(String fileName) { String resourceName = "./../../" + fileName; InputStream is = JsonParser.class.getResourceAsStream(resourceName); if (is == null) { From 666fa70a5241645a56c6e67e7da4edae2eae9aed Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 18 Jan 2023 18:08:06 +0100 Subject: [PATCH 02/47] Created item class --- src/main/java/org/bitbiome/classes/Item.java | 40 ++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/main/java/org/bitbiome/classes/Item.java diff --git a/src/main/java/org/bitbiome/classes/Item.java b/src/main/java/org/bitbiome/classes/Item.java new file mode 100644 index 0000000..4230728 --- /dev/null +++ b/src/main/java/org/bitbiome/classes/Item.java @@ -0,0 +1,40 @@ +package org.bitbiome.classes; + +public class Item { + + public String name; + public boolean doesDamage; + public float damage; + + + public Item(String name, boolean doesDamage, float damage) { + this.name = name; + this.doesDamage = doesDamage; + this.damage = damage; + } + + public String getName() { + return name; + } + + public float getDamage() { + return damage; + } + + public boolean doesDamage() { + return doesDamage; + } + + public void setName(String name) { + this.name = name; + } + + public void setDamage(float damage) { + this.damage = damage; + } + + public void changeDoesDamage(boolean doesDamage) { + this.doesDamage = doesDamage; + } + +} From 9a6f804563ce36d12c3388c167b681534051515e Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 18 Jan 2023 18:12:17 +0100 Subject: [PATCH 03/47] Created mob class --- src/main/java/org/bitbiome/classes/Mob.java | 47 +++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/main/java/org/bitbiome/classes/Mob.java diff --git a/src/main/java/org/bitbiome/classes/Mob.java b/src/main/java/org/bitbiome/classes/Mob.java new file mode 100644 index 0000000..f214d90 --- /dev/null +++ b/src/main/java/org/bitbiome/classes/Mob.java @@ -0,0 +1,47 @@ +package org.bitbiome.classes; + +public class Mob { + + private String name; + private boolean isFriendly; + + private float hp; + private float damage; + + public Mob(String name, boolean isFriendly, float hp, float damage) { + this.name = name; + this.isFriendly = isFriendly; + this.hp = hp; + this.damage = damage; + } + + public String getName() { + return name; + } + + public boolean isFriendly() { + return isFriendly; + } + + public float getHp() { + return hp; + } + + public float getDamage() { + return damage; + } + + public void setDamage(float damage) { + this.damage = damage; + } + + public void setHp(float hp) { + this.hp = hp; + } + + public void setFriendly(boolean isFriendly) { + this.isFriendly = isFriendly; + } + + +} From f1e40de850973da641a745881ec10929744ff98a Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 18 Jan 2023 18:14:45 +0100 Subject: [PATCH 04/47] Created location class --- .../java/org/bitbiome/classes/Location.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/main/java/org/bitbiome/classes/Location.java diff --git a/src/main/java/org/bitbiome/classes/Location.java b/src/main/java/org/bitbiome/classes/Location.java new file mode 100644 index 0000000..8d608cf --- /dev/null +++ b/src/main/java/org/bitbiome/classes/Location.java @@ -0,0 +1,33 @@ +package org.bitbiome.classes; + +import java.util.ArrayList; + +public class Location { + + private String name; + private ArrayList mobList; + private ArrayList itemList; + + + public Location(String name, ArrayList mobList, ArrayList itemList) { + this.name = name; + this.mobList = mobList; + this.itemList = itemList; + } + + + public String getName() { + return name; + } + + public ArrayList getMobList() { + return mobList; + } + + public ArrayList getItemList() { + return itemList; + } + + + +} From 20a461412839cf25a96ab66d65b84e6d24ba6428 Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 18 Jan 2023 18:25:03 +0100 Subject: [PATCH 05/47] Created class where locations can be created --- .../java/org/bitbiome/classes/CreateLocations.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/main/java/org/bitbiome/classes/CreateLocations.java diff --git a/src/main/java/org/bitbiome/classes/CreateLocations.java b/src/main/java/org/bitbiome/classes/CreateLocations.java new file mode 100644 index 0000000..7899f48 --- /dev/null +++ b/src/main/java/org/bitbiome/classes/CreateLocations.java @@ -0,0 +1,13 @@ +package org.bitbiome.classes; + +import java.util.ArrayList; + +public class CreateLocations { + + public static Location createForest() { + ArrayList items = new ArrayList<>(); + ArrayList mobs = new ArrayList<>(); + String name = "Wald"; + return new Location(name, mobs, items); + } +} From 6e24f5651ba4776c5cea8d5870d7de4a6fe17bdc Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 18 Jan 2023 18:25:14 +0100 Subject: [PATCH 06/47] Created player class --- .../java/org/bitbiome/classes/Player.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/main/java/org/bitbiome/classes/Player.java diff --git a/src/main/java/org/bitbiome/classes/Player.java b/src/main/java/org/bitbiome/classes/Player.java new file mode 100644 index 0000000..1090d7e --- /dev/null +++ b/src/main/java/org/bitbiome/classes/Player.java @@ -0,0 +1,51 @@ +package org.bitbiome.classes; + +import java.util.ArrayList; + +public class Player { + private String name; + private float hp; + private Location location; + + private ArrayList inventory; + + public Player(String name) { + this.name = name; + hp = 100.0F; + location = CreateLocations.createForest(); + inventory = new ArrayList<>(); + } + + public String getName() { + return name; + } + + public ArrayList getInventory() { + return inventory; + } + + public float getHp() { + return hp; + } + + public Location getLocation() { + return location; + } + + public void setLocation(Location location) { + this.location = location; + } + + public void setHp(float hp) { + this.hp = hp; + } + + public boolean addToInventory(Item item) { + return inventory.add(item); + } + + public boolean removeFromInventory(Item item) { + return inventory.remove(item); + } + +} From 20bc727d77f2cb6dd1d01af37cb3b25c7f2ba8be Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 18 Jan 2023 18:25:31 +0100 Subject: [PATCH 07/47] Created traveling engine --- .../java/org/bitbiome/classes/TravelEngine.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/main/java/org/bitbiome/classes/TravelEngine.java diff --git a/src/main/java/org/bitbiome/classes/TravelEngine.java b/src/main/java/org/bitbiome/classes/TravelEngine.java new file mode 100644 index 0000000..f02fa63 --- /dev/null +++ b/src/main/java/org/bitbiome/classes/TravelEngine.java @@ -0,0 +1,15 @@ +package org.bitbiome.classes; + +public class TravelEngine { + + private Location location; + + public TravelEngine() { + + } + + public void travelTo(Location location) { + this.location = location; + } + +} From a3722db6333cb3c667241529d9f44ff0e807ce33 Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 18 Jan 2023 18:28:10 +0100 Subject: [PATCH 08/47] refactoring: outsourced the entities in the entities package --- .../java/org/bitbiome/classes/CreateLocations.java | 4 ++++ src/main/java/org/bitbiome/classes/TravelEngine.java | 10 +++++++--- .../java/org/bitbiome/{classes => entities}/Item.java | 2 +- .../org/bitbiome/{classes => entities}/Location.java | 2 +- .../java/org/bitbiome/{classes => entities}/Mob.java | 2 +- .../org/bitbiome/{classes => entities}/Player.java | 4 +++- 6 files changed, 17 insertions(+), 7 deletions(-) rename src/main/java/org/bitbiome/{classes => entities}/Item.java (95%) rename src/main/java/org/bitbiome/{classes => entities}/Location.java (94%) rename src/main/java/org/bitbiome/{classes => entities}/Mob.java (96%) rename src/main/java/org/bitbiome/{classes => entities}/Player.java (92%) diff --git a/src/main/java/org/bitbiome/classes/CreateLocations.java b/src/main/java/org/bitbiome/classes/CreateLocations.java index 7899f48..5223fdf 100644 --- a/src/main/java/org/bitbiome/classes/CreateLocations.java +++ b/src/main/java/org/bitbiome/classes/CreateLocations.java @@ -1,5 +1,9 @@ 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 { diff --git a/src/main/java/org/bitbiome/classes/TravelEngine.java b/src/main/java/org/bitbiome/classes/TravelEngine.java index f02fa63..25fbc62 100644 --- a/src/main/java/org/bitbiome/classes/TravelEngine.java +++ b/src/main/java/org/bitbiome/classes/TravelEngine.java @@ -1,15 +1,19 @@ package org.bitbiome.classes; +import org.bitbiome.entities.Location; +import org.bitbiome.entities.Player; + public class TravelEngine { private Location location; + private Player player; - public TravelEngine() { - + public TravelEngine(Player player) { + this.player = player; } public void travelTo(Location location) { - this.location = location; + player.setLocation(location); } } diff --git a/src/main/java/org/bitbiome/classes/Item.java b/src/main/java/org/bitbiome/entities/Item.java similarity index 95% rename from src/main/java/org/bitbiome/classes/Item.java rename to src/main/java/org/bitbiome/entities/Item.java index 4230728..2817cd5 100644 --- a/src/main/java/org/bitbiome/classes/Item.java +++ b/src/main/java/org/bitbiome/entities/Item.java @@ -1,4 +1,4 @@ -package org.bitbiome.classes; +package org.bitbiome.entities; public class Item { diff --git a/src/main/java/org/bitbiome/classes/Location.java b/src/main/java/org/bitbiome/entities/Location.java similarity index 94% rename from src/main/java/org/bitbiome/classes/Location.java rename to src/main/java/org/bitbiome/entities/Location.java index 8d608cf..98c04d1 100644 --- a/src/main/java/org/bitbiome/classes/Location.java +++ b/src/main/java/org/bitbiome/entities/Location.java @@ -1,4 +1,4 @@ -package org.bitbiome.classes; +package org.bitbiome.entities; import java.util.ArrayList; diff --git a/src/main/java/org/bitbiome/classes/Mob.java b/src/main/java/org/bitbiome/entities/Mob.java similarity index 96% rename from src/main/java/org/bitbiome/classes/Mob.java rename to src/main/java/org/bitbiome/entities/Mob.java index f214d90..af479ce 100644 --- a/src/main/java/org/bitbiome/classes/Mob.java +++ b/src/main/java/org/bitbiome/entities/Mob.java @@ -1,4 +1,4 @@ -package org.bitbiome.classes; +package org.bitbiome.entities; public class Mob { diff --git a/src/main/java/org/bitbiome/classes/Player.java b/src/main/java/org/bitbiome/entities/Player.java similarity index 92% rename from src/main/java/org/bitbiome/classes/Player.java rename to src/main/java/org/bitbiome/entities/Player.java index 1090d7e..8f07072 100644 --- a/src/main/java/org/bitbiome/classes/Player.java +++ b/src/main/java/org/bitbiome/entities/Player.java @@ -1,4 +1,6 @@ -package org.bitbiome.classes; +package org.bitbiome.entities; + +import org.bitbiome.classes.CreateLocations; import java.util.ArrayList; From c8ea2a75fe4d49673ba4f92821701d7e971769df Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 18 Jan 2023 18:44:57 +0100 Subject: [PATCH 09/47] Added getPlayer method to the travel engine --- src/main/java/org/bitbiome/classes/TravelEngine.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/org/bitbiome/classes/TravelEngine.java b/src/main/java/org/bitbiome/classes/TravelEngine.java index 25fbc62..ec21dde 100644 --- a/src/main/java/org/bitbiome/classes/TravelEngine.java +++ b/src/main/java/org/bitbiome/classes/TravelEngine.java @@ -16,4 +16,8 @@ public class TravelEngine { player.setLocation(location); } + public Player getPlayer() { + return player; + } + } From 3cedb71e90dc9424af3e28b76e8163d5f4b133d4 Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 18 Jan 2023 18:45:35 +0100 Subject: [PATCH 10/47] Added the travel engine to the InteractionLoop --- src/main/java/org/bitbiome/Boot.java | 6 +++++- src/main/java/org/bitbiome/classes/InteractionLoop.java | 5 +++-- src/main/java/org/bitbiome/commands/CommandAPI.java | 4 +++- src/main/java/org/bitbiome/commands/CommandListener.java | 6 ++++-- src/main/java/org/bitbiome/commands/HelpCommand.java | 3 ++- src/main/java/org/bitbiome/commands/QuitCommand.java | 4 +++- 6 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/bitbiome/Boot.java b/src/main/java/org/bitbiome/Boot.java index b264413..9706de6 100644 --- a/src/main/java/org/bitbiome/Boot.java +++ b/src/main/java/org/bitbiome/Boot.java @@ -1,7 +1,9 @@ package org.bitbiome; import org.bitbiome.classes.InteractionLoop; +import org.bitbiome.classes.TravelEngine; import org.bitbiome.commands.CommandListener; +import org.bitbiome.entities.Player; public class Boot { @@ -11,7 +13,9 @@ public class Boot { instance = this; cmdListener = new CommandListener(); InteractionLoop game = new InteractionLoop(); - game.run(); + Player player = new Player("Dave"); + TravelEngine travelEngine = new TravelEngine(player); + game.run(travelEngine); } public CommandListener getCmdListener(){ diff --git a/src/main/java/org/bitbiome/classes/InteractionLoop.java b/src/main/java/org/bitbiome/classes/InteractionLoop.java index 6566b0a..879c345 100644 --- a/src/main/java/org/bitbiome/classes/InteractionLoop.java +++ b/src/main/java/org/bitbiome/classes/InteractionLoop.java @@ -8,11 +8,12 @@ public class InteractionLoop { Scanner input = new Scanner(System.in); - public void run() { + public void run(TravelEngine travelEngine) { boolean isRunning = true; + System.out.println("Willkommen zu BitBiome " + travelEngine.getPlayer().getName() + "!\n\n"); while (isRunning) { String line = input.nextLine().toLowerCase(); - if (!Boot.instance.getCmdListener().perform(line.toLowerCase().split(" ")[0], input, isRunning, line)) { + if (!Boot.instance.getCmdListener().perform(line.toLowerCase().split(" ")[0], input, isRunning, line, travelEngine)) { System.out.println("Unknown Command"); } } diff --git a/src/main/java/org/bitbiome/commands/CommandAPI.java b/src/main/java/org/bitbiome/commands/CommandAPI.java index d3a67c6..a5c48be 100644 --- a/src/main/java/org/bitbiome/commands/CommandAPI.java +++ b/src/main/java/org/bitbiome/commands/CommandAPI.java @@ -1,8 +1,10 @@ package org.bitbiome.commands; +import org.bitbiome.classes.TravelEngine; + import java.util.Scanner; public interface CommandAPI { - public void performCommand(Scanner scanner, boolean isRunning, String message); + public void performCommand(Scanner scanner, boolean isRunning, String message, TravelEngine travelEngine); } diff --git a/src/main/java/org/bitbiome/commands/CommandListener.java b/src/main/java/org/bitbiome/commands/CommandListener.java index 2e62105..d1dd278 100644 --- a/src/main/java/org/bitbiome/commands/CommandListener.java +++ b/src/main/java/org/bitbiome/commands/CommandListener.java @@ -1,5 +1,7 @@ package org.bitbiome.commands; +import org.bitbiome.classes.TravelEngine; + import java.util.HashMap; import java.util.Scanner; @@ -21,11 +23,11 @@ public class CommandListener { } - public boolean perform(String command, Scanner scanner, boolean isRunning, String message) { + public boolean perform(String command, Scanner scanner, boolean isRunning, String message, TravelEngine travelEngine) { CommandAPI cmd; if ((cmd = commands.get(command)) != null) { - cmd.performCommand(scanner, isRunning, message); + cmd.performCommand(scanner, isRunning, message, travelEngine); return true; } return false; diff --git a/src/main/java/org/bitbiome/commands/HelpCommand.java b/src/main/java/org/bitbiome/commands/HelpCommand.java index 4d88e3a..ce85922 100644 --- a/src/main/java/org/bitbiome/commands/HelpCommand.java +++ b/src/main/java/org/bitbiome/commands/HelpCommand.java @@ -1,6 +1,7 @@ package org.bitbiome.commands; import org.bitbiome.Boot; +import org.bitbiome.classes.TravelEngine; import java.util.HashMap; import java.util.Scanner; @@ -9,7 +10,7 @@ public class HelpCommand implements CommandAPI { @Override - public void performCommand(Scanner scanner, boolean isRunning, String message) { + public void performCommand(Scanner scanner, boolean isRunning, String message, TravelEngine travelEngine) { System.out.println(getHelpMessage()); } diff --git a/src/main/java/org/bitbiome/commands/QuitCommand.java b/src/main/java/org/bitbiome/commands/QuitCommand.java index d969852..25dbb00 100644 --- a/src/main/java/org/bitbiome/commands/QuitCommand.java +++ b/src/main/java/org/bitbiome/commands/QuitCommand.java @@ -1,11 +1,13 @@ package org.bitbiome.commands; +import org.bitbiome.classes.TravelEngine; + import java.util.Scanner; public class QuitCommand implements CommandAPI { @Override - public void performCommand(Scanner scanner, boolean isRunning, String message) { + public void performCommand(Scanner scanner, boolean isRunning, String message, TravelEngine travelEngine) { System.out.println(getQuitMessage()); System.exit(0); } From 201e2aa1fb739ff9db261c786c671bf24ae1eb6f Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 18 Jan 2023 18:55:52 +0100 Subject: [PATCH 11/47] Created class with ansi color codes --- .../java/org/bitbiome/classes/Colors.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/main/java/org/bitbiome/classes/Colors.java diff --git a/src/main/java/org/bitbiome/classes/Colors.java b/src/main/java/org/bitbiome/classes/Colors.java new file mode 100644 index 0000000..d08f59e --- /dev/null +++ b/src/main/java/org/bitbiome/classes/Colors.java @@ -0,0 +1,56 @@ +package org.bitbiome.classes; + +public class Colors { + + public static final String ANSI_RESET = "\u001B[0m"; + + public static final String ANSI_BLACK = "\u001B[30m"; + public static final String ANSI_RED = "\u001B[31m"; + public static final String ANSI_GREEN = "\u001B[32m"; + public static final String ANSI_YELLOW = "\u001B[33m"; + public static final String ANSI_BLUE = "\u001B[34m"; + public static final String ANSI_PURPLE = "\u001B[35m"; + public static final String ANSI_CYAN = "\u001B[36m"; + public static final String ANSI_WHITE = "\u001B[37m"; + + public static final String ANSI_BRIGHT_BLACK = "\u001B[90m"; + public static final String ANSI_BRIGHT_RED = "\u001B[91m"; + public static final String ANSI_BRIGHT_GREEN = "\u001B[92m"; + public static final String ANSI_BRIGHT_YELLOW = "\u001B[93m"; + public static final String ANSI_BRIGHT_BLUE = "\u001B[94m"; + public static final String ANSI_BRIGHT_PURPLE = "\u001B[95m"; + public static final String ANSI_BRIGHT_CYAN = "\u001B[96m"; + public static final String ANSI_BRIGHT_WHITE = "\u001B[97m"; + + public static final String[] FOREGROUNDS = { + ANSI_BLACK, ANSI_RED, ANSI_GREEN, ANSI_YELLOW, + ANSI_BLUE, ANSI_PURPLE, ANSI_CYAN, ANSI_WHITE, + ANSI_BRIGHT_BLACK, ANSI_BRIGHT_RED, ANSI_BRIGHT_GREEN, ANSI_BRIGHT_YELLOW, + ANSI_BRIGHT_BLUE, ANSI_BRIGHT_PURPLE, ANSI_BRIGHT_CYAN, ANSI_BRIGHT_WHITE + }; + + public static final String ANSI_BG_BLACK = "\u001B[40m"; + public static final String ANSI_BG_RED = "\u001B[41m"; + public static final String ANSI_BG_GREEN = "\u001B[42m"; + public static final String ANSI_BG_YELLOW = "\u001B[43m"; + public static final String ANSI_BG_BLUE = "\u001B[44m"; + public static final String ANSI_BG_PURPLE = "\u001B[45m"; + public static final String ANSI_BG_CYAN = "\u001B[46m"; + public static final String ANSI_BG_WHITE = "\u001B[47m"; + + public static final String ANSI_BRIGHT_BG_BLACK = "\u001B[100m"; + public static final String ANSI_BRIGHT_BG_RED = "\u001B[101m"; + public static final String ANSI_BRIGHT_BG_GREEN = "\u001B[102m"; + public static final String ANSI_BRIGHT_BG_YELLOW = "\u001B[103m"; + public static final String ANSI_BRIGHT_BG_BLUE = "\u001B[104m"; + public static final String ANSI_BRIGHT_BG_PURPLE = "\u001B[105m"; + public static final String ANSI_BRIGHT_BG_CYAN = "\u001B[106m"; + public static final String ANSI_BRIGHT_BG_WHITE = "\u001B[107m"; + + public static final String[] BACKGROUNDS = { + ANSI_BG_BLACK, ANSI_BG_RED, ANSI_BG_GREEN, ANSI_BG_YELLOW, + ANSI_BG_BLUE, ANSI_BG_PURPLE, ANSI_BG_CYAN, ANSI_BG_WHITE, + ANSI_BRIGHT_BG_BLACK, ANSI_BRIGHT_BG_RED, ANSI_BRIGHT_BG_GREEN, ANSI_BRIGHT_BG_YELLOW, + ANSI_BRIGHT_BG_BLUE, ANSI_BRIGHT_BG_PURPLE, ANSI_BRIGHT_BG_CYAN, ANSI_BRIGHT_BG_WHITE }; + +} From 157ceabc59f7473671646ce2d213005746065c68 Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 18 Jan 2023 19:32:30 +0100 Subject: [PATCH 12/47] Edited TravelEngine, added getLocationList and locationExist method --- .../org/bitbiome/classes/TravelEngine.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/bitbiome/classes/TravelEngine.java b/src/main/java/org/bitbiome/classes/TravelEngine.java index ec21dde..26a84a1 100644 --- a/src/main/java/org/bitbiome/classes/TravelEngine.java +++ b/src/main/java/org/bitbiome/classes/TravelEngine.java @@ -2,13 +2,19 @@ package org.bitbiome.classes; import org.bitbiome.entities.Location; import org.bitbiome.entities.Player; +import org.json.JSONArray; + +import java.util.ArrayList; public class TravelEngine { - private Location location; + private JSONArray locations; + JsonParser jp; private Player player; public TravelEngine(Player player) { + jp = new JsonParser(); + locations = jp.getJSONObject("../gameconfig.json").getJSONArray("locations"); this.player = player; } @@ -20,4 +26,17 @@ public class TravelEngine { return player; } + public JSONArray getLocationList() { + return locations; + } + + public boolean locationExists(String name) { + boolean found = false; + for (int i = 0; i < locations.length(); i++) + if (locations.getJSONObject(i).getString("name").equals(name)) { + found = true; + } + return found; + } + } From 456b7d8c5994d5701ff6fa6361a78cc377edbacf Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 18 Jan 2023 19:32:41 +0100 Subject: [PATCH 13/47] Added beach to the gameconfig.json --- src/main/resources/gameconfig.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/resources/gameconfig.json b/src/main/resources/gameconfig.json index a29ef19..cb08775 100644 --- a/src/main/resources/gameconfig.json +++ b/src/main/resources/gameconfig.json @@ -33,6 +33,23 @@ ] } ] + }, + { + "name": "Strand", + "items": [ + "Holz", + "Stein" + ], + "mobs": [ + { + "name": "Big Foot", + "hp": 50, + "damage": "10-15", + "items": [ + "Fell" + ] + } + ] } ] } \ No newline at end of file From a9f0ec154b29d75976d1342b74af6cba23550039 Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 18 Jan 2023 19:32:55 +0100 Subject: [PATCH 14/47] Added createBeach method to createLocations class --- src/main/java/org/bitbiome/classes/CreateLocations.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/org/bitbiome/classes/CreateLocations.java b/src/main/java/org/bitbiome/classes/CreateLocations.java index 5223fdf..ed237a1 100644 --- a/src/main/java/org/bitbiome/classes/CreateLocations.java +++ b/src/main/java/org/bitbiome/classes/CreateLocations.java @@ -14,4 +14,11 @@ public class CreateLocations { String name = "Wald"; return new Location(name, mobs, items); } + + public static Location createBeach() { + ArrayList items = new ArrayList<>(); + ArrayList mobs = new ArrayList<>(); + String name = "Strand"; + return new Location(name, mobs, items); + } } From 06d01e97b44c433bb9c787002b7347bdb220a181 Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 18 Jan 2023 19:44:37 +0100 Subject: [PATCH 15/47] Added location command to get the current location of the player --- .../java/org/bitbiome/commands/CommandListener.java | 1 + .../java/org/bitbiome/commands/LocationCommand.java | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 src/main/java/org/bitbiome/commands/LocationCommand.java diff --git a/src/main/java/org/bitbiome/commands/CommandListener.java b/src/main/java/org/bitbiome/commands/CommandListener.java index d1dd278..b1a5378 100644 --- a/src/main/java/org/bitbiome/commands/CommandListener.java +++ b/src/main/java/org/bitbiome/commands/CommandListener.java @@ -16,6 +16,7 @@ public class CommandListener { commands.put("exit", new QuitCommand()); commands.put("quit", new QuitCommand()); + commands.put("location", new LocationCommand()); } public HashMap returnCommands() { diff --git a/src/main/java/org/bitbiome/commands/LocationCommand.java b/src/main/java/org/bitbiome/commands/LocationCommand.java new file mode 100644 index 0000000..5b690d0 --- /dev/null +++ b/src/main/java/org/bitbiome/commands/LocationCommand.java @@ -0,0 +1,13 @@ +package org.bitbiome.commands; + +import org.bitbiome.classes.TravelEngine; + +import java.util.Scanner; + +public class LocationCommand implements CommandAPI{ + + @Override + public void performCommand(Scanner scanner, boolean isRunning, String message, TravelEngine travelEngine) { + System.out.println("Du befindest dich gerade hier: " + travelEngine.getPlayer().getLocation().getName()); + } +} From 48af98341b5989d992e972d02e36c1395d4d2dfc Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 18 Jan 2023 19:45:26 +0100 Subject: [PATCH 16/47] Added Travel command, to travel to different places --- .../bitbiome/commands/CommandListener.java | 1 + .../org/bitbiome/commands/TravelCommand.java | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/main/java/org/bitbiome/commands/TravelCommand.java diff --git a/src/main/java/org/bitbiome/commands/CommandListener.java b/src/main/java/org/bitbiome/commands/CommandListener.java index b1a5378..d59813c 100644 --- a/src/main/java/org/bitbiome/commands/CommandListener.java +++ b/src/main/java/org/bitbiome/commands/CommandListener.java @@ -17,6 +17,7 @@ public class CommandListener { commands.put("exit", new QuitCommand()); commands.put("quit", new QuitCommand()); commands.put("location", new LocationCommand()); + commands.put("travel", new TravelCommand()); } public HashMap returnCommands() { diff --git a/src/main/java/org/bitbiome/commands/TravelCommand.java b/src/main/java/org/bitbiome/commands/TravelCommand.java new file mode 100644 index 0000000..ca68bf5 --- /dev/null +++ b/src/main/java/org/bitbiome/commands/TravelCommand.java @@ -0,0 +1,33 @@ +package org.bitbiome.commands; + +import org.bitbiome.classes.Colors; +import org.bitbiome.classes.CreateLocations; +import org.bitbiome.classes.TravelEngine; +import org.bitbiome.entities.Item; +import org.bitbiome.entities.Location; +import org.bitbiome.entities.Mob; +import org.json.JSONArray; + +import java.util.ArrayList; +import java.util.Scanner; + + +public class TravelCommand implements CommandAPI { + + @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(); + for (int i = 0; i < locations.length(); i++) { + System.out.println("- " + locations.getJSONObject(i).getString("name")); + } + + String locationName = scanner.nextLine(); + if (travelEngine.locationExists(locationName)) { + travelEngine.travelTo(new Location(locationName, new ArrayList(), new ArrayList())); + 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); + } + } +} From c18cb6190aa674351719c81b4e51e9deebc97be4 Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 18 Jan 2023 19:52:22 +0100 Subject: [PATCH 17/47] refactoring: outsourced current location message --- src/main/java/org/bitbiome/commands/LocationCommand.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/bitbiome/commands/LocationCommand.java b/src/main/java/org/bitbiome/commands/LocationCommand.java index 5b690d0..cbbca02 100644 --- a/src/main/java/org/bitbiome/commands/LocationCommand.java +++ b/src/main/java/org/bitbiome/commands/LocationCommand.java @@ -8,6 +8,11 @@ public class LocationCommand implements CommandAPI{ @Override public void performCommand(Scanner scanner, boolean isRunning, String message, TravelEngine travelEngine) { - System.out.println("Du befindest dich gerade hier: " + travelEngine.getPlayer().getLocation().getName()); + System.out.println(getLocationMessage(travelEngine)); + } + + + public static String getLocationMessage(TravelEngine travelEngine) { + return "Du befindest dich gerade hier: " + travelEngine.getPlayer().getLocation().getName(); } } From ec70ab4803b82d109a585892b70208379846564d Mon Sep 17 00:00:00 2001 From: David Hermann Date: Mon, 23 Jan 2023 19:52:36 +0100 Subject: [PATCH 18/47] Summary Commit Boot.java: Added getPlayerSave() InteractionLoop: Asks for name if the player's name is null JsonParser: New method writeObject Travel Engine: getLocationByName() method Edited Help Command Added setter for Player's name New Quiz questions Edited Help unit test Added unit test for Location Command --- src/main/java/org/bitbiome/Boot.java | 12 +- .../org/bitbiome/classes/InteractionLoop.java | 13 +- .../java/org/bitbiome/classes/JsonParser.java | 23 +- .../org/bitbiome/classes/TravelEngine.java | 31 ++- .../org/bitbiome/commands/HelpCommand.java | 14 +- .../java/org/bitbiome/entities/Player.java | 10 +- src/main/resources/quiz.json | 204 ++++++++++++++++++ .../bitbiome/commands/HelpCommandTest.java | 17 +- .../commands/LocationCommandTest.java | 22 ++ 9 files changed, 336 insertions(+), 10 deletions(-) create mode 100644 src/main/resources/quiz.json create mode 100644 src/test/java/org/bitbiome/commands/LocationCommandTest.java diff --git a/src/main/java/org/bitbiome/Boot.java b/src/main/java/org/bitbiome/Boot.java index 9706de6..0f5ebdd 100644 --- a/src/main/java/org/bitbiome/Boot.java +++ b/src/main/java/org/bitbiome/Boot.java @@ -1,9 +1,11 @@ package org.bitbiome; import org.bitbiome.classes.InteractionLoop; +import org.bitbiome.classes.JsonParser; import org.bitbiome.classes.TravelEngine; import org.bitbiome.commands.CommandListener; import org.bitbiome.entities.Player; +import org.json.JSONObject; public class Boot { @@ -13,7 +15,7 @@ public class Boot { instance = this; cmdListener = new CommandListener(); InteractionLoop game = new InteractionLoop(); - Player player = new Player("Dave"); + Player player = getPlayerSave(); TravelEngine travelEngine = new TravelEngine(player); game.run(travelEngine); } @@ -22,6 +24,14 @@ public class Boot { return cmdListener; } + private Player getPlayerSave() { + String name; + JsonParser jp = new JsonParser(); + JSONObject playerconfig = jp.getJSONObject("playerconfig.json"); + name = playerconfig.getString("name"); + return new Player(name); + } + } diff --git a/src/main/java/org/bitbiome/classes/InteractionLoop.java b/src/main/java/org/bitbiome/classes/InteractionLoop.java index 879c345..2523644 100644 --- a/src/main/java/org/bitbiome/classes/InteractionLoop.java +++ b/src/main/java/org/bitbiome/classes/InteractionLoop.java @@ -1,7 +1,7 @@ package org.bitbiome.classes; import org.bitbiome.Boot; - +import org.json.JSONObject; import java.util.Scanner; public class InteractionLoop { @@ -10,7 +10,16 @@ public class InteractionLoop { public void run(TravelEngine travelEngine) { boolean isRunning = true; - System.out.println("Willkommen zu BitBiome " + travelEngine.getPlayer().getName() + "!\n\n"); + if (travelEngine.getPlayer().getName().equals("null")) { + System.out.println(Colors.ANSI_BLUE + "Oh, ein Fremder!\nBist du bereit für dein womöglich größtes Abenteuer?\nDann sag mir doch zunächst wie du heißt: " + Colors.ANSI_RESET); + String name = input.nextLine(); + JsonParser jp = new JsonParser(); + JSONObject playerconf = jp.getJSONObject("playerconfig.json"); + playerconf.put("name", name); + travelEngine.getPlayer().setName(name); + jp.writeObject("playerconfig.json", playerconf); + } + System.out.println(Colors.ANSI_BG_CYAN + Colors.ANSI_BLACK + "Willkommen zu BitBiome " + travelEngine.getPlayer().getName() + "!" + Colors.ANSI_RESET + "\n\n"); while (isRunning) { String line = input.nextLine().toLowerCase(); if (!Boot.instance.getCmdListener().perform(line.toLowerCase().split(" ")[0], input, isRunning, line, travelEngine)) { diff --git a/src/main/java/org/bitbiome/classes/JsonParser.java b/src/main/java/org/bitbiome/classes/JsonParser.java index e63dd87..0eb23d5 100644 --- a/src/main/java/org/bitbiome/classes/JsonParser.java +++ b/src/main/java/org/bitbiome/classes/JsonParser.java @@ -2,8 +2,14 @@ package org.bitbiome.classes; import org.json.JSONObject; import org.json.JSONTokener; +import org.json.JSONWriter; +import java.io.FileWriter; +import java.io.IOException; import java.io.InputStream; +import java.io.StringWriter; + + public class JsonParser { @@ -23,14 +29,27 @@ public class JsonParser { */ public JSONObject getJSONObject(String fileName) { - String resourceName = "./../../" + fileName; + String resourceName = "./../../../" + fileName; InputStream is = JsonParser.class.getResourceAsStream(resourceName); if (is == null) { throw new NullPointerException("Cannot find resource file " + resourceName); } JSONTokener tokener = new JSONTokener(is); - return new JSONObject(tokener); } + + public void writeObject(String fileName, JSONObject object) { + + String resourceName = System.getProperty("user.dir") + "/src/main/resources/" + fileName; + try { + FileWriter fw = new FileWriter(resourceName, false); + fw.write(object.toString(1)); + fw.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + + + } } diff --git a/src/main/java/org/bitbiome/classes/TravelEngine.java b/src/main/java/org/bitbiome/classes/TravelEngine.java index 26a84a1..a8d3213 100644 --- a/src/main/java/org/bitbiome/classes/TravelEngine.java +++ b/src/main/java/org/bitbiome/classes/TravelEngine.java @@ -3,23 +3,28 @@ package org.bitbiome.classes; import org.bitbiome.entities.Location; import org.bitbiome.entities.Player; import org.json.JSONArray; +import org.json.JSONObject; import java.util.ArrayList; public class TravelEngine { private JSONArray locations; - JsonParser jp; + private JsonParser jp; private Player player; public TravelEngine(Player player) { jp = new JsonParser(); - locations = jp.getJSONObject("../gameconfig.json").getJSONArray("locations"); + locations = jp.getJSONObject("gameconfig.json").getJSONArray("locations"); this.player = player; } public void travelTo(Location location) { player.setLocation(location); + JSONObject jObj = jp.getJSONObject("playerconfig.json"); + jObj.put("currentLocation", location.getName()); + + jp.writeObject("playerconfig.json", jObj); } public Player getPlayer() { @@ -39,4 +44,26 @@ public class TravelEngine { return found; } + public Location getLocationByName(String name) { + JsonParser jp = new JsonParser(); + JSONObject gameconfig = jp.getJSONObject("gameconfig.json"); + JSONArray locations = gameconfig.getJSONArray("locations"); + JSONObject location = null; + if (locationExists(name)) { + for (int i = 0; i < locations.length(); i++) { + if (locations.getJSONObject(i).getString("name").equals(name)) { + location = locations.getJSONObject(i); + } + } + assert location != null; + //TODO Create Location by name and add mobs and times to the location + JSONArray items = location.getJSONArray("items"); + JSONArray mobs = location.getJSONArray("mobs"); + System.out.println(items.toString(1)); + System.out.println(mobs.toString(1)); + return new Location(name, new ArrayList<>(), new ArrayList<>()); + } else { + return null; + } + } } diff --git a/src/main/java/org/bitbiome/commands/HelpCommand.java b/src/main/java/org/bitbiome/commands/HelpCommand.java index ce85922..90702cc 100644 --- a/src/main/java/org/bitbiome/commands/HelpCommand.java +++ b/src/main/java/org/bitbiome/commands/HelpCommand.java @@ -1,6 +1,7 @@ package org.bitbiome.commands; import org.bitbiome.Boot; +import org.bitbiome.classes.Colors; import org.bitbiome.classes.TravelEngine; import java.util.HashMap; @@ -16,7 +17,18 @@ public class HelpCommand implements CommandAPI { public static String getHelpMessage() { StringBuilder outputMessage = new StringBuilder(); - outputMessage.append("Hier ist eine Liste der Commands:\n").append("- help -> Gibt diese Nachricht aus\n").append("- exit/quit -> Beendet das Spiel\n"); + outputMessage + .append("|______________|_____________________________|\n") + .append("|" + Colors.ANSI_PURPLE + " Command" + Colors.ANSI_RESET + " | " + Colors.ANSI_PURPLE + "Description" + Colors.ANSI_RESET + " |\n") + .append("|--------------|-----------------------------|\n") + .append("|" + Colors.ANSI_GREEN + " help" + Colors.ANSI_RESET + " | Gibt diese Nachricht aus |\n") + .append("|--------------|-----------------------------|\n") + .append("|" + Colors.ANSI_GREEN + " exit/quit" + Colors.ANSI_RESET + " | Beendet das Spiel |\n") + .append("|--------------|-----------------------------|\n") + .append("|" + Colors.ANSI_GREEN + " travel" + Colors.ANSI_RESET + " | Startet das Reise System |\n") + .append("|--------------|-----------------------------|\n") + .append("|" + Colors.ANSI_GREEN + " location" + Colors.ANSI_RESET + " | Gibt deine Location aus |\n") + .append("|______________|_____________________________|\n"); return outputMessage.toString(); } diff --git a/src/main/java/org/bitbiome/entities/Player.java b/src/main/java/org/bitbiome/entities/Player.java index 8f07072..6fe3152 100644 --- a/src/main/java/org/bitbiome/entities/Player.java +++ b/src/main/java/org/bitbiome/entities/Player.java @@ -1,6 +1,7 @@ package org.bitbiome.entities; import org.bitbiome.classes.CreateLocations; +import org.bitbiome.classes.JsonParser; import java.util.ArrayList; @@ -11,10 +12,13 @@ public class Player { private ArrayList inventory; + private JsonParser jp; + public Player(String name) { + jp = new JsonParser(); this.name = name; hp = 100.0F; - location = CreateLocations.createForest(); + location = new Location(jp.getJSONObject("playerconfig.json").getString("currentLocation"), new ArrayList<>(), new ArrayList<>()); inventory = new ArrayList<>(); } @@ -50,4 +54,8 @@ public class Player { return inventory.remove(item); } + public void setName(String name) { + this.name = name; + } + } diff --git a/src/main/resources/quiz.json b/src/main/resources/quiz.json new file mode 100644 index 0000000..cc58a3f --- /dev/null +++ b/src/main/resources/quiz.json @@ -0,0 +1,204 @@ +{ + "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" + } + ] +} \ No newline at end of file diff --git a/src/test/java/org/bitbiome/commands/HelpCommandTest.java b/src/test/java/org/bitbiome/commands/HelpCommandTest.java index 75006ed..dab4d90 100644 --- a/src/test/java/org/bitbiome/commands/HelpCommandTest.java +++ b/src/test/java/org/bitbiome/commands/HelpCommandTest.java @@ -1,14 +1,29 @@ package org.bitbiome.commands; +import org.bitbiome.classes.Colors; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class HelpCommandTest { @Test public void testHelpCommand() { String helpMessage = HelpCommand.getHelpMessage(); - assertEquals("Hier ist eine Liste der Commands:\n- help -> Gibt diese Nachricht aus\n- exit/quit -> Beendet das Spiel\n", helpMessage); + StringBuilder outputMessage = new StringBuilder(); + outputMessage + .append("|______________|_____________________________|\n") + .append("|" + Colors.ANSI_PURPLE + " Command" + Colors.ANSI_RESET + " | " + Colors.ANSI_PURPLE + "Description" + Colors.ANSI_RESET + " |\n") + .append("|--------------|-----------------------------|\n") + .append("|" + Colors.ANSI_GREEN + " help" + Colors.ANSI_RESET + " | Gibt diese Nachricht aus |\n") + .append("|--------------|-----------------------------|\n") + .append("|" + Colors.ANSI_GREEN + " exit/quit" + Colors.ANSI_RESET + " | Beendet das Spiel |\n") + .append("|--------------|-----------------------------|\n") + .append("|" + Colors.ANSI_GREEN + " travel" + Colors.ANSI_RESET + " | Startet das Reise System |\n") + .append("|--------------|-----------------------------|\n") + .append("|" + Colors.ANSI_GREEN + " location" + Colors.ANSI_RESET + " | Gibt deine Location aus |\n") + .append("|______________|_____________________________|\n"); + assertEquals(outputMessage.toString(), helpMessage); } diff --git a/src/test/java/org/bitbiome/commands/LocationCommandTest.java b/src/test/java/org/bitbiome/commands/LocationCommandTest.java new file mode 100644 index 0000000..23c6541 --- /dev/null +++ b/src/test/java/org/bitbiome/commands/LocationCommandTest.java @@ -0,0 +1,22 @@ +package org.bitbiome.commands; + +import org.bitbiome.classes.TravelEngine; +import org.bitbiome.entities.Player; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.Arrays; + +public class LocationCommandTest { + + @Test + public void testLocationCommand() { + Player p = new Player("Unit"); + TravelEngine tE = new TravelEngine(p); + String[] standorte = {"Wald", "Strand"}; + String locationMessage = LocationCommand.getLocationMessage(tE).split(": ")[1]; + assertTrue(Arrays.asList(standorte).contains(locationMessage)); + } + +} From 67822c0a8e9196d2fd4eef9a7e537420b47ac3dd Mon Sep 17 00:00:00 2001 From: David Hermann Date: Sat, 28 Jan 2023 13:18:56 +0100 Subject: [PATCH 19/47] refactoring: Deleted unused imports --- src/main/java/org/bitbiome/classes/JsonParser.java | 2 -- src/main/java/org/bitbiome/commands/HelpCommand.java | 4 ++-- src/main/java/org/bitbiome/commands/TravelCommand.java | 2 +- src/main/java/org/bitbiome/entities/Player.java | 2 +- src/test/java/org/bitbiome/commands/HelpCommandTest.java | 2 +- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/bitbiome/classes/JsonParser.java b/src/main/java/org/bitbiome/classes/JsonParser.java index 0eb23d5..45111ef 100644 --- a/src/main/java/org/bitbiome/classes/JsonParser.java +++ b/src/main/java/org/bitbiome/classes/JsonParser.java @@ -2,12 +2,10 @@ package org.bitbiome.classes; import org.json.JSONObject; import org.json.JSONTokener; -import org.json.JSONWriter; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; -import java.io.StringWriter; diff --git a/src/main/java/org/bitbiome/commands/HelpCommand.java b/src/main/java/org/bitbiome/commands/HelpCommand.java index 90702cc..ee4f237 100644 --- a/src/main/java/org/bitbiome/commands/HelpCommand.java +++ b/src/main/java/org/bitbiome/commands/HelpCommand.java @@ -1,10 +1,10 @@ package org.bitbiome.commands; -import org.bitbiome.Boot; + import org.bitbiome.classes.Colors; import org.bitbiome.classes.TravelEngine; -import java.util.HashMap; + import java.util.Scanner; public class HelpCommand implements CommandAPI { diff --git a/src/main/java/org/bitbiome/commands/TravelCommand.java b/src/main/java/org/bitbiome/commands/TravelCommand.java index ca68bf5..da5cbe7 100644 --- a/src/main/java/org/bitbiome/commands/TravelCommand.java +++ b/src/main/java/org/bitbiome/commands/TravelCommand.java @@ -1,7 +1,7 @@ package org.bitbiome.commands; import org.bitbiome.classes.Colors; -import org.bitbiome.classes.CreateLocations; + import org.bitbiome.classes.TravelEngine; import org.bitbiome.entities.Item; import org.bitbiome.entities.Location; diff --git a/src/main/java/org/bitbiome/entities/Player.java b/src/main/java/org/bitbiome/entities/Player.java index 6fe3152..ff8dffb 100644 --- a/src/main/java/org/bitbiome/entities/Player.java +++ b/src/main/java/org/bitbiome/entities/Player.java @@ -1,6 +1,6 @@ package org.bitbiome.entities; -import org.bitbiome.classes.CreateLocations; + import org.bitbiome.classes.JsonParser; import java.util.ArrayList; diff --git a/src/test/java/org/bitbiome/commands/HelpCommandTest.java b/src/test/java/org/bitbiome/commands/HelpCommandTest.java index dab4d90..5caac07 100644 --- a/src/test/java/org/bitbiome/commands/HelpCommandTest.java +++ b/src/test/java/org/bitbiome/commands/HelpCommandTest.java @@ -3,7 +3,7 @@ package org.bitbiome.commands; import org.bitbiome.classes.Colors; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; + public class HelpCommandTest { From c7b8855442a315e34ba71f46e954020f897d0199 Mon Sep 17 00:00:00 2001 From: David Hermann Date: Sat, 28 Jan 2023 13:29:02 +0100 Subject: [PATCH 20/47] refactoring: Language change, added color When a command is unkown, the language is now german and the message is red. --- src/main/java/org/bitbiome/classes/InteractionLoop.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/bitbiome/classes/InteractionLoop.java b/src/main/java/org/bitbiome/classes/InteractionLoop.java index 2523644..d5c4c98 100644 --- a/src/main/java/org/bitbiome/classes/InteractionLoop.java +++ b/src/main/java/org/bitbiome/classes/InteractionLoop.java @@ -3,6 +3,8 @@ package org.bitbiome.classes; import org.bitbiome.Boot; import org.json.JSONObject; import java.util.Scanner; +import org.bitbiome.classes.Colors; + public class InteractionLoop { @@ -23,7 +25,7 @@ public class InteractionLoop { while (isRunning) { String line = input.nextLine().toLowerCase(); if (!Boot.instance.getCmdListener().perform(line.toLowerCase().split(" ")[0], input, isRunning, line, travelEngine)) { - System.out.println("Unknown Command"); + System.out.println(Colors.ANSI_RED + "Unbekannter Befehl - Siehe " + Colors.ANSI_PURPLE + "help\n" + Colors.ANSI_RESET); } } } From d09e3b1c2dd3497cfede95753332600562ed0964 Mon Sep 17 00:00:00 2001 From: David Hermann Date: Sat, 28 Jan 2023 13:33:21 +0100 Subject: [PATCH 21/47] refactoring: Removed unused imports --- src/main/java/org/bitbiome/classes/InteractionLoop.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/bitbiome/classes/InteractionLoop.java b/src/main/java/org/bitbiome/classes/InteractionLoop.java index d5c4c98..a0b5017 100644 --- a/src/main/java/org/bitbiome/classes/InteractionLoop.java +++ b/src/main/java/org/bitbiome/classes/InteractionLoop.java @@ -3,7 +3,6 @@ package org.bitbiome.classes; import org.bitbiome.Boot; import org.json.JSONObject; import java.util.Scanner; -import org.bitbiome.classes.Colors; public class InteractionLoop { From ce6247312e943b4e1d1eae3a62594745aef06ca1 Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 1 Feb 2023 19:43:06 +0100 Subject: [PATCH 22/47] Update Item.java Changed the privacy of the variables Added empty constructor for unit tests --- src/main/java/org/bitbiome/entities/Item.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/bitbiome/entities/Item.java b/src/main/java/org/bitbiome/entities/Item.java index 2817cd5..0ded3ff 100644 --- a/src/main/java/org/bitbiome/entities/Item.java +++ b/src/main/java/org/bitbiome/entities/Item.java @@ -2,9 +2,9 @@ package org.bitbiome.entities; public class Item { - public String name; - public boolean doesDamage; - public float damage; + private String name; + private boolean doesDamage; + private float damage; public Item(String name, boolean doesDamage, float damage) { @@ -13,6 +13,10 @@ public class Item { this.damage = damage; } + public Item() { + + } + public String getName() { return name; } From 5e723f41b3afbc014dfc3aedfb4d6b0259444cb6 Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 1 Feb 2023 19:43:27 +0100 Subject: [PATCH 23/47] Update Location.java Added empty constructor for unit tests Added setName() method for unit tests --- src/main/java/org/bitbiome/entities/Location.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/org/bitbiome/entities/Location.java b/src/main/java/org/bitbiome/entities/Location.java index 98c04d1..664509d 100644 --- a/src/main/java/org/bitbiome/entities/Location.java +++ b/src/main/java/org/bitbiome/entities/Location.java @@ -15,6 +15,10 @@ public class Location { this.itemList = itemList; } + public Location() { + + } + public String getName() { return name; @@ -28,6 +32,10 @@ public class Location { return itemList; } + public void setName(String name) { + this.name = name; + } + } From 7131083fd9a97e583ea3542b49452c3c5233dda3 Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 1 Feb 2023 19:43:46 +0100 Subject: [PATCH 24/47] Update Mob.java Added empty constructor for unit tests --- src/main/java/org/bitbiome/entities/Mob.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/org/bitbiome/entities/Mob.java b/src/main/java/org/bitbiome/entities/Mob.java index af479ce..4bb0d03 100644 --- a/src/main/java/org/bitbiome/entities/Mob.java +++ b/src/main/java/org/bitbiome/entities/Mob.java @@ -15,6 +15,10 @@ public class Mob { this.damage = damage; } + public Mob() { + + } + public String getName() { return name; } From 62ddc0bd3ce33994843d12f2c29915f47e66dabc Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 1 Feb 2023 19:43:56 +0100 Subject: [PATCH 25/47] Update Player.java Added empty constructor for unit tests --- src/main/java/org/bitbiome/entities/Player.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/org/bitbiome/entities/Player.java b/src/main/java/org/bitbiome/entities/Player.java index ff8dffb..3d46e17 100644 --- a/src/main/java/org/bitbiome/entities/Player.java +++ b/src/main/java/org/bitbiome/entities/Player.java @@ -22,6 +22,10 @@ public class Player { inventory = new ArrayList<>(); } + public Player() { + + } + public String getName() { return name; } From 56fb3c546cb826871798f4688f1a62bfb91d5747 Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 1 Feb 2023 19:51:18 +0100 Subject: [PATCH 26/47] unittest: created test for item class This is testing the name of the item --- .../org/bitbiome/entitiesTest/ItemTest.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/test/java/org/bitbiome/entitiesTest/ItemTest.java diff --git a/src/test/java/org/bitbiome/entitiesTest/ItemTest.java b/src/test/java/org/bitbiome/entitiesTest/ItemTest.java new file mode 100644 index 0000000..56335cc --- /dev/null +++ b/src/test/java/org/bitbiome/entitiesTest/ItemTest.java @@ -0,0 +1,23 @@ +package org.bitbiome.entitiesTest; +import static org.junit.jupiter.api.Assertions.assertEquals; + +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"); + } + + @Test + public void testGetName() { + assertEquals("Unit", item.getName()); + } +} From 8a380d1ef3e81db1dd79392744fed716a4e0202b Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 1 Feb 2023 20:02:21 +0100 Subject: [PATCH 27/47] unittest: updated item test This additionally tests the damage of the items --- src/test/java/org/bitbiome/entitiesTest/ItemTest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/test/java/org/bitbiome/entitiesTest/ItemTest.java b/src/test/java/org/bitbiome/entitiesTest/ItemTest.java index 56335cc..ef6093c 100644 --- a/src/test/java/org/bitbiome/entitiesTest/ItemTest.java +++ b/src/test/java/org/bitbiome/entitiesTest/ItemTest.java @@ -14,10 +14,16 @@ public class ItemTest { public static void setItem() { item = new Item(); item.setName("Unit"); + item.setDamage(12.5F); } @Test public void testGetName() { assertEquals("Unit", item.getName()); } + + @Test + public void testGetDamage() { + assertEquals(12.5, item.getDamage()); + } } From 432c37c27826acabcada79ed58222c9d7147af9f Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 1 Feb 2023 20:07:24 +0100 Subject: [PATCH 28/47] unittest: updated item test This additionally tests whether the item does any damage at all. --- src/test/java/org/bitbiome/entitiesTest/ItemTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/test/java/org/bitbiome/entitiesTest/ItemTest.java b/src/test/java/org/bitbiome/entitiesTest/ItemTest.java index ef6093c..4214043 100644 --- a/src/test/java/org/bitbiome/entitiesTest/ItemTest.java +++ b/src/test/java/org/bitbiome/entitiesTest/ItemTest.java @@ -1,5 +1,6 @@ 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; @@ -15,6 +16,7 @@ public class ItemTest { item = new Item(); item.setName("Unit"); item.setDamage(12.5F); + item.changeDoesDamage(true); } @Test @@ -26,4 +28,11 @@ public class ItemTest { public void testGetDamage() { assertEquals(12.5, item.getDamage()); } + + @Test + public void testDoesDamage() { + boolean doesDamage = item.doesDamage(); + assumeTrue(item.getDamage() > 0); + assumeTrue(doesDamage); + } } From 562bd31373f758a280ac57165568509fa2a2910a Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 1 Feb 2023 20:09:20 +0100 Subject: [PATCH 29/47] unittest: created test for mob class This tests whether the mob is friendly --- .../org/bitbiome/entitiesTest/MobTest.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/test/java/org/bitbiome/entitiesTest/MobTest.java diff --git a/src/test/java/org/bitbiome/entitiesTest/MobTest.java b/src/test/java/org/bitbiome/entitiesTest/MobTest.java new file mode 100644 index 0000000..b11f4ce --- /dev/null +++ b/src/test/java/org/bitbiome/entitiesTest/MobTest.java @@ -0,0 +1,24 @@ +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); + } + + + @Test + public void testFriendly() { + assertEquals(mob.isFriendly(), true); + } + +} From 21f5b7d44c8dcec7a72ec3250f28e704654b54f5 Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 1 Feb 2023 20:11:05 +0100 Subject: [PATCH 30/47] unittest: updated mob test This additionally tests how much damage the mob does --- src/test/java/org/bitbiome/entitiesTest/MobTest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/test/java/org/bitbiome/entitiesTest/MobTest.java b/src/test/java/org/bitbiome/entitiesTest/MobTest.java index b11f4ce..9777dc3 100644 --- a/src/test/java/org/bitbiome/entitiesTest/MobTest.java +++ b/src/test/java/org/bitbiome/entitiesTest/MobTest.java @@ -13,6 +13,7 @@ public class MobTest { public static void setMob() { mob = new Mob(); mob.setFriendly(true); + mob.setDamage(0F); } @@ -20,5 +21,10 @@ public class MobTest { public void testFriendly() { assertEquals(mob.isFriendly(), true); } + + @Test + public void testDamage() { + assertEquals(mob.getDamage(), 0F); + } } From 06c77bf83768ad7503e89ee9e176e6370d2503a8 Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 1 Feb 2023 20:11:44 +0100 Subject: [PATCH 31/47] unittest: updated mob test This additionally tests how much life the mob has --- src/test/java/org/bitbiome/entitiesTest/MobTest.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/test/java/org/bitbiome/entitiesTest/MobTest.java b/src/test/java/org/bitbiome/entitiesTest/MobTest.java index 9777dc3..00afaf8 100644 --- a/src/test/java/org/bitbiome/entitiesTest/MobTest.java +++ b/src/test/java/org/bitbiome/entitiesTest/MobTest.java @@ -14,6 +14,7 @@ public class MobTest { mob = new Mob(); mob.setFriendly(true); mob.setDamage(0F); + mob.setHp(561.45F); } @@ -27,4 +28,8 @@ public class MobTest { assertEquals(mob.getDamage(), 0F); } + @Test + public void testHp() { + assertEquals(mob.getHp(), 561.45F); + } } From 8dda2401d12e18fa0846eb44c00fdc7bfa8f6f34 Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 1 Feb 2023 20:12:44 +0100 Subject: [PATCH 32/47] unittest: created test for location class This tests the name of the location --- .../bitbiome/entitiesTest/LocationTest.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/test/java/org/bitbiome/entitiesTest/LocationTest.java diff --git a/src/test/java/org/bitbiome/entitiesTest/LocationTest.java b/src/test/java/org/bitbiome/entitiesTest/LocationTest.java new file mode 100644 index 0000000..1ae0575 --- /dev/null +++ b/src/test/java/org/bitbiome/entitiesTest/LocationTest.java @@ -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()); + } +} From 9acf819d35f8df525d081dcd1d8992c28b79c0c0 Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 1 Feb 2023 20:13:52 +0100 Subject: [PATCH 33/47] unittest: created test for player class This tests the name of the player --- .../org/bitbiome/entitiesTest/PlayerTest.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/test/java/org/bitbiome/entitiesTest/PlayerTest.java diff --git a/src/test/java/org/bitbiome/entitiesTest/PlayerTest.java b/src/test/java/org/bitbiome/entitiesTest/PlayerTest.java new file mode 100644 index 0000000..4f9d885 --- /dev/null +++ b/src/test/java/org/bitbiome/entitiesTest/PlayerTest.java @@ -0,0 +1,26 @@ +package org.bitbiome.entitiesTest; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.bitbiome.entities.Player; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +public class PlayerTest { + + private static Player player; + + @BeforeAll + public static void setPlayer() { + player = new Player(); + + player.setName("UnitPlayer"); + + } + + @Test + public void testPlayerName() { + assertEquals("UnitPlayer", player.getName()); + } + +} From df4b960fa7532add54a912710539b03c2c86ae9d Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 1 Feb 2023 20:14:52 +0100 Subject: [PATCH 34/47] unittest: updated player test This additionally tests how many lives the player has --- src/test/java/org/bitbiome/entitiesTest/PlayerTest.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/bitbiome/entitiesTest/PlayerTest.java b/src/test/java/org/bitbiome/entitiesTest/PlayerTest.java index 4f9d885..df03dfd 100644 --- a/src/test/java/org/bitbiome/entitiesTest/PlayerTest.java +++ b/src/test/java/org/bitbiome/entitiesTest/PlayerTest.java @@ -15,7 +15,7 @@ public class PlayerTest { player = new Player(); player.setName("UnitPlayer"); - + player.setHp(100F); } @Test @@ -23,4 +23,10 @@ public class PlayerTest { assertEquals("UnitPlayer", player.getName()); } + + @Test + public void testPlayerHp() { + assertEquals(100F, player.getHp()); + } + } From 1ded07cd00b5145388665ee00836fa152cb14598 Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 1 Feb 2023 20:17:10 +0100 Subject: [PATCH 35/47] unittest: updated player test This additionally tests if the player has a location by testing the name of the location related to the player --- .../java/org/bitbiome/entitiesTest/PlayerTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/java/org/bitbiome/entitiesTest/PlayerTest.java b/src/test/java/org/bitbiome/entitiesTest/PlayerTest.java index df03dfd..2205e95 100644 --- a/src/test/java/org/bitbiome/entitiesTest/PlayerTest.java +++ b/src/test/java/org/bitbiome/entitiesTest/PlayerTest.java @@ -2,6 +2,7 @@ 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; @@ -9,12 +10,17 @@ 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); } @@ -29,4 +35,9 @@ public class PlayerTest { assertEquals(100F, player.getHp()); } + @Test + public void testLocationNameFromPlayer() { + assertEquals("NewUnitWorld", player.getLocation().getName()); + } + } From 1749b5f66351b5f14f30888347bcf06380487a47 Mon Sep 17 00:00:00 2001 From: David Hermann Date: Mon, 6 Feb 2023 10:07:56 +0100 Subject: [PATCH 36/47] refactoring: Outsourced System.out.println --- .../java/org/bitbiome/classes/InteractionLoop.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/bitbiome/classes/InteractionLoop.java b/src/main/java/org/bitbiome/classes/InteractionLoop.java index a0b5017..bbf513d 100644 --- a/src/main/java/org/bitbiome/classes/InteractionLoop.java +++ b/src/main/java/org/bitbiome/classes/InteractionLoop.java @@ -12,7 +12,7 @@ public class InteractionLoop { public void run(TravelEngine travelEngine) { boolean isRunning = true; if (travelEngine.getPlayer().getName().equals("null")) { - System.out.println(Colors.ANSI_BLUE + "Oh, ein Fremder!\nBist du bereit für dein womöglich größtes Abenteuer?\nDann sag mir doch zunächst wie du heißt: " + Colors.ANSI_RESET); + print(Colors.ANSI_BLUE + "Oh, ein Fremder!\nBist du bereit für dein womöglich größtes Abenteuer?\nDann sag mir doch zunächst wie du heißt: " + Colors.ANSI_RESET); String name = input.nextLine(); JsonParser jp = new JsonParser(); JSONObject playerconf = jp.getJSONObject("playerconfig.json"); @@ -20,15 +20,20 @@ public class InteractionLoop { travelEngine.getPlayer().setName(name); jp.writeObject("playerconfig.json", playerconf); } - System.out.println(Colors.ANSI_BG_CYAN + Colors.ANSI_BLACK + "Willkommen zu BitBiome " + travelEngine.getPlayer().getName() + "!" + Colors.ANSI_RESET + "\n\n"); + print(Colors.ANSI_BG_CYAN + Colors.ANSI_BLACK + "Willkommen zu BitBiome " + travelEngine.getPlayer().getName() + "!" + Colors.ANSI_RESET + "\n\n"); while (isRunning) { String line = input.nextLine().toLowerCase(); if (!Boot.instance.getCmdListener().perform(line.toLowerCase().split(" ")[0], input, isRunning, line, travelEngine)) { - System.out.println(Colors.ANSI_RED + "Unbekannter Befehl - Siehe " + Colors.ANSI_PURPLE + "help\n" + Colors.ANSI_RESET); + print(Colors.ANSI_RED + "Unbekannter Befehl - Siehe " + Colors.ANSI_PURPLE + "help\n" + Colors.ANSI_RESET); } } } + public boolean print(String message) { + System.out.println(message); + return true; + } + } From 4e990e2d04321291f620cfeb23b416874abb1419 Mon Sep 17 00:00:00 2001 From: David Hermann Date: Mon, 6 Feb 2023 10:17:22 +0100 Subject: [PATCH 37/47] refactoring: Outsourced code in InteractionLoop Whether the player is new or not will be checked in new outsourced function --- src/main/java/org/bitbiome/classes/InteractionLoop.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/bitbiome/classes/InteractionLoop.java b/src/main/java/org/bitbiome/classes/InteractionLoop.java index bbf513d..5cd9a59 100644 --- a/src/main/java/org/bitbiome/classes/InteractionLoop.java +++ b/src/main/java/org/bitbiome/classes/InteractionLoop.java @@ -11,7 +11,7 @@ public class InteractionLoop { public void run(TravelEngine travelEngine) { boolean isRunning = true; - if (travelEngine.getPlayer().getName().equals("null")) { + if (playerIsNew(travelEngine.getPlayer().getName())) { print(Colors.ANSI_BLUE + "Oh, ein Fremder!\nBist du bereit für dein womöglich größtes Abenteuer?\nDann sag mir doch zunächst wie du heißt: " + Colors.ANSI_RESET); String name = input.nextLine(); JsonParser jp = new JsonParser(); @@ -34,6 +34,10 @@ public class InteractionLoop { return true; } + public boolean playerIsNew(String name) { + return name.equalsIgnoreCase("null"); + } + } From d6ece832e7768909c1e77e1dc34fc800fcd3f5bb Mon Sep 17 00:00:00 2001 From: David Hermann Date: Mon, 6 Feb 2023 10:39:23 +0100 Subject: [PATCH 38/47] refactoring: Outsourced code When the player is new a outsourced method is called --- .../org/bitbiome/classes/InteractionLoop.java | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/bitbiome/classes/InteractionLoop.java b/src/main/java/org/bitbiome/classes/InteractionLoop.java index 5cd9a59..f8a6c84 100644 --- a/src/main/java/org/bitbiome/classes/InteractionLoop.java +++ b/src/main/java/org/bitbiome/classes/InteractionLoop.java @@ -4,7 +4,6 @@ import org.bitbiome.Boot; import org.json.JSONObject; import java.util.Scanner; - public class InteractionLoop { Scanner input = new Scanner(System.in); @@ -12,19 +11,16 @@ public class InteractionLoop { public void run(TravelEngine travelEngine) { boolean isRunning = true; if (playerIsNew(travelEngine.getPlayer().getName())) { - print(Colors.ANSI_BLUE + "Oh, ein Fremder!\nBist du bereit für dein womöglich größtes Abenteuer?\nDann sag mir doch zunächst wie du heißt: " + Colors.ANSI_RESET); - String name = input.nextLine(); - JsonParser jp = new JsonParser(); - JSONObject playerconf = jp.getJSONObject("playerconfig.json"); - playerconf.put("name", name); - travelEngine.getPlayer().setName(name); - jp.writeObject("playerconfig.json", playerconf); + newPlayerWelcome(travelEngine); } - print(Colors.ANSI_BG_CYAN + Colors.ANSI_BLACK + "Willkommen zu BitBiome " + travelEngine.getPlayer().getName() + "!" + Colors.ANSI_RESET + "\n\n"); + print(Colors.ANSI_BG_CYAN + Colors.ANSI_BLACK + "Willkommen zu BitBiome " + travelEngine.getPlayer().getName() + + "!" + Colors.ANSI_RESET + "\n\n"); while (isRunning) { String line = input.nextLine().toLowerCase(); - if (!Boot.instance.getCmdListener().perform(line.toLowerCase().split(" ")[0], input, isRunning, line, travelEngine)) { - print(Colors.ANSI_RED + "Unbekannter Befehl - Siehe " + Colors.ANSI_PURPLE + "help\n" + Colors.ANSI_RESET); + if (!Boot.instance.getCmdListener().perform(line.toLowerCase().split(" ")[0], input, isRunning, line, + travelEngine)) { + print(Colors.ANSI_RED + "Unbekannter Befehl - Siehe " + Colors.ANSI_PURPLE + "help\n" + + Colors.ANSI_RESET); } } } @@ -38,6 +34,16 @@ public class InteractionLoop { return name.equalsIgnoreCase("null"); } - + public void newPlayerWelcome(TravelEngine travelEngine) { + print(Colors.ANSI_BLUE + + "Oh, ein Fremder!\nBist du bereit für dein womöglich größtes Abenteuer?\nDann sag mir doch zunächst wie du heißt: " + + Colors.ANSI_RESET); + String name = input.nextLine(); + JsonParser jp = new JsonParser(); + JSONObject playerconf = jp.getJSONObject("playerconfig.json"); + playerconf.put("name", name); + travelEngine.getPlayer().setName(name); + jp.writeObject("playerconfig.json", playerconf); + } } From fda96a5acb65c3b651dee5235a7f70e049f82bd5 Mon Sep 17 00:00:00 2001 From: David Hermann Date: Mon, 6 Feb 2023 10:41:41 +0100 Subject: [PATCH 39/47] refactoring: Deleted CreateLocations --- .../org/bitbiome/classes/CreateLocations.java | 24 ------------------- 1 file changed, 24 deletions(-) delete mode 100644 src/main/java/org/bitbiome/classes/CreateLocations.java diff --git a/src/main/java/org/bitbiome/classes/CreateLocations.java b/src/main/java/org/bitbiome/classes/CreateLocations.java deleted file mode 100644 index ed237a1..0000000 --- a/src/main/java/org/bitbiome/classes/CreateLocations.java +++ /dev/null @@ -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 items = new ArrayList<>(); - ArrayList mobs = new ArrayList<>(); - String name = "Wald"; - return new Location(name, mobs, items); - } - - public static Location createBeach() { - ArrayList items = new ArrayList<>(); - ArrayList mobs = new ArrayList<>(); - String name = "Strand"; - return new Location(name, mobs, items); - } -} From 9ebe7ea258f84b34dd3cfdc207d07759796a770b Mon Sep 17 00:00:00 2001 From: David Hermann Date: Mon, 6 Feb 2023 10:48:37 +0100 Subject: [PATCH 40/47] refactoring: Outsourced System.out.println --- .../java/org/bitbiome/commands/TravelCommand.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/bitbiome/commands/TravelCommand.java b/src/main/java/org/bitbiome/commands/TravelCommand.java index da5cbe7..810333e 100644 --- a/src/main/java/org/bitbiome/commands/TravelCommand.java +++ b/src/main/java/org/bitbiome/commands/TravelCommand.java @@ -16,18 +16,23 @@ public class TravelCommand implements CommandAPI { @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); + print(Colors.ANSI_BLUE + "Du hast dein Travel-Pad gezückt. Wohin möchtest du reisen?" + Colors.ANSI_RESET); JSONArray locations = travelEngine.getLocationList(); for (int i = 0; i < locations.length(); i++) { - System.out.println("- " + locations.getJSONObject(i).getString("name")); + print("- " + locations.getJSONObject(i).getString("name")); } String locationName = scanner.nextLine(); if (travelEngine.locationExists(locationName)) { travelEngine.travelTo(new Location(locationName, new ArrayList(), new ArrayList())); - System.out.println(Colors.ANSI_BLUE + "Du bist nun hierhin gereist: " + locationName + "\n" + Colors.ANSI_RESET); + print(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); + print(Colors.ANSI_BLUE + "Du hast dein Travel-Pad weggesteckt." + Colors.ANSI_RESET); } } + + public String print(String message) { + System.out.println(message); + return message; + } } From 460fc7157038129ad248030f981f9e5d677d43f7 Mon Sep 17 00:00:00 2001 From: David Hermann Date: Mon, 6 Feb 2023 11:17:56 +0100 Subject: [PATCH 41/47] refactoring: Added comment to Color --- .../java/org/bitbiome/classes/Colors.java | 106 +++++++++--------- 1 file changed, 56 insertions(+), 50 deletions(-) diff --git a/src/main/java/org/bitbiome/classes/Colors.java b/src/main/java/org/bitbiome/classes/Colors.java index d08f59e..99e45e1 100644 --- a/src/main/java/org/bitbiome/classes/Colors.java +++ b/src/main/java/org/bitbiome/classes/Colors.java @@ -2,55 +2,61 @@ package org.bitbiome.classes; public class Colors { - public static final String ANSI_RESET = "\u001B[0m"; - - public static final String ANSI_BLACK = "\u001B[30m"; - public static final String ANSI_RED = "\u001B[31m"; - public static final String ANSI_GREEN = "\u001B[32m"; - public static final String ANSI_YELLOW = "\u001B[33m"; - public static final String ANSI_BLUE = "\u001B[34m"; - public static final String ANSI_PURPLE = "\u001B[35m"; - public static final String ANSI_CYAN = "\u001B[36m"; - public static final String ANSI_WHITE = "\u001B[37m"; - - public static final String ANSI_BRIGHT_BLACK = "\u001B[90m"; - public static final String ANSI_BRIGHT_RED = "\u001B[91m"; - public static final String ANSI_BRIGHT_GREEN = "\u001B[92m"; - public static final String ANSI_BRIGHT_YELLOW = "\u001B[93m"; - public static final String ANSI_BRIGHT_BLUE = "\u001B[94m"; - public static final String ANSI_BRIGHT_PURPLE = "\u001B[95m"; - public static final String ANSI_BRIGHT_CYAN = "\u001B[96m"; - public static final String ANSI_BRIGHT_WHITE = "\u001B[97m"; - - public static final String[] FOREGROUNDS = { - ANSI_BLACK, ANSI_RED, ANSI_GREEN, ANSI_YELLOW, - ANSI_BLUE, ANSI_PURPLE, ANSI_CYAN, ANSI_WHITE, - ANSI_BRIGHT_BLACK, ANSI_BRIGHT_RED, ANSI_BRIGHT_GREEN, ANSI_BRIGHT_YELLOW, - ANSI_BRIGHT_BLUE, ANSI_BRIGHT_PURPLE, ANSI_BRIGHT_CYAN, ANSI_BRIGHT_WHITE - }; - - public static final String ANSI_BG_BLACK = "\u001B[40m"; - public static final String ANSI_BG_RED = "\u001B[41m"; - public static final String ANSI_BG_GREEN = "\u001B[42m"; - public static final String ANSI_BG_YELLOW = "\u001B[43m"; - public static final String ANSI_BG_BLUE = "\u001B[44m"; - public static final String ANSI_BG_PURPLE = "\u001B[45m"; - public static final String ANSI_BG_CYAN = "\u001B[46m"; - public static final String ANSI_BG_WHITE = "\u001B[47m"; - - public static final String ANSI_BRIGHT_BG_BLACK = "\u001B[100m"; - public static final String ANSI_BRIGHT_BG_RED = "\u001B[101m"; - public static final String ANSI_BRIGHT_BG_GREEN = "\u001B[102m"; - public static final String ANSI_BRIGHT_BG_YELLOW = "\u001B[103m"; - public static final String ANSI_BRIGHT_BG_BLUE = "\u001B[104m"; - public static final String ANSI_BRIGHT_BG_PURPLE = "\u001B[105m"; - public static final String ANSI_BRIGHT_BG_CYAN = "\u001B[106m"; - public static final String ANSI_BRIGHT_BG_WHITE = "\u001B[107m"; - - public static final String[] BACKGROUNDS = { - ANSI_BG_BLACK, ANSI_BG_RED, ANSI_BG_GREEN, ANSI_BG_YELLOW, - ANSI_BG_BLUE, ANSI_BG_PURPLE, ANSI_BG_CYAN, ANSI_BG_WHITE, - ANSI_BRIGHT_BG_BLACK, ANSI_BRIGHT_BG_RED, ANSI_BRIGHT_BG_GREEN, ANSI_BRIGHT_BG_YELLOW, - ANSI_BRIGHT_BG_BLUE, ANSI_BRIGHT_BG_PURPLE, ANSI_BRIGHT_BG_CYAN, ANSI_BRIGHT_BG_WHITE }; + /* + * This class has only public static mehtods + * Just add a String to your String and finalize it with the ANSI_RESET String + * The Color Codes with BG in the variable name are for the background colors + */ + + public static final String ANSI_RESET = "\u001B[0m"; + + public static final String ANSI_BLACK = "\u001B[30m"; + public static final String ANSI_RED = "\u001B[31m"; + public static final String ANSI_GREEN = "\u001B[32m"; + public static final String ANSI_YELLOW = "\u001B[33m"; + public static final String ANSI_BLUE = "\u001B[34m"; + public static final String ANSI_PURPLE = "\u001B[35m"; + public static final String ANSI_CYAN = "\u001B[36m"; + public static final String ANSI_WHITE = "\u001B[37m"; + + public static final String ANSI_BRIGHT_BLACK = "\u001B[90m"; + public static final String ANSI_BRIGHT_RED = "\u001B[91m"; + public static final String ANSI_BRIGHT_GREEN = "\u001B[92m"; + public static final String ANSI_BRIGHT_YELLOW = "\u001B[93m"; + public static final String ANSI_BRIGHT_BLUE = "\u001B[94m"; + public static final String ANSI_BRIGHT_PURPLE = "\u001B[95m"; + public static final String ANSI_BRIGHT_CYAN = "\u001B[96m"; + public static final String ANSI_BRIGHT_WHITE = "\u001B[97m"; + + public static final String[] FOREGROUNDS = { + ANSI_BLACK, ANSI_RED, ANSI_GREEN, ANSI_YELLOW, + ANSI_BLUE, ANSI_PURPLE, ANSI_CYAN, ANSI_WHITE, + ANSI_BRIGHT_BLACK, ANSI_BRIGHT_RED, ANSI_BRIGHT_GREEN, ANSI_BRIGHT_YELLOW, + ANSI_BRIGHT_BLUE, ANSI_BRIGHT_PURPLE, ANSI_BRIGHT_CYAN, ANSI_BRIGHT_WHITE + }; + + public static final String ANSI_BG_BLACK = "\u001B[40m"; + public static final String ANSI_BG_RED = "\u001B[41m"; + public static final String ANSI_BG_GREEN = "\u001B[42m"; + public static final String ANSI_BG_YELLOW = "\u001B[43m"; + public static final String ANSI_BG_BLUE = "\u001B[44m"; + public static final String ANSI_BG_PURPLE = "\u001B[45m"; + public static final String ANSI_BG_CYAN = "\u001B[46m"; + public static final String ANSI_BG_WHITE = "\u001B[47m"; + + public static final String ANSI_BRIGHT_BG_BLACK = "\u001B[100m"; + public static final String ANSI_BRIGHT_BG_RED = "\u001B[101m"; + public static final String ANSI_BRIGHT_BG_GREEN = "\u001B[102m"; + public static final String ANSI_BRIGHT_BG_YELLOW = "\u001B[103m"; + public static final String ANSI_BRIGHT_BG_BLUE = "\u001B[104m"; + public static final String ANSI_BRIGHT_BG_PURPLE = "\u001B[105m"; + public static final String ANSI_BRIGHT_BG_CYAN = "\u001B[106m"; + public static final String ANSI_BRIGHT_BG_WHITE = "\u001B[107m"; + + public static final String[] BACKGROUNDS = { + ANSI_BG_BLACK, ANSI_BG_RED, ANSI_BG_GREEN, ANSI_BG_YELLOW, + ANSI_BG_BLUE, ANSI_BG_PURPLE, ANSI_BG_CYAN, ANSI_BG_WHITE, + ANSI_BRIGHT_BG_BLACK, ANSI_BRIGHT_BG_RED, ANSI_BRIGHT_BG_GREEN, ANSI_BRIGHT_BG_YELLOW, + ANSI_BRIGHT_BG_BLUE, ANSI_BRIGHT_BG_PURPLE, ANSI_BRIGHT_BG_CYAN, ANSI_BRIGHT_BG_WHITE }; } From ad5f87a4b0332170961a112eb3493006573e1a1c Mon Sep 17 00:00:00 2001 From: David Hermann Date: Mon, 6 Feb 2023 11:21:36 +0100 Subject: [PATCH 42/47] refactoring: Added comments to CommandInterface --- src/main/java/org/bitbiome/commands/CommandAPI.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/org/bitbiome/commands/CommandAPI.java b/src/main/java/org/bitbiome/commands/CommandAPI.java index a5c48be..9e5ade8 100644 --- a/src/main/java/org/bitbiome/commands/CommandAPI.java +++ b/src/main/java/org/bitbiome/commands/CommandAPI.java @@ -5,6 +5,10 @@ import org.bitbiome.classes.TravelEngine; import java.util.Scanner; public interface CommandAPI { + + // This is the command interface. Every command implements it's run method from here + // This is the API between the commands and the interaction loop/game + public void performCommand(Scanner scanner, boolean isRunning, String message, TravelEngine travelEngine); } From b26a43dfcbb824f587895f2ea341542ae8e3eaa7 Mon Sep 17 00:00:00 2001 From: David Hermann Date: Mon, 6 Feb 2023 11:24:45 +0100 Subject: [PATCH 43/47] refactoring: Added comments to CommandListener --- src/main/java/org/bitbiome/commands/CommandListener.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/bitbiome/commands/CommandListener.java b/src/main/java/org/bitbiome/commands/CommandListener.java index d59813c..d30ef1f 100644 --- a/src/main/java/org/bitbiome/commands/CommandListener.java +++ b/src/main/java/org/bitbiome/commands/CommandListener.java @@ -6,7 +6,9 @@ import java.util.HashMap; import java.util.Scanner; public class CommandListener { - + // This class is the API between the command interface and the user input + // This class is used to handle all the commands + // The commands are stored in a hashmap private HashMap commands; public CommandListener() { From 3e4259170cebe5dfb1fa2d16073a96d7e7f67c51 Mon Sep 17 00:00:00 2001 From: David Hermann Date: Mon, 6 Feb 2023 11:28:09 +0100 Subject: [PATCH 44/47] refactoring: Added comments to QuitCommand --- src/main/java/org/bitbiome/commands/QuitCommand.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/org/bitbiome/commands/QuitCommand.java b/src/main/java/org/bitbiome/commands/QuitCommand.java index 25dbb00..258ab1a 100644 --- a/src/main/java/org/bitbiome/commands/QuitCommand.java +++ b/src/main/java/org/bitbiome/commands/QuitCommand.java @@ -6,6 +6,10 @@ import java.util.Scanner; public class QuitCommand implements CommandAPI { + // This command is used to end the game via command + // When the player quits the game, the game is stopped through System.exit(0) + // That means it is exited with no error status + @Override public void performCommand(Scanner scanner, boolean isRunning, String message, TravelEngine travelEngine) { System.out.println(getQuitMessage()); From 23c162d5246115b5603b771065252f9870cfcaf5 Mon Sep 17 00:00:00 2001 From: David Hermann Date: Mon, 6 Feb 2023 11:36:56 +0100 Subject: [PATCH 45/47] unittest: Created test for important color codes --- src/test/java/org/bitbiome/classes/ColorsTest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/test/java/org/bitbiome/classes/ColorsTest.java diff --git a/src/test/java/org/bitbiome/classes/ColorsTest.java b/src/test/java/org/bitbiome/classes/ColorsTest.java new file mode 100644 index 0000000..21069bb --- /dev/null +++ b/src/test/java/org/bitbiome/classes/ColorsTest.java @@ -0,0 +1,13 @@ +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); + } +} From 76aeb8fc0fc9529176aa45444fa5d85400ec38bd Mon Sep 17 00:00:00 2001 From: David Hermann Date: Mon, 6 Feb 2023 11:38:13 +0100 Subject: [PATCH 46/47] unittest: Created test for blue color --- src/test/java/org/bitbiome/classes/ColorsTest.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/test/java/org/bitbiome/classes/ColorsTest.java b/src/test/java/org/bitbiome/classes/ColorsTest.java index 21069bb..d6cc36b 100644 --- a/src/test/java/org/bitbiome/classes/ColorsTest.java +++ b/src/test/java/org/bitbiome/classes/ColorsTest.java @@ -10,4 +10,9 @@ public class ColorsTest { public void testResetCode() { assertEquals("\u001B[0m", Colors.ANSI_RESET); } + + @Test + public void testBlueCode() { + assertEquals("\u001B[34m", Colors.ANSI_BLUE); + } } From 7ec03825398edf2eedf9947932b8578b380422b4 Mon Sep 17 00:00:00 2001 From: David Hermann Date: Mon, 6 Feb 2023 11:42:03 +0100 Subject: [PATCH 47/47] unittest: Created test for cyan code --- src/test/java/org/bitbiome/classes/ColorsTest.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/test/java/org/bitbiome/classes/ColorsTest.java b/src/test/java/org/bitbiome/classes/ColorsTest.java index d6cc36b..541ebdf 100644 --- a/src/test/java/org/bitbiome/classes/ColorsTest.java +++ b/src/test/java/org/bitbiome/classes/ColorsTest.java @@ -15,4 +15,9 @@ public class ColorsTest { public void testBlueCode() { assertEquals("\u001B[34m", Colors.ANSI_BLUE); } + + @Test + public void testCyanCode() { + assertEquals("\u001B[36m", Colors.ANSI_CYAN); + } }