|
|
|
@ -10,7 +10,6 @@
@@ -10,7 +10,6 @@
|
|
|
|
|
package engine.objects; |
|
|
|
|
|
|
|
|
|
import engine.Enum; |
|
|
|
|
import engine.Enum.GameObjectType; |
|
|
|
|
import engine.Enum.ItemType; |
|
|
|
|
import engine.gameManager.DbManager; |
|
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
@ -19,7 +18,6 @@ import java.sql.ResultSet;
@@ -19,7 +18,6 @@ import java.sql.ResultSet;
|
|
|
|
|
import java.sql.SQLException; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
|
|
|
|
|
|
public class ItemBase { |
|
|
|
|
|
|
|
|
@ -27,11 +25,10 @@ public class ItemBase {
@@ -27,11 +25,10 @@ public class ItemBase {
|
|
|
|
|
public static int GOLD_BASE_ID = 7; |
|
|
|
|
public static ArrayList<Integer> AnniversaryGifts = new ArrayList<>(); |
|
|
|
|
public static HashMap<Integer, ItemBase> _itemBaseByUUID = new HashMap<>(); |
|
|
|
|
// Internal cache
|
|
|
|
|
private static final HashMap<Integer, Integer> itemHashIDMap = new HashMap<>(); |
|
|
|
|
private static final HashMap<String, Integer> _IDsByNames = new HashMap<>(); |
|
|
|
|
private static final ArrayList<ItemBase> _resourceList = new ArrayList<>(); |
|
|
|
|
private final int uuid; |
|
|
|
|
public final int uuid; |
|
|
|
|
|
|
|
|
|
//requirements/restrictions
|
|
|
|
|
private final ItemType type; |
|
|
|
@ -44,7 +41,6 @@ public class ItemBase {
@@ -44,7 +41,6 @@ public class ItemBase {
|
|
|
|
|
// Armor and weapon related values
|
|
|
|
|
private final String skillRequired; |
|
|
|
|
private final short percentRequired; |
|
|
|
|
private final float blockMod; |
|
|
|
|
private final short defense; |
|
|
|
|
private final float dexPenalty; |
|
|
|
|
private final float speed; |
|
|
|
@ -59,14 +55,10 @@ public class ItemBase {
@@ -59,14 +55,10 @@ public class ItemBase {
|
|
|
|
|
// Item stat modifiers
|
|
|
|
|
private final HashMap<Integer, Integer> bakedInStats = new HashMap<>(); |
|
|
|
|
private final HashMap<Integer, Integer> usedStats = new HashMap<>(); |
|
|
|
|
private final float parryBonus; |
|
|
|
|
private final boolean isStrBased; |
|
|
|
|
private ArrayList<Integer> animations = new ArrayList<>(); |
|
|
|
|
private ArrayList<Integer> offHandAnimations = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* ResultSet Constructor |
|
|
|
|
*/ |
|
|
|
|
public ItemBase(ResultSet rs) throws SQLException { |
|
|
|
|
|
|
|
|
|
this.uuid = rs.getInt("ID"); |
|
|
|
@ -81,10 +73,8 @@ public class ItemBase {
@@ -81,10 +73,8 @@ public class ItemBase {
|
|
|
|
|
this.isConsumable = false; |
|
|
|
|
this.skillRequired = rs.getString("skillRequired"); |
|
|
|
|
this.percentRequired = rs.getShort("percentRequired"); |
|
|
|
|
this.blockMod = rs.getFloat("blockMod"); |
|
|
|
|
this.defense = rs.getShort("defense"); |
|
|
|
|
this.dexPenalty = rs.getFloat("dexPenalty"); |
|
|
|
|
this.parryBonus = rs.getFloat("parryBonus"); |
|
|
|
|
this.isStrBased = (rs.getInt("isStrBased") == 1); |
|
|
|
|
this.speed = rs.getFloat("speed"); |
|
|
|
|
this.range = rs.getFloat("range"); |
|
|
|
@ -145,19 +135,11 @@ public class ItemBase {
@@ -145,19 +135,11 @@ public class ItemBase {
|
|
|
|
|
return itemHashIDMap; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
* Database |
|
|
|
|
*/ |
|
|
|
|
public static ItemBase getItemBase(int uuid) { |
|
|
|
|
|
|
|
|
|
return _itemBaseByUUID.get(uuid); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get the ItemBase instance for Gold. |
|
|
|
|
* |
|
|
|
|
* @return ItemBase for Gold |
|
|
|
|
*/ |
|
|
|
|
public static ItemBase getGoldItemBase() { |
|
|
|
|
if (ItemBase.GOLD_ITEM_BASE == null) |
|
|
|
|
ItemBase.GOLD_ITEM_BASE = getItemBase(7); |
|
|
|
@ -170,16 +152,10 @@ public class ItemBase {
@@ -170,16 +152,10 @@ public class ItemBase {
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @return the _itemBaseByUUID |
|
|
|
|
*/ |
|
|
|
|
public static HashMap<Integer, ItemBase> getUUIDCache() { |
|
|
|
|
return _itemBaseByUUID; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @return the _resourceList |
|
|
|
|
*/ |
|
|
|
|
public static ArrayList<ItemBase> getResourceList() { |
|
|
|
|
return _resourceList; |
|
|
|
|
} |
|
|
|
@ -271,59 +247,6 @@ public class ItemBase {
@@ -271,59 +247,6 @@ public class ItemBase {
|
|
|
|
|
return hashID; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public boolean canEquip(Enum.EquipSlotType slot, CharacterItemManager itemManager, AbstractCharacter abstractCharacter, Item item) { |
|
|
|
|
|
|
|
|
|
if (itemManager == null || abstractCharacter == null) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
if (abstractCharacter.getObjectType().equals(GameObjectType.PlayerCharacter)) { |
|
|
|
|
|
|
|
|
|
if (!validForSlot(slot, itemManager.getEquipped(), item)) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
if (!ItemTemplate.validForSkills(item, abstractCharacter.getSkills())) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
if (ItemTemplate.canCharacterEquip(item, abstractCharacter) == false) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
return item.template.item_value != 0 || Kit.IsNoobGear(item.getItemBase().uuid); |
|
|
|
|
//players can't wear 0 value items.
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return true; //Mobiles and NPC's don't need to check equip
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static boolean validForSlot(Enum.EquipSlotType slot, ConcurrentHashMap<Enum.EquipSlotType, Item> equipped, Item item) { |
|
|
|
|
|
|
|
|
|
boolean validSlot = false; |
|
|
|
|
|
|
|
|
|
if (equipped == null) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
// Slot is taken
|
|
|
|
|
|
|
|
|
|
if (equipped.get(slot) != null && equipped.get(slot).equals(item) == false) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
// Two handed weapons take up two slots
|
|
|
|
|
|
|
|
|
|
if ((ItemTemplate.isTwoHanded(item)) && |
|
|
|
|
((slot == Enum.EquipSlotType.LHELD && equipped.get(Enum.EquipSlotType.RHELD) != null) || |
|
|
|
|
(slot == Enum.EquipSlotType.RHELD && equipped.get(Enum.EquipSlotType.LHELD) != null))) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
if (item.template.item_type.equals(ItemType.WEAPON)) |
|
|
|
|
if (equipped.get(slot) != null && equipped.get(slot).equals(item) == false) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @return the uuid |
|
|
|
|
*/ |
|
|
|
|
public final int getUUID() { |
|
|
|
|
return uuid; |
|
|
|
|
} |
|
|
|
@ -332,72 +255,42 @@ public class ItemBase {
@@ -332,72 +255,42 @@ public class ItemBase {
|
|
|
|
|
return this.twoHanded; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @return the skillRequired |
|
|
|
|
*/ |
|
|
|
|
public String getSkillRequired() { |
|
|
|
|
return skillRequired; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @return the mastery |
|
|
|
|
*/ |
|
|
|
|
public String getMastery() { |
|
|
|
|
return mastery; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @return the defense |
|
|
|
|
*/ |
|
|
|
|
public short getDefense() { |
|
|
|
|
return defense; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @return the dexPenalty |
|
|
|
|
*/ |
|
|
|
|
public float getDexPenalty() { |
|
|
|
|
return dexPenalty; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @return the speed |
|
|
|
|
*/ |
|
|
|
|
public float getSpeed() { |
|
|
|
|
return speed; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @return the range |
|
|
|
|
*/ |
|
|
|
|
public float getRange() { |
|
|
|
|
return range; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @return the isStrBased |
|
|
|
|
*/ |
|
|
|
|
public boolean isStrBased() { |
|
|
|
|
return isStrBased; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @return the maxDamage |
|
|
|
|
*/ |
|
|
|
|
public short getMaxDamage() { |
|
|
|
|
return maxDamage; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @return the minDamage |
|
|
|
|
*/ |
|
|
|
|
public short getMinDamage() { |
|
|
|
|
return minDamage; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @return the damageType |
|
|
|
|
*/ |
|
|
|
|
public Enum.SourceType getDamageType() { |
|
|
|
|
return damageType; |
|
|
|
|
} |
|
|
|
|