diff --git a/data/actors/jobs/Red Mage/job.ini b/data/actors/jobs/Red Mage/job.ini index 6a01f78..d90d1fa 100644 --- a/data/actors/jobs/Red Mage/job.ini +++ b/data/actors/jobs/Red Mage/job.ini @@ -6,4 +6,5 @@ itl = 10 acc = 7 spd = 10 mdef = 20 +weight = 1 name = RedMAGE diff --git a/src/actors/Player.java b/src/actors/Player.java index 8e52df4..7d003d9 100644 --- a/src/actors/Player.java +++ b/src/actors/Player.java @@ -136,7 +136,7 @@ public Player(Preferences p) { this(p.get("name", "aaaa"), p.get("job", "Fighter")); - /** + /* * loads all the stats for the player, * if the stats don't exist then just use * the job's initial stats @@ -157,6 +157,33 @@ public Player(Preferences p) mdef = p.getInt("mdef", mdef); luk = p.getInt("luck", luk); exp = p.getInt("exp", 0); + + /* + * Loads all the armor and weapons + */ + weight = p.getInt("weight", 0); + + for (int i = 0; i < weapons.length; i++) + { + weapons[i] = Item.loadItem(p.get(String.format("weapon%02d", i), null)); + } + + String e = p.get("eWeapon", "-1"); + if (Integer.parseInt(e) != -1) + weapon = weapons[Integer.parseInt(e)]; + + e = p.get("eArmor", ""); + for (int i = 0; i < armor.length; i++) + { + armor[i] = Item.loadItem(p.get(String.format("armor%02d", i), null)); + if (e.contains(""+i+" ")) + wearArmor(armor[i]); + } + Scanner s = new Scanner(e); + while (s.hasNextInt()) + wearArmor(armor[s.nextInt()]); + s.close(); + e = null; } /** @@ -190,6 +217,23 @@ public void savePlayer(Ini ini, String section) ini.put(section, "luck", luk); ini.put(section, "exp", exp); + String e = ""; + for (int i = 0; i < weapons.length; i++) + { + ini.put(section, String.format("weapon%02d", i), weapons[i]); + if (getWeapon() == weapons[i]) + e = i + ""; + } + ini.put(section, "eWeapon", e); //equipped item index + + e = ""; + for (int i = 0; i < armor.length; i++) + { + ini.put(section, String.format("armor%02d", i), armor[i]); + if (this.isWearing(armor[i])) + e += i + " "; + } + ini.put(section, "eArmor", e); } /** @@ -789,7 +833,7 @@ public boolean isWearing(Item item) { */ public boolean wearArmor(Item armor) { - if (armor.isEquipment() && armor.getWeight() <= weight) + if (armor != null && armor.isEquipment() && armor.getWeight() <= weight) { //only equip the armor if there is a piece of armor of that type that is not already equipped for (int i = 0; i < equippedArmor.size(); i++) diff --git a/src/item/Item.java b/src/item/Item.java index 106ff95..4d278e9 100644 --- a/src/item/Item.java +++ b/src/item/Item.java @@ -59,6 +59,10 @@ public boolean accept(File f, String s) { public static Item loadItem(String s) { Item i = null; + //ignore loading if the value is null + if (s == null) + return null; + //compare first against the dictionary since it knows which item names are valid if (Dictionary.contains(s)) if (cache.containsKey(s)) @@ -181,21 +185,21 @@ public Item(String s) throws Exception { Preferences equip = inifile.node(eqSec); // type is armor or weapon - if (type != 2) { + if (type != ACCESSORY_TYPE) { // get armor weight and restricted jobs weight = equip.getInt("weight", 0); restrict = equip.get("restrict", "").split(","); if (type == 1) slot = equip.getInt("slot", 0); } - hp = equip.getInt("hp", 1); - str = equip.getInt("str", 1); - itl = equip.getInt("int", 1); - spd = equip.getInt("spd", 1); - evd = equip.getInt("evd", 1); - acc = equip.getInt("acc", 1); - vit = equip.getInt("vit", 1); - mdef = equip.getInt("mdef", 1); + hp = equip.getInt("hp", 0); + str = equip.getInt("str", 0); + itl = equip.getInt("int", 0); + spd = equip.getInt("spd", 0); + evd = equip.getInt("evd", 0); + acc = equip.getInt("acc", 0); + vit = equip.getInt("vit", 0); + mdef = equip.getInt("mdef", 0); } String command = main.get("command", null); diff --git a/src/scenes/MenuScene/GUI/EquipmentGUI.java b/src/scenes/MenuScene/GUI/EquipmentGUI.java index 8553e0b..a7cc585 100644 --- a/src/scenes/MenuScene/GUI/EquipmentGUI.java +++ b/src/scenes/MenuScene/GUI/EquipmentGUI.java @@ -84,7 +84,7 @@ public int[] updateArrowPosition(int index) int x = index % 2; int y = index % 4 / 2; arrowPosition[0] = eWindows[i].getX() + 58 + 80*x; - arrowPosition[1] = eWindows[i].getY() + 16 + 16*y; + arrowPosition[1] = eWindows[i].getY() + 16 + 12*y; } return arrowPosition; } @@ -166,7 +166,7 @@ public void paint(Graphics g) { t = ((p.getWeapon() == p.getWeapons()[i] && p.getWeapon() != null)?"E-":"") + ((p.getWeapons()[i] != null)?p.getWeapons()[i].getName():""); else t = ((p.isWearing(p.getArmor()[i])?"E-":"") + ((p.getArmor()[i] != null)?p.getArmor()[i].getName():"")); - f.drawString(g, t, 20+(items.getWidth()/2*(i%2)), 14+(items.getHeight()/2*(i/2)), items); + f.drawString(g, t, 20+(items.getWidth()/2*(i%2)), 14+(12*(i/2)), items); } } } diff --git a/src/scenes/MenuScene/System/ArmorState.java b/src/scenes/MenuScene/System/ArmorState.java index 1265c7a..c751e5a 100644 --- a/src/scenes/MenuScene/System/ArmorState.java +++ b/src/scenes/MenuScene/System/ArmorState.java @@ -25,7 +25,7 @@ public void handleKeyInput(int key) Item armor = player.getArmor()[row+col]; if (player.isWearing(armor)) player.takeOffArmor(armor); - else if (player.getWeapons()[row+col] != null) + else if (armor != null) player.wearArmor(armor); } }