diff --git a/src/engine/db/handlers/dbSkillReqHandler.java b/src/engine/db/handlers/dbSkillReqHandler.java index b0e16f90..6025b7c6 100644 --- a/src/engine/db/handlers/dbSkillReqHandler.java +++ b/src/engine/db/handlers/dbSkillReqHandler.java @@ -9,9 +9,14 @@ package engine.db.handlers; +import engine.objects.PreparedStatementShared; import engine.objects.SkillReq; +import engine.powers.PowersBase; +import org.pmw.tinylog.Logger; +import java.sql.ResultSet; import java.util.ArrayList; +import java.util.HashMap; public class dbSkillReqHandler extends dbHandlerBase { @@ -20,16 +25,61 @@ public class dbSkillReqHandler extends dbHandlerBase { this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName()); } + public static ArrayList getAllPowersBase() { + PreparedStatementShared ps = null; + ArrayList out = new ArrayList<>(); + try { + ps = new PreparedStatementShared("SELECT * FROM static_power_powerbase"); + ResultSet rs = ps.executeQuery(); + while (rs.next()) { + PowersBase toAdd = new PowersBase(rs); + out.add(toAdd); + } + rs.close(); + } catch (Exception e) { + Logger.error(e.toString()); + } finally { + ps.release(); + } + return out; + } + + public static void getFailConditions(HashMap powers) { + PreparedStatementShared ps = null; + try { + ps = new PreparedStatementShared("SELECT IDString, type FROM static_power_failcondition where powerOrEffect = 'Power'"); + ResultSet rs = ps.executeQuery(); + String type, IDString; + PowersBase pb; + while (rs.next()) { + type = rs.getString("type"); + IDString = rs.getString("IDString"); + pb = powers.get(IDString); + if (pb != null) { + switch (type) { + case "CastSpell": + pb.cancelOnCastSpell = true; + break; + case "TakeDamage": + pb.cancelOnTakeDamage = true; + break; + } + } else { + Logger.error("null power for Grief " + IDString); + } + } + rs.close(); + } catch (Exception e) { + Logger.error(e.toString()); + } finally { + ps.release(); + } + } + public ArrayList GET_REQS_FOR_RUNE(final int objectUUID) { prepareCallable("SELECT * FROM `static_skill_skillreq` WHERE `runeID`=?"); setInt(1, objectUUID); return getObjectList(); } - - public SkillReq GET_REQS_BY_SKILLID(int skillID) { - prepareCallable("SELECT * FROM `static_skill_skillreq` WHERE `skillID` = ?"); - setInt(1,skillID); - int objectUUID = (int) getUUID(); - return (SkillReq) this.getObjectSingle(objectUUID); - } + } diff --git a/src/engine/gameManager/PowersManager.java b/src/engine/gameManager/PowersManager.java index eeaf9c47..59a4aa36 100644 --- a/src/engine/gameManager/PowersManager.java +++ b/src/engine/gameManager/PowersManager.java @@ -12,6 +12,7 @@ import engine.Enum.*; import engine.InterestManagement.HeightMap; import engine.InterestManagement.WorldGrid; import engine.db.handlers.dbEffectsBaseHandler; +import engine.db.handlers.dbSkillReqHandler; import engine.job.AbstractJob; import engine.job.AbstractScheduleJob; import engine.job.JobContainer; @@ -100,7 +101,7 @@ public enum PowersManager { public static void InitializeLoginPowers() { // get all PowersBase - ArrayList pbList = PowersBase.getAllPowersBase(); + ArrayList pbList = dbSkillReqHandler.getAllPowersBase(); for (PowersBase pb : pbList) { if (pb.getToken() != 0) @@ -137,7 +138,7 @@ public enum PowersManager { // AbstractPowerAction.loadValidItemFlags(PowersManager.powerActionsByIDString); // get all PowersBase - ArrayList pbList = PowersBase.getAllPowersBase(); + ArrayList pbList = dbSkillReqHandler.getAllPowersBase(); for (PowersBase pb : pbList) { if (pb.getToken() != 0) { PowersManager.powersBaseByIDString.put(pb.getIDString(), pb); @@ -148,7 +149,7 @@ public enum PowersManager { // Add Power Prereqs PowerPrereq.getAllPowerPrereqs(PowersManager.powersBaseByIDString); // Add Fail Conditions - PowersBase.getFailConditions(PowersManager.powersBaseByIDString); + dbSkillReqHandler.getFailConditions(PowersManager.powersBaseByIDString); // Add Actions Base ActionsBase.getActionsBase(PowersManager.powersBaseByIDString, PowersManager.powerActionsByIDString); diff --git a/src/engine/powers/PowersBase.java b/src/engine/powers/PowersBase.java index 89e4aa37..ca24eb06 100644 --- a/src/engine/powers/PowersBase.java +++ b/src/engine/powers/PowersBase.java @@ -11,13 +11,11 @@ package engine.powers; import engine.Enum.PowerCategoryType; import engine.Enum.PowerTargetType; -import engine.objects.PreparedStatementShared; import org.pmw.tinylog.Logger; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; -import java.util.HashMap; public class PowersBase { @@ -340,57 +338,6 @@ public class PowersBase { this.monsterTypeRestrictions.add(ct); } - public static ArrayList getAllPowersBase() { - PreparedStatementShared ps = null; - ArrayList out = new ArrayList<>(); - try { - ps = new PreparedStatementShared("SELECT * FROM static_power_powerbase"); - ResultSet rs = ps.executeQuery(); - while (rs.next()) { - PowersBase toAdd = new PowersBase(rs); - out.add(toAdd); - } - rs.close(); - } catch (Exception e) { - Logger.error( e.toString()); - } finally { - ps.release(); - } - return out; - } - - - public static void getFailConditions(HashMap powers) { - PreparedStatementShared ps = null; - try { - ps = new PreparedStatementShared("SELECT IDString, type FROM static_power_failcondition where powerOrEffect = 'Power'"); - ResultSet rs = ps.executeQuery(); - String type, IDString; PowersBase pb; - while (rs.next()) { - type = rs.getString("type"); - IDString = rs.getString("IDString"); - pb = powers.get(IDString); - if (pb != null) { - switch (type) { - case "CastSpell": - pb.cancelOnCastSpell = true; - break; - case "TakeDamage": - pb.cancelOnTakeDamage = true; - break; - } - }else{ - Logger.error("null power for Grief " + IDString); - } - } - rs.close(); - } catch (Exception e) { - Logger.error( e.toString()); - } finally { - ps.release(); - } - } - public String getName() { return this.name;