From f6169372366bf5ac6a7adb6f2fd3b1bc954aa559 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 10 Mar 2024 14:10:51 -0400 Subject: [PATCH] Refactor skill_used --- src/engine/gameManager/CombatManager.java | 3 ++- src/engine/objects/ItemBase.java | 8 -------- src/engine/objects/ItemFactory.java | 4 ++-- src/engine/objects/Mob.java | 8 ++++---- src/engine/objects/PlayerCharacter.java | 12 ++++++------ 5 files changed, 14 insertions(+), 21 deletions(-) diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index 9c8d607f..62147bc9 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -1037,8 +1037,9 @@ public enum CombatManager { } } + ItemTemplate template = ItemTemplate.itemTemplates.get(wb.getUUID()); - String required = wb.getSkillRequired(); + String required = template.item_skill_used; String mastery = wb.getMastery(); if (required.equals("Unarmed Combat")) diff --git a/src/engine/objects/ItemBase.java b/src/engine/objects/ItemBase.java index c5bdcc2c..3cc4d8f9 100644 --- a/src/engine/objects/ItemBase.java +++ b/src/engine/objects/ItemBase.java @@ -35,8 +35,6 @@ public class ItemBase { private int hashID; private final byte useAmount; - // Armor and weapon related values - private final String skillRequired; private final short percentRequired; private final short defense; private final float dexPenalty; @@ -65,7 +63,6 @@ public class ItemBase { this.hashID = rs.getInt("itemHashID"); this.isConsumable = false; - this.skillRequired = rs.getString("skillRequired"); this.percentRequired = rs.getShort("percentRequired"); this.defense = rs.getShort("defense"); this.dexPenalty = rs.getFloat("dexPenalty"); @@ -248,11 +245,6 @@ public class ItemBase { public boolean isTwoHanded() { return this.twoHanded; } - - public String getSkillRequired() { - return skillRequired; - } - public String getMastery() { return mastery; } diff --git a/src/engine/objects/ItemFactory.java b/src/engine/objects/ItemFactory.java index ca048ea2..4cdde82b 100644 --- a/src/engine/objects/ItemFactory.java +++ b/src/engine/objects/ItemFactory.java @@ -221,7 +221,7 @@ public class ItemFactory { if (template.item_type.equals(ItemType.WEAPON) && ib.getPercentRequired() == 110) { - switch (ib.getSkillRequired()) { + switch (template.item_skill_used) { case "Bow": case "Crossbow": case "Spear": @@ -815,7 +815,7 @@ public class ItemFactory { int wormwoodAmount = 0; if (template.item_type.equals(ItemType.WEAPON) && ib.getPercentRequired() == 110) { - switch (ib.getSkillRequired()) { + switch (template.item_skill_used) { case "Bow": case "Crossbow": case "Spear": diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 69a1c315..055b56f7 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1243,7 +1243,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed { skill = null; mastery = null; } else { - skill = this.skills.get(wb.getSkillRequired()); + skill = this.skills.get(weapon.template.item_skill_used); mastery = this.skills.get(wb.getMastery()); } @@ -1298,10 +1298,10 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed { if (!armor.template.item_type.equals(ItemType.ARMOR)) return 0; - if (ib.getSkillRequired().isEmpty()) + if (armor.template.item_skill_used.isEmpty()) return ib.getDefense(); - CharacterSkill armorSkill = this.skills.get(ib.getSkillRequired()); + CharacterSkill armorSkill = this.skills.get(armor.template.item_skill_used); if (armorSkill == null) return ib.getDefense(); @@ -1372,7 +1372,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed { else this.rangeHandTwo = weapon.getItemBase().getRange() * (1 + (baseStrength / 600.0f)); - skillPercentage = getModifiedAmount(this.skills.get(wb.getSkillRequired())); + skillPercentage = getModifiedAmount(this.skills.get(weapon.template.item_skill_used)); masteryPercentage = getModifiedAmount(this.skills.get(wb.getMastery())); if (masteryPercentage == 0f) diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 7ded1e94..9f9e5e72 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -2841,11 +2841,11 @@ public class PlayerCharacter extends AbstractCharacter { if (ib != null) { if ((item.template.item_type.equals(ItemType.WEAPON)) - && (ib.getSkillRequired().equals(type) || ib.getMastery().equals(type))) + && (item.template.item_skill_used.equals(type) || ib.getMastery().equals(type))) return true; return (item.template.item_type.equals(ItemType.ARMOR)) - && (ib.getSkillRequired().equals(type)); + && (item.template.item_skill_used.equals(type)); } return false; @@ -3919,7 +3919,7 @@ public class PlayerCharacter extends AbstractCharacter { this.rangeHandTwo *= range_bonus; } - skillPercentage = getModifiedAmount(this.skills.get(wb.getSkillRequired())); + skillPercentage = getModifiedAmount(this.skills.get(weapon.template.item_skill_used)); masteryPercentage = getModifiedAmount(this.skills.get(wb.getMastery())); if (masteryPercentage == 0f) mastDam = 0f; @@ -4174,10 +4174,10 @@ public class PlayerCharacter extends AbstractCharacter { if (!armor.template.item_type.equals(ItemType.ARMOR)) return 0; - if (ib.getSkillRequired().isEmpty()) + if (armor.template.item_skill_used.isEmpty()) return ib.getDefense(); - CharacterSkill armorSkill = this.skills.get(ib.getSkillRequired()); + CharacterSkill armorSkill = this.skills.get(armor.template.item_skill_used); if (armorSkill == null) { Logger.error("Player " + this.getObjectUUID() + " has armor equipped without the nescessary skill to equip it"); @@ -4218,7 +4218,7 @@ public class PlayerCharacter extends AbstractCharacter { skill = this.skills.get("Unarmed Combat"); mastery = this.skills.get("Unarmed Combat Mastery"); } else { - skill = this.skills.get(wb.getSkillRequired()); + skill = this.skills.get(weapon.template.item_skill_used); mastery = this.skills.get(wb.getMastery()); } if (skill != null)