Browse Source

rollTable() method added to loot classes.

master
MagicBot 1 year ago
parent
commit
8a5924eeee
  1. 17
      src/engine/loot/GenTableEntry.java
  2. 17
      src/engine/loot/ItemTableEntry.java
  3. 17
      src/engine/loot/ModTableEntry.java
  4. 17
      src/engine/loot/ModTypeTableEntry.java
  5. 53
      src/engine/objects/LootTable.java

17
src/engine/loot/GenTableEntry.java

@ -8,8 +8,11 @@ @@ -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 { @@ -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<GenTableEntry> genTableEntryList;
genTableEntryList = LootManager._genTables.get(genTable);
for (GenTableEntry iteration : genTableEntryList)
if (roll >= iteration.minRoll && roll <= iteration.maxRoll)
genTableEntry = iteration;
return genTableEntry;
}
}

17
src/engine/loot/ItemTableEntry.java

@ -8,8 +8,11 @@ @@ -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 { @@ -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<ItemTableEntry> itemTableEntryList;
itemTableEntryList = LootManager._itemTables.get(itemTable);
for (ItemTableEntry iteration : itemTableEntryList)
if (roll >= iteration.minRoll && roll <= iteration.maxRoll)
itemTableEntry = iteration;
return itemTableEntry;
}
}

17
src/engine/loot/ModTableEntry.java

@ -8,8 +8,11 @@ @@ -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 { @@ -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<ModTableEntry> itemTableEntryList;
itemTableEntryList = LootManager._modTables.get(modTablwe);
for (ModTableEntry iteration : itemTableEntryList)
if (roll >= iteration.minRoll && roll <= iteration.maxRoll)
modTableEntry = iteration;
return modTableEntry;
}
}

17
src/engine/loot/ModTypeTableEntry.java

@ -8,8 +8,11 @@ @@ -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 { @@ -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<ModTypeTableEntry> modTypeTableEntryList;
modTypeTableEntryList = LootManager._modTypeTables.get(modTablwe);
for (ModTypeTableEntry iteration : modTypeTableEntryList)
if (roll >= iteration.minRoll && roll <= iteration.maxRoll)
modTypeTableEntry = iteration;
return modTypeTableEntry;
}
}

53
src/engine/objects/LootTable.java

@ -15,10 +15,7 @@ import java.util.HashMap; @@ -15,10 +15,7 @@ import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;
public class LootTable {
private static final ConcurrentHashMap<Integer, LootTable> genTables = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
private static final ConcurrentHashMap<Integer, LootTable> itemTables = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
private static final ConcurrentHashMap<Integer, LootTable> modTables = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
private static final ConcurrentHashMap<Integer, LootTable> modTables = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
private static final ConcurrentHashMap<Integer, LootTable> modTypeTables = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
private static final ConcurrentHashMap<Integer, Integer> 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 { @@ -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<Integer, LootTable> getGenTables() {
return genTables;
}
/**
* @return the lootTables
*/
public static ConcurrentHashMap<Integer, LootTable> getItemTables() {
return itemTables;
}
/**
* @return the modTables
*/
public static ConcurrentHashMap<Integer, LootTable> getModTables() {
return modTables;
}
/**
* @return the modGroups
*/
public static ConcurrentHashMap<Integer, LootTable> getModTypeTables() {
return modTypeTables;
}
public static LootTable getModTypeTable(int UUID) {

Loading…
Cancel
Save