diff --git a/src/engine/loot/GenTableEntry.java b/src/engine/loot/GenTableEntry.java index b615121e..b7b3c625 100644 --- a/src/engine/loot/GenTableEntry.java +++ b/src/engine/loot/GenTableEntry.java @@ -8,8 +8,11 @@ package engine.loot; +import engine.gameManager.LootManager; + import java.sql.ResultSet; import java.sql.SQLException; +import java.util.List; public class GenTableEntry { public int minRoll; @@ -25,4 +28,18 @@ public class GenTableEntry { this.pModTable = rs.getInt("pModTableID"); this.sModTable = rs.getInt("sModTableID"); } + + public static GenTableEntry rollTable(int genTable, int roll) { + + GenTableEntry genTableEntry = null; + List genTableEntryList; + + genTableEntryList = LootManager._genTables.get(genTable); + + for (GenTableEntry iteration : genTableEntryList) + if (roll >= iteration.minRoll && roll <= iteration.maxRoll) + genTableEntry = iteration; + + return genTableEntry; + } } diff --git a/src/engine/loot/ItemTableEntry.java b/src/engine/loot/ItemTableEntry.java index ef652842..9147f217 100644 --- a/src/engine/loot/ItemTableEntry.java +++ b/src/engine/loot/ItemTableEntry.java @@ -8,8 +8,11 @@ package engine.loot; +import engine.gameManager.LootManager; + import java.sql.ResultSet; import java.sql.SQLException; +import java.util.List; public class ItemTableEntry { public int minRoll; @@ -25,4 +28,18 @@ public class ItemTableEntry { this.minSpawn = rs.getInt("minSpawn"); this.maxSpawn = rs.getInt("maxSpawn"); } + + public static ItemTableEntry rollTable(int itemTable, int roll) { + + ItemTableEntry itemTableEntry = null; + List itemTableEntryList; + + itemTableEntryList = LootManager._itemTables.get(itemTable); + + for (ItemTableEntry iteration : itemTableEntryList) + if (roll >= iteration.minRoll && roll <= iteration.maxRoll) + itemTableEntry = iteration; + + return itemTableEntry; + } } diff --git a/src/engine/loot/ModTableEntry.java b/src/engine/loot/ModTableEntry.java index 2572910a..86697880 100644 --- a/src/engine/loot/ModTableEntry.java +++ b/src/engine/loot/ModTableEntry.java @@ -8,8 +8,11 @@ package engine.loot; +import engine.gameManager.LootManager; + import java.sql.ResultSet; import java.sql.SQLException; +import java.util.List; public class ModTableEntry { public int minRoll; @@ -23,4 +26,18 @@ public class ModTableEntry { this.action = rs.getString("action"); this.level = rs.getInt("level"); } + + public static ModTableEntry rollTable(int modTablwe, int roll) { + + ModTableEntry modTableEntry = null; + List itemTableEntryList; + + itemTableEntryList = LootManager._modTables.get(modTablwe); + + for (ModTableEntry iteration : itemTableEntryList) + if (roll >= iteration.minRoll && roll <= iteration.maxRoll) + modTableEntry = iteration; + + return modTableEntry; + } } diff --git a/src/engine/loot/ModTypeTableEntry.java b/src/engine/loot/ModTypeTableEntry.java index b8cd13bd..8ed23ace 100644 --- a/src/engine/loot/ModTypeTableEntry.java +++ b/src/engine/loot/ModTypeTableEntry.java @@ -8,8 +8,11 @@ package engine.loot; +import engine.gameManager.LootManager; + import java.sql.ResultSet; import java.sql.SQLException; +import java.util.List; public class ModTypeTableEntry { public int minRoll; @@ -21,4 +24,18 @@ public class ModTypeTableEntry { this.maxRoll = rs.getInt("maxRoll"); this.modTableID = rs.getInt("subTableID"); } + + public static ModTypeTableEntry rollTable(int modTablwe, int roll) { + + ModTypeTableEntry modTypeTableEntry = null; + List modTypeTableEntryList; + + modTypeTableEntryList = LootManager._modTypeTables.get(modTablwe); + + for (ModTypeTableEntry iteration : modTypeTableEntryList) + if (roll >= iteration.minRoll && roll <= iteration.maxRoll) + modTypeTableEntry = iteration; + + return modTypeTableEntry; + } } diff --git a/src/engine/objects/LootTable.java b/src/engine/objects/LootTable.java index c9c3ebb4..47dbd4ed 100644 --- a/src/engine/objects/LootTable.java +++ b/src/engine/objects/LootTable.java @@ -15,10 +15,7 @@ import java.util.HashMap; import java.util.concurrent.ConcurrentHashMap; public class LootTable { - - private static final ConcurrentHashMap genTables = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); - private static final ConcurrentHashMap itemTables = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); - private static final ConcurrentHashMap modTables = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); +private static final ConcurrentHashMap modTables = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); private static final ConcurrentHashMap modTypeTables = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); private static final ConcurrentHashMap statRuneChances = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); public static boolean initialized = false; @@ -46,54 +43,6 @@ public class LootTable { this.lootTableID = lootTableID; } - public static LootTable getGenTable(int UUID) { - - if (genTables.containsKey(UUID)) - return genTables.get(UUID); - - LootTable lootGroup = new LootTable(UUID); - genTables.put(UUID, lootGroup); - return lootGroup; - } - - public static LootTable getItemTable(int UUID) { - - if (itemTables.containsKey(UUID)) - return itemTables.get(UUID); - - LootTable lootTable = new LootTable(UUID); - itemTables.put(UUID, lootTable); - - return lootTable; - } - - /** - * @return the lootGroups - */ - public static ConcurrentHashMap getGenTables() { - return genTables; - } - - /** - * @return the lootTables - */ - public static ConcurrentHashMap getItemTables() { - return itemTables; - } - - /** - * @return the modTables - */ - public static ConcurrentHashMap getModTables() { - return modTables; - } - - /** - * @return the modGroups - */ - public static ConcurrentHashMap getModTypeTables() { - return modTypeTables; - } public static LootTable getModTypeTable(int UUID) {