|
|
@ -19,17 +19,15 @@ import org.pmw.tinylog.Logger; |
|
|
|
import java.sql.ResultSet; |
|
|
|
import java.sql.ResultSet; |
|
|
|
import java.sql.SQLException; |
|
|
|
import java.sql.SQLException; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.EnumSet; |
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashSet; |
|
|
|
import java.util.HashSet; |
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
|
|
|
|
|
|
|
|
public class ItemBase { |
|
|
|
public class ItemBase { |
|
|
|
|
|
|
|
|
|
|
|
public static final byte GOLD_BASE_TYPE = 4; |
|
|
|
|
|
|
|
public static ItemBase GOLD_ITEM_BASE = null; |
|
|
|
public static ItemBase GOLD_ITEM_BASE = null; |
|
|
|
public static int GOLD_BASE_ID = 7; |
|
|
|
public static int GOLD_BASE_ID = 7; |
|
|
|
public static ArrayList<Integer> AnniverseryGifts = new ArrayList<>(); |
|
|
|
public static ArrayList<Integer> AnniversaryGifts = new ArrayList<>(); |
|
|
|
public static HashMap<Integer, ItemBase> _itemBaseByUUID = new HashMap<>(); |
|
|
|
public static HashMap<Integer, ItemBase> _itemBaseByUUID = new HashMap<>(); |
|
|
|
public static HashMap<engine.Enum.ItemType, HashSet<ItemBase>> ItemBaseTypeMap = new HashMap<>(); |
|
|
|
public static HashMap<engine.Enum.ItemType, HashSet<ItemBase>> ItemBaseTypeMap = new HashMap<>(); |
|
|
|
// Internal cache
|
|
|
|
// Internal cache
|
|
|
@ -37,15 +35,8 @@ public class ItemBase { |
|
|
|
private static final HashMap<String, Integer> _IDsByNames = new HashMap<>(); |
|
|
|
private static final HashMap<String, Integer> _IDsByNames = new HashMap<>(); |
|
|
|
private static final ArrayList<ItemBase> _resourceList = new ArrayList<>(); |
|
|
|
private static final ArrayList<ItemBase> _resourceList = new ArrayList<>(); |
|
|
|
private final int uuid; |
|
|
|
private final int uuid; |
|
|
|
// private String name;
|
|
|
|
|
|
|
|
//requirements/restrictions
|
|
|
|
//requirements/restrictions
|
|
|
|
public EnumSet<Enum.MonsterType> restrictedRaces; |
|
|
|
|
|
|
|
public EnumSet<Enum.MonsterType> requiredRaces; |
|
|
|
|
|
|
|
public EnumSet<Enum.ClassType> restrictedClasses; |
|
|
|
|
|
|
|
public EnumSet<Enum.ClassType> requiredClasses; |
|
|
|
|
|
|
|
public EnumSet<Enum.DisciplineType> requiredDiscs; |
|
|
|
|
|
|
|
public EnumSet<Enum.DisciplineType> restrictedDiscs; |
|
|
|
|
|
|
|
private final short color; |
|
|
|
|
|
|
|
private final ItemType type; |
|
|
|
private final ItemType type; |
|
|
|
private int vendorType; |
|
|
|
private int vendorType; |
|
|
|
private final int modTable; |
|
|
|
private final int modTable; |
|
|
@ -85,7 +76,6 @@ public class ItemBase { |
|
|
|
|
|
|
|
|
|
|
|
this.uuid = rs.getInt("ID"); |
|
|
|
this.uuid = rs.getInt("ID"); |
|
|
|
|
|
|
|
|
|
|
|
this.color = rs.getShort("color"); |
|
|
|
|
|
|
|
this.type = ItemType.valueOf(rs.getString("Type")); |
|
|
|
this.type = ItemType.valueOf(rs.getString("Type")); |
|
|
|
this.useID = rs.getInt("useID"); |
|
|
|
this.useID = rs.getInt("useID"); |
|
|
|
this.vendorType = rs.getInt("vendorType"); |
|
|
|
this.vendorType = rs.getInt("vendorType"); |
|
|
@ -109,13 +99,6 @@ public class ItemBase { |
|
|
|
this.minDamage = rs.getShort("minDamage"); |
|
|
|
this.minDamage = rs.getShort("minDamage"); |
|
|
|
this.maxDamage = rs.getShort("maxDamage"); |
|
|
|
this.maxDamage = rs.getShort("maxDamage"); |
|
|
|
|
|
|
|
|
|
|
|
// Item restrictions and requirements
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.requiredRaces = DbManager.parseEnumSet(rs.getString("race_required"), Enum.MonsterType.class); |
|
|
|
|
|
|
|
this.restrictedRaces = DbManager.parseEnumSet(rs.getString("race_restricted"), Enum.MonsterType.class); |
|
|
|
|
|
|
|
this.requiredClasses = DbManager.parseEnumSet(rs.getString("class_required"), Enum.ClassType.class); |
|
|
|
|
|
|
|
this.requiredDiscs = DbManager.parseEnumSet(rs.getString("disc_required"), Enum.DisciplineType.class); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.mastery = rs.getString("mastery"); |
|
|
|
this.mastery = rs.getString("mastery"); |
|
|
|
damageType = Enum.SourceType.valueOf(rs.getString("damageType").toUpperCase()); |
|
|
|
damageType = Enum.SourceType.valueOf(rs.getString("damageType").toUpperCase()); |
|
|
|
|
|
|
|
|
|
|
@ -214,25 +197,25 @@ public class ItemBase { |
|
|
|
public static void loadAllItemBases() { |
|
|
|
public static void loadAllItemBases() { |
|
|
|
DbManager.ItemBaseQueries.LOAD_ALL_ITEMBASES(); |
|
|
|
DbManager.ItemBaseQueries.LOAD_ALL_ITEMBASES(); |
|
|
|
|
|
|
|
|
|
|
|
AnniverseryGifts.add(971000); |
|
|
|
AnniversaryGifts.add(971000); |
|
|
|
AnniverseryGifts.add(971001); |
|
|
|
AnniversaryGifts.add(971001); |
|
|
|
AnniverseryGifts.add(971002); |
|
|
|
AnniversaryGifts.add(971002); |
|
|
|
AnniverseryGifts.add(971003); |
|
|
|
AnniversaryGifts.add(971003); |
|
|
|
AnniverseryGifts.add(971004); |
|
|
|
AnniversaryGifts.add(971004); |
|
|
|
AnniverseryGifts.add(971005); |
|
|
|
AnniversaryGifts.add(971005); |
|
|
|
AnniverseryGifts.add(971006); |
|
|
|
AnniversaryGifts.add(971006); |
|
|
|
AnniverseryGifts.add(971007); |
|
|
|
AnniversaryGifts.add(971007); |
|
|
|
AnniverseryGifts.add(971008); |
|
|
|
AnniversaryGifts.add(971008); |
|
|
|
AnniverseryGifts.add(971009); |
|
|
|
AnniversaryGifts.add(971009); |
|
|
|
AnniverseryGifts.add(971010); |
|
|
|
AnniversaryGifts.add(971010); |
|
|
|
AnniverseryGifts.add(5101000); |
|
|
|
AnniversaryGifts.add(5101000); |
|
|
|
AnniverseryGifts.add(5101020); |
|
|
|
AnniversaryGifts.add(5101020); |
|
|
|
AnniverseryGifts.add(5101100); |
|
|
|
AnniversaryGifts.add(5101100); |
|
|
|
AnniverseryGifts.add(5101120); |
|
|
|
AnniversaryGifts.add(5101120); |
|
|
|
AnniverseryGifts.add(5101040); |
|
|
|
AnniversaryGifts.add(5101040); |
|
|
|
AnniverseryGifts.add(5101140); |
|
|
|
AnniversaryGifts.add(5101140); |
|
|
|
AnniverseryGifts.add(5101060); |
|
|
|
AnniversaryGifts.add(5101060); |
|
|
|
AnniverseryGifts.add(5101080); |
|
|
|
AnniversaryGifts.add(5101080); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
@ -402,20 +385,6 @@ public class ItemBase { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean validForSkills(ConcurrentHashMap<String, CharacterSkill> skills) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CharacterSkill characterSkill; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.skillRequired.isEmpty()) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
characterSkill = skills.get(this.skillRequired); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (characterSkill == null) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return !(this.percentRequired > characterSkill.getModifiedAmountBeforeMods()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean canEquip(int slot, CharacterItemManager itemManager, AbstractCharacter abstractCharacter, Item item) { |
|
|
|
public boolean canEquip(int slot, CharacterItemManager itemManager, AbstractCharacter abstractCharacter, Item item) { |
|
|
|
|
|
|
|
|
|
|
@ -427,10 +396,10 @@ public class ItemBase { |
|
|
|
if (!validForSlot(slot, itemManager.getEquipped(), item)) |
|
|
|
if (!validForSlot(slot, itemManager.getEquipped(), item)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
if (!validForSkills(abstractCharacter.getSkills())) |
|
|
|
if (!ItemTemplate.validForSkills(item, abstractCharacter.getSkills())) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
if (this.canCharacterEquip(abstractCharacter) == false) |
|
|
|
if (ItemTemplate.canCharacterEquip(item, abstractCharacter) == false) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
return item.template.item_value != 0 || Kit.IsNoobGear(item.getItemBase().uuid); |
|
|
|
return item.template.item_value != 0 || Kit.IsNoobGear(item.getItemBase().uuid); |
|
|
@ -873,54 +842,4 @@ public class ItemBase { |
|
|
|
return this.isClothArmor(); |
|
|
|
return this.isClothArmor(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Boolean canCharacterEquip(AbstractCharacter character) { |
|
|
|
|
|
|
|
return ValidRace(character.absRace) && ValidClass(character.absBaseClass, character.absPromotionClass) && ValidDiscipline(character.absDisciplines); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Boolean ValidRace(Enum.MonsterType race) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.requiredRaces.isEmpty() && this.restrictedRaces.isEmpty()) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.requiredRaces.isEmpty() == false && race.elementOf(this.requiredRaces) == true) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return this.restrictedRaces.isEmpty() == false && race.elementOf(this.restrictedRaces) == false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Boolean ValidClass(Enum.ClassType base, Enum.ClassType profession) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean requiredEmpty = this.requiredClasses == null || this.requiredClasses.isEmpty(); |
|
|
|
|
|
|
|
boolean restrictedEmpty = this.restrictedClasses == null || this.restrictedClasses.isEmpty(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (requiredEmpty && restrictedEmpty) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.requiredClasses != null && this.requiredClasses.isEmpty() == false) |
|
|
|
|
|
|
|
if (this.requiredClasses.contains(base) || this.requiredClasses.contains(profession)) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.restrictedClasses != null && this.restrictedClasses.isEmpty() == false) |
|
|
|
|
|
|
|
return this.restrictedClasses.contains(base) == false && this.restrictedClasses.contains(profession) == false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Boolean ValidDiscipline(EnumSet<Enum.DisciplineType> discs) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean requiredEmpty = this.requiredDiscs == null || this.requiredDiscs.isEmpty(); |
|
|
|
|
|
|
|
boolean restrictedEmpty = this.restrictedDiscs == null || this.restrictedDiscs.isEmpty(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (requiredEmpty && restrictedEmpty) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (Enum.DisciplineType disc : discs) { |
|
|
|
|
|
|
|
if (this.requiredDiscs.isEmpty() == false && this.requiredDiscs.contains(disc)) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.restrictedDiscs.isEmpty() == false && this.restrictedDiscs.contains(disc)) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|