diff --git a/src/main/java/com/jadventure/game/entities/Entity.java b/src/main/java/com/jadventure/game/entities/Entity.java index 62100a3d..3a9af6b6 100644 --- a/src/main/java/com/jadventure/game/entities/Entity.java +++ b/src/main/java/com/jadventure/game/entities/Entity.java @@ -11,6 +11,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; +import java.util.Iterator; /** * superclass for all entities (includes player, monsters...) @@ -39,8 +40,37 @@ public abstract class Entity { private int armour; private String weapon = "empty"; private HashMap equipment; + public HashMap classStats = new HashMap() { + { + put("Recruit", 0); + put("Sewer Rat", 0); + }; + }; + private String currentClassName; protected Storage storage; Random globalRand = new Random(); + + public String getCurrentClass() { + return this.currentClassName; + } + + public void setCurrentClass(String className) { + this.currentClassName = className; + } + + public void checkCurrentClass() { + Iterator it = this.classStats.entrySet().iterator(); + int highestClassLevel = 0; + String highestClassName = ""; + while (it.hasNext()) { + Map.Entry pairs = (Map.Entry)it.next(); + if (pairs.getValue() > highestClassLevel) { + highestClassLevel = pairs.getValue(); + highestClassName = pairs.getKey(); + } + } + this.currentClassName = highestClassName; + } // maybe not all entities start at full health, etc. public Entity() { diff --git a/src/main/java/com/jadventure/game/entities/Player.java b/src/main/java/com/jadventure/game/entities/Player.java index 7a66cadc..7262ae42 100644 --- a/src/main/java/com/jadventure/game/entities/Player.java +++ b/src/main/java/com/jadventure/game/entities/Player.java @@ -84,7 +84,7 @@ public static Player load(String name) { player.setDexterity(json.get("dexterity").getAsInt()); player.setLuck(json.get("luck").getAsInt()); player.setStealth(json.get("stealth").getAsInt()); - player.equipItem("rightHand", new Item(json.get("weapon").getAsString())); + player.equipItem("rightHand", new Item(json.get("weapon").getAsString())); if (json.has("items")) { HashMap items = new Gson().fromJson(json.get("items"), new TypeToken>(){}.getType()); ArrayList itemList = new ArrayList(); @@ -145,6 +145,15 @@ public static Player getInstance(String playerClass){ player.setLuck(luck); player.setStealth(json.get("stealth").getAsInt()); player.setIntro(json.get("intro").getAsString()); + if (player.getName().equals("Recruit")) { + player.classStats.put("Recruit", 50); + player.setCurrentClass("Recruit"); + } else if (player.getName().equals("Sewer Rat")) { + player.classStats.put("Sewer Rat", 50); + player.setCurrentClass("Sewer Rat"); + } else { + System.out.println("Not a valid class"); + } reader.close(); } catch (FileNotFoundException ex) { QueueProvider.offer( "Unable to open file '" + fileName + "'."); @@ -178,6 +187,7 @@ public void getStats(){ weaponName = "hands"; } String message = "\nPlayer name: " + getName(); + message += "\nClass: " + getCurrentClass(); message += "\nCurrent weapon: " + weaponName; message += "\nGold: " + getGold(); message += "\nHealth/Max: " + getHealth() + "/" + getHealthMax();