diff --git a/src/main/java/org/bitbiome/commands/CommandListener.java b/src/main/java/org/bitbiome/commands/CommandListener.java index 7d03184..43011db 100644 --- a/src/main/java/org/bitbiome/commands/CommandListener.java +++ b/src/main/java/org/bitbiome/commands/CommandListener.java @@ -19,6 +19,7 @@ public class CommandListener { commands.put("location", new LocationCommand()); commands.put("travel", new TravelCommand()); commands.put("map", new MapCommand()); + commands.put("gold", new GoldCommand()); } public HashMap returnCommands() { diff --git a/src/main/java/org/bitbiome/commands/GoldCommand.java b/src/main/java/org/bitbiome/commands/GoldCommand.java new file mode 100644 index 0000000..4330cf5 --- /dev/null +++ b/src/main/java/org/bitbiome/commands/GoldCommand.java @@ -0,0 +1,23 @@ +package org.bitbiome.commands; + +import java.util.Scanner; + +import org.bitbiome.classes.TravelEngine; +import org.bitbiome.entities.Player; + + + + +public class GoldCommand implements CommandAPI{ + + + public static String getGoldMessage(Player player) { + return "Dein Gold: " + player.getGold(); + } + + @Override + public void performCommand(Scanner scanner, boolean isRunning, String message, TravelEngine travelEngine) { + System.out.println(getGoldMessage(travelEngine.getPlayer())); + return; + } +} diff --git a/src/main/java/org/bitbiome/entities/Player.java b/src/main/java/org/bitbiome/entities/Player.java index ff8dffb..3cb83c5 100644 --- a/src/main/java/org/bitbiome/entities/Player.java +++ b/src/main/java/org/bitbiome/entities/Player.java @@ -8,6 +8,10 @@ import java.util.ArrayList; public class Player { private String name; private float hp; + + + + private float gold; private Location location; private ArrayList inventory; @@ -20,6 +24,7 @@ public class Player { hp = 100.0F; location = new Location(jp.getJSONObject("playerconfig.json").getString("currentLocation"), new ArrayList<>(), new ArrayList<>()); inventory = new ArrayList<>(); + gold = jp.getJSONObject("playerconfig.json").getFloat("gold"); } public String getName() { @@ -58,4 +63,8 @@ public class Player { this.name = name; } + public float getGold() { return gold; } + + public void setGold(float gold) { this.gold = gold; } + }