Browse Source

created GoldCommand

remotes/origin/map
Tanja Herche 2 years ago
parent
commit
ca19d64103
  1. 1
      src/main/java/org/bitbiome/commands/CommandListener.java
  2. 23
      src/main/java/org/bitbiome/commands/GoldCommand.java
  3. 9
      src/main/java/org/bitbiome/entities/Player.java

1
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<String, CommandAPI> returnCommands() {

23
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;
}
}

9
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<Item> 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; }
}
Loading…
Cancel
Save