Browse Source

File reformat.

combat-2
MagicBot 9 months ago
parent
commit
d46b2dc298
  1. 155
      src/engine/objects/ItemBase.java

155
src/engine/objects/ItemBase.java

@ -34,59 +34,58 @@ public class ItemBase {
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
private static HashMap<Integer, Integer> itemHashIDMap = new HashMap<>(); private static final HashMap<Integer, Integer> itemHashIDMap = new HashMap<>();
private static HashMap<String, Integer> _IDsByNames = new HashMap<>(); private static final HashMap<String, Integer> _IDsByNames = new HashMap<>();
private static ArrayList<ItemBase> _resourceList = new ArrayList<>(); private static final ArrayList<ItemBase> _resourceList = new ArrayList<>();
private final int uuid; private final int uuid;
private final String name; private final String name;
private float durability; //requirements/restrictions
private int value; public EnumSet<Enum.MonsterType> restrictedRaces;
private short weight; public EnumSet<Enum.MonsterType> requiredRaces;
private short color; public EnumSet<Enum.ClassType> restrictedClasses;
private ItemType type; public EnumSet<Enum.ClassType> requiredClasses;
public EnumSet<Enum.DisciplineType> requiredDiscs;
public EnumSet<Enum.DisciplineType> restrictedDiscs;
private final float durability;
private final int value;
private final short weight;
private final short color;
private final ItemType type;
private int vendorType; private int vendorType;
private int modTable; private final int modTable;
private int useID; private final int useID;
private int hashID; private int hashID;
private byte useAmount; private final byte useAmount;
// Armor and weapon related values // Armor and weapon related values
private int equipFlag; private final int equipFlag;
private int restrictFlag; private final int restrictFlag;
private String skillRequired; private final String skillRequired;
private short percentRequired; private final short percentRequired;
private float slashResist; private final float slashResist;
private float crushResist; private final float crushResist;
private float pierceResist; private final float pierceResist;
private float blockMod; private final float blockMod;
private short defense; private final short defense;
private float dexPenalty; private final float dexPenalty;
private float speed; private final float speed;
private float range; private final float range;
private short minDamage; private final short minDamage;
private short maxDamage; private final short maxDamage;
private String mastery; private final String mastery;
private engine.Enum.DamageType damageType; private final engine.Enum.DamageType damageType;
private boolean twoHanded; private final boolean twoHanded;
private boolean isConsumable; private boolean isConsumable;
private boolean isStackable; private boolean isStackable;
private int numCharges; private final int numCharges;
// Item stat modifiers // Item stat modifiers
private HashMap<Integer, Integer> bakedInStats = new HashMap<>(); private final HashMap<Integer, Integer> bakedInStats = new HashMap<>();
private HashMap<Integer, Integer> usedStats = new HashMap<>(); private final HashMap<Integer, Integer> usedStats = new HashMap<>();
private float parryBonus; private final float parryBonus;
private boolean isStrBased; private final boolean isStrBased;
private ArrayList<Integer> animations = new ArrayList<>(); private ArrayList<Integer> animations = new ArrayList<>();
private ArrayList<Integer> offHandAnimations = new ArrayList<>(); private ArrayList<Integer> offHandAnimations = new ArrayList<>();
private boolean autoID = false; private boolean autoID = false;
//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;
/** /**
* ResultSet Constructor * ResultSet Constructor
*/ */
@ -324,11 +323,8 @@ public class ItemBase {
public boolean isDiscRune() { public boolean isDiscRune() {
int ID = uuid; int ID = uuid;
if (ID > 2499 && ID < 3050) { //class, discipline runes //class, discipline runes
return true; return ID > 2499 && ID < 3050;
} else {
return false;
}
} }
public boolean isGlass() { public boolean isGlass() {
@ -486,7 +482,7 @@ public class ItemBase {
if (!validForSkills(abstractCharacter.getSkills())) if (!validForSkills(abstractCharacter.getSkills()))
return false; return false;
if(this.canCharacterEquip(abstractCharacter) == false) if (this.canCharacterEquip(abstractCharacter) == false)
return false; return false;
return item.getItemBase().value != 0 || Kit.IsNoobGear(item.getItemBase().uuid); return item.getItemBase().value != 0 || Kit.IsNoobGear(item.getItemBase().uuid);
@ -496,6 +492,7 @@ public class ItemBase {
return true; //Mobiles and NPC's don't need to check equip return true; //Mobiles and NPC's don't need to check equip
} }
public int getValidSlot() { public int getValidSlot() {
int slotValue = 0; int slotValue = 0;
@ -772,19 +769,19 @@ public class ItemBase {
} }
public boolean isThrowing() { public boolean isThrowing() {
return this.mastery.equals("Throwing") ? true : false; return this.mastery.equals("Throwing");
} }
public boolean isStaff() { public boolean isStaff() {
return this.mastery.equals("Staff") ? true : false; return this.mastery.equals("Staff");
} }
public boolean isScepter() { public boolean isScepter() {
return this.mastery.equals("Benediction") ? true : false; return this.mastery.equals("Benediction");
} }
public boolean isArchery() { public boolean isArchery() {
return this.mastery.equals("Archery") ? true : false; return this.mastery.equals("Archery");
} }
public boolean isMelee() { public boolean isMelee() {
@ -935,66 +932,66 @@ public class ItemBase {
this.autoID = autoID; this.autoID = autoID;
} }
public boolean isArmor(){ public boolean isArmor() {
if(this.isHeavyArmor()) if (this.isHeavyArmor())
return true; return true;
if(this.isMediumArmor()) if (this.isMediumArmor())
return true; return true;
if(this.isLightArmor()) if (this.isLightArmor())
return true; return true;
if(this.isClothArmor()) return this.isClothArmor();
return true;
return false;
} }
public Boolean canCharacterEquip(AbstractCharacter character){
return ValidRace(character.absRace) && ValidClass(character.absBaseClass,character.absPromotionClass) && ValidDiscipline(character.absDisciplines); public Boolean canCharacterEquip(AbstractCharacter character) {
return ValidRace(character.absRace) && ValidClass(character.absBaseClass, character.absPromotionClass) && ValidDiscipline(character.absDisciplines);
} }
public Boolean ValidRace(Enum.MonsterType race){ 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) if (this.requiredRaces.isEmpty() && this.restrictedRaces.isEmpty())
return true; return true;
if(this.restrictedRaces.isEmpty() == false && race.elementOf(this.restrictedRaces) == false) if (this.requiredRaces.isEmpty() == false && race.elementOf(this.requiredRaces) == true)
return true; return true;
return false; return this.restrictedRaces.isEmpty() == false && race.elementOf(this.restrictedRaces) == false;
} }
public Boolean ValidClass(Enum.ClassType base,Enum.ClassType profession){ public Boolean ValidClass(Enum.ClassType base, Enum.ClassType profession) {
boolean requiredEmpty = this.requiredClasses == null || this.requiredClasses.isEmpty(); boolean requiredEmpty = this.requiredClasses == null || this.requiredClasses.isEmpty();
boolean restrictedEmpty = this.restrictedClasses == null || this.restrictedClasses.isEmpty(); boolean restrictedEmpty = this.restrictedClasses == null || this.restrictedClasses.isEmpty();
if(requiredEmpty && restrictedEmpty)
if (requiredEmpty && restrictedEmpty)
return true; return true;
if(this.requiredClasses != null && this.requiredClasses.isEmpty() == false) if (this.requiredClasses != null && this.requiredClasses.isEmpty() == false)
if(this.requiredClasses.contains(base) || this.requiredClasses.contains(profession)) if (this.requiredClasses.contains(base) || this.requiredClasses.contains(profession))
return true; return true;
if(this.restrictedClasses != null && this.restrictedClasses.isEmpty() == false) if (this.restrictedClasses != null && this.restrictedClasses.isEmpty() == false)
if(this.restrictedClasses.contains(base) == false && this.restrictedClasses.contains(profession) == false) return this.restrictedClasses.contains(base) == false && this.restrictedClasses.contains(profession) == false;
return true;
return false; return false;
} }
public Boolean ValidDiscipline(EnumSet<Enum.DisciplineType> discs){ public Boolean ValidDiscipline(EnumSet<Enum.DisciplineType> discs) {
boolean requiredEmpty = this.requiredDiscs == null || this.requiredDiscs.isEmpty(); boolean requiredEmpty = this.requiredDiscs == null || this.requiredDiscs.isEmpty();
boolean restrictedEmpty = this.restrictedDiscs == null || this.restrictedDiscs.isEmpty(); boolean restrictedEmpty = this.restrictedDiscs == null || this.restrictedDiscs.isEmpty();
if(requiredEmpty && restrictedEmpty)
if (requiredEmpty && restrictedEmpty)
return true; return true;
for(Enum.DisciplineType disc : discs){ for (Enum.DisciplineType disc : discs) {
if(this.requiredDiscs.isEmpty() == false && this.requiredDiscs.contains(disc)) if (this.requiredDiscs.isEmpty() == false && this.requiredDiscs.contains(disc))
return true; return true;
if(this.restrictedDiscs.isEmpty() == false && this.restrictedDiscs.contains(disc))
if (this.restrictedDiscs.isEmpty() == false && this.restrictedDiscs.contains(disc))
return false; return false;
} }
return false; return false;

Loading…
Cancel
Save