From 84e74c5052137557bc961f0456b36a5f98b87354 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 6 Mar 2024 14:36:25 -0500 Subject: [PATCH] Refactored out character skill enum. --- src/engine/Enum.java | 99 ------------------------- src/engine/objects/ItemTemplate.java | 26 ++----- src/engine/objects/PlayerCharacter.java | 2 +- 3 files changed, 9 insertions(+), 118 deletions(-) diff --git a/src/engine/Enum.java b/src/engine/Enum.java index f67c3828..225b87af 100644 --- a/src/engine/Enum.java +++ b/src/engine/Enum.java @@ -1323,105 +1323,6 @@ public class Enum { Sanctifier, } - public enum CharacterSkills { - - Animation, - Archery, - Athletics, - AxeMastery, - Axe, - Bardsong, - Bargaining, - Beastcraft, - Benediction, - BladeMastery, - BladeWeaving, - Block, - Bow, - Channeling, - Cloth, - Conditioning, - Crossbow, - DaggerMastery, - Dagger, - Dodge, - Dueling, - Enchantment, - Endurance, - FlameCalling, - Focus, - GreatAxeMastery, - GreatHammerMastery, - GreatSwordMastery, - HammerMastery, - Hammer, - Leadership, - Learning, - Liturgy, - Meditation, - NatureLore, - None, - Opening, - Parry, - PoleArmMastery, - PoleArm, - ResistanceAcid, - ResistanceCold, - ResistanceCrushing, - ResistanceDisease, - ResistanceEarth, - ResistanceFire, - ResistanceHoly, - ResistanceLightning, - ResistanceMagic, - ResistanceMental, - ResistancePiercing, - ResistancePoison, - ResistanceSlashing, - ResistanceUnholy, - Restoration, - Runecarving, - Running, - Shadowmastery, - Shapechanging, - Sorcery, - SpearMastery, - Spear, - StaffMastery, - Staff, - Stormcalling, - Subterfuge, - Summoning, - SwordMastery, - Sword, - Thaumaturgy, - Theurgy, - Throwing, - Toughness, - UnarmedCombatMastery, - UnarmedCombat, - Unknown, - Warding, - Warlockry, - WayoftheGaana, - WearArmorHeavy, - WearArmorLight, - WearArmorMedium, - Willpower, - Wizardry, - Corruption, - Abjuration, - WayoftheWolf, - WayoftheRat, - WayoftheBear, - Orthanatos, - Bloodcraft, - Exorcism, - Necromancy, - SunDancing; - - } - public enum GuildHistoryType { JOIN(1), LEAVE(4), diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index e1412de2..c8d74160 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -50,8 +50,8 @@ public class ItemTemplate { public int item_render_object_female; public float item_health_full; public int item_parry_anim_id; - public EnumSet item_skill_used = EnumSet.noneOf(Enum.CharacterSkills.class); - public EnumSet item_skill_mastery_used = EnumSet.noneOf(Enum.CharacterSkills.class); + public String item_skill_used = ""; + public String item_skill_mastery_used = ""; public float item_bulk_factor; public int item_defense_rating; public float item_weapon_wepspeed; @@ -67,7 +67,7 @@ public class ItemTemplate { public EnumSet item_flags = EnumSet.noneOf(Enum.ItemFlags.class); public EnumSet item_use_flags = EnumSet.noneOf(Enum.ItemUseFlags.class); public int item_initial_charges; - public HashMap item_skill_required = new HashMap<>(); + public HashMap item_skill_required = new HashMap<>(); public EnumSet item_race_req = EnumSet.noneOf(Enum.MonsterType.class); public EnumSet item_race_res = EnumSet.noneOf(Enum.MonsterType.class); @@ -163,21 +163,13 @@ public class ItemTemplate { Object skill_used = jsonObject.get("item_skill_used"); - if (skill_used instanceof String) { - String skilString = (String) skill_used; - skilString = skilString.replaceAll("\\s", ""); - skilString = skilString.replaceAll(",", ""); - item_skill_used.add(Enum.CharacterSkills.valueOf(skilString)); - } + if (skill_used instanceof String) + item_skill_used = (String) skill_used; Object mastery_used = jsonObject.get("item_skill_mastery_used"); - if (mastery_used instanceof String) { - String masteryString = (String) mastery_used; - masteryString = masteryString.replaceAll("\\s", ""); - masteryString = masteryString.replaceAll(",", ""); - item_skill_mastery_used.add(Enum.CharacterSkills.valueOf(masteryString)); - } + if (mastery_used instanceof String) + item_skill_mastery_used = (String) mastery_used; item_parry_anim_id = ((Long) jsonObject.get("item_parry_anim_id")).intValue(); @@ -258,10 +250,8 @@ public class ItemTemplate { for (Object o : skill_required) { JSONObject skill_req = (JSONObject) o; String skill_type = (String) skill_req.get("skill_type"); - skill_type = skill_type.replaceAll("\\s", ""); - skill_type = skill_type.replaceAll(",", ""); int skill_level = ((Long) skill_req.get("skill_level")).intValue(); - item_skill_required.put(Enum.CharacterSkills.valueOf(skill_type), skill_level); + item_skill_required.put(skill_type, skill_level); } JSONObject race_required = (JSONObject) jsonObject.get("item_race_req"); diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 2f0da902..035e7fd3 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -5485,7 +5485,7 @@ public class PlayerCharacter extends AbstractCharacter { public float getBargain() { float bargain = 0; - CharacterSkill bargainSkill = this.getSkills().get(engine.Enum.CharacterSkills.Bargaining.name()); + CharacterSkill bargainSkill = this.getSkills().get("Bargaining"); if (bargainSkill != null) bargain = bargainSkill.getModifiedAmountBeforeMods();