use of delta.games.lotro.lore.items.EquipmentLocation in project lotro-companion by dmorcellet.
the class ItemEditionPanelController method buildSlotCombo.
private ComboBoxController<EquipmentLocation> buildSlotCombo() {
ComboBoxController<EquipmentLocation> ctrl = new ComboBoxController<EquipmentLocation>();
ctrl.addEmptyItem("");
for (EquipmentLocation slot : EquipmentLocation.getAll()) {
ctrl.addItem(slot, slot.getLabel());
}
ctrl.selectItem(null);
return ctrl;
}
use of delta.games.lotro.lore.items.EquipmentLocation in project lotro-tools by dmorcellet.
the class LotroPlanItemsDbLoader method buildItemFromLine.
private Item buildItemFromLine(LotroPlanTable table, String line) {
String[] fieldsTrimmed = StringSplitter.split(line.trim(), '\t');
if (line.startsWith("#")) {
System.out.println("Ignored: " + line);
return null;
}
if (fieldsTrimmed.length < 2) {
_section = line.trim();
System.out.println("Section: " + _section);
return null;
}
String[] fields = StringSplitter.split(line, '\t');
// Item level
int itemLevel = NumericTools.parseInt(fields[LotroPlanTable.ITEM_LEVEL_INDEX], -1);
// Stats
ItemStatsProvider provider = table.loadStats(fields);
BasicStatsSet stats = provider.getStats(itemLevel);
FixedDecimalsInteger armorStat = stats.getStat(STAT.ARMOUR);
Item item = null;
Armour armour = null;
if (armorStat != null) {
armour = new Armour();
item = armour;
armour.setArmourValue(armorStat.intValue());
stats.removeStat(STAT.ARMOUR);
} else {
item = new Item();
}
// ID
String idStr = "";
int notesIndex = table.getNotesIndex();
if (fields.length >= notesIndex) {
idStr = fields[notesIndex].trim();
}
int id = 0;
if (idStr.startsWith("ID:")) {
idStr = idStr.substring(3).trim();
}
id = NumericTools.parseInt(idStr, -1);
if (id != -1) {
item.setIdentifier(id);
}
// Name
String name = fields[LotroPlanTable.NAME_INDEX];
if (name.startsWith("(")) {
int index = name.indexOf(')');
idStr = name.substring(1, index).trim();
id = NumericTools.parseInt(idStr, -1);
item.setIdentifier(id);
name = name.substring(index + 1).trim();
}
if (name.endsWith(":")) {
name = name.substring(0, name.length() - 1);
}
name = name.replace(' ', ' ');
if (name.endsWith("s)")) {
name = name.substring(0, name.length() - 2);
int index = name.lastIndexOf('(');
int nbSlots = NumericTools.parseInt(name.substring(index + 1), 0);
name = name.substring(0, index).trim();
item.setEssenceSlots(nbSlots);
}
if (name.endsWith(")")) {
String newName = name.substring(0, name.length() - 1);
int index = newName.lastIndexOf('(');
String valueStr = newName.substring(index + 1);
int minLevel;
if ("TBD".equals(valueStr)) {
minLevel = -1;
} else {
minLevel = NumericTools.parseInt(valueStr, -1);
name = newName.substring(0, index).trim();
}
if (minLevel > 0) {
item.setMinLevel(Integer.valueOf(minLevel));
}
}
name = name.trim();
item.setName(name);
// Item level
if (itemLevel != -1) {
item.setItemLevel(Integer.valueOf(itemLevel));
}
// Stats
item.getStats().setStats(stats);
String slices = provider.toPersistableString();
int nbSlices = ((SlicesBasedItemStatsProvider) provider).getSlices();
if (nbSlices > 0) {
item.setProperty(ItemPropertyNames.FORMULAS, slices);
}
// Slot
EquipmentLocation slot = null;
if ("Head".equals(_section))
slot = EquipmentLocation.HEAD;
else if ("Shoulders".equals(_section))
slot = EquipmentLocation.SHOULDER;
else if ("Chest".equals(_section))
slot = EquipmentLocation.CHEST;
else if ("Hands".equals(_section))
slot = EquipmentLocation.HAND;
else if ("Legs".equals(_section))
slot = EquipmentLocation.LEGS;
else if ("Feet".equals(_section))
slot = EquipmentLocation.FEET;
else if ("Shields".equals(_section))
slot = EquipmentLocation.OFF_HAND;
else if ("Ears".equals(_section))
slot = EquipmentLocation.EAR;
else if ("Neck".equals(_section))
slot = EquipmentLocation.NECK;
else if ("Wrists".equals(_section))
slot = EquipmentLocation.WRIST;
else if ("Fingers".equals(_section))
slot = EquipmentLocation.FINGER;
else if ("Pockets".equals(_section))
slot = EquipmentLocation.POCKET;
if (slot == null) {
int categoryIndex = table.getCategoryIndex();
if ((categoryIndex > 0) && (fields.length >= categoryIndex)) {
String category = fields[categoryIndex];
slot = getSlotFromCategory(category);
}
}
// Class requirement
String classRequirementStr = "";
int classesIndex = table.getClassesIndex();
if ((classesIndex != -1) && (fields.length >= classesIndex)) {
classRequirementStr = fields[classesIndex].trim();
}
CharacterClass classRequirement = getClassRequirement(classRequirementStr);
if (classRequirement != null) {
item.setRequiredClass(classRequirement);
}
if ("Burglar Signals".equals(_section)) {
item.setSubCategory("Burglar:Signal");
slot = EquipmentLocation.RANGED_ITEM;
item.setRequiredClass(CharacterClass.BURGLAR);
} else if ("Captain Standards".equals(_section)) {
item.setSubCategory("Captain:Standard");
slot = EquipmentLocation.RANGED_ITEM;
item.setRequiredClass(CharacterClass.CAPTAIN);
} else if ("Hunter Tomes".equals(_section)) {
String subCategory = "Tome";
if (name.contains("Wind-rider"))
subCategory = "Wind-rider";
if (name.contains("Whisper-draw"))
subCategory = "Whisper-draw";
item.setSubCategory("Hunter:" + subCategory);
slot = EquipmentLocation.CLASS_SLOT;
item.setRequiredClass(CharacterClass.HUNTER);
} else if ("Lore-master Brooches".equals(_section)) {
item.setSubCategory("Lore-master:Stickpin");
slot = EquipmentLocation.RANGED_ITEM;
item.setRequiredClass(CharacterClass.LORE_MASTER);
} else if ("Minstrel Instruments".equals(_section)) {
item.setSubCategory("Instrument");
slot = EquipmentLocation.RANGED_ITEM;
item.setRequiredClass(CharacterClass.MINSTREL);
} else if ("Rune-keeper Chisels".equals(_section)) {
String subCategory = "Other";
if (name.contains("Riffler"))
subCategory = "Riffler";
if (name.contains("Chisel"))
subCategory = "Chisel";
item.setSubCategory("Rune-keeper:" + subCategory);
slot = EquipmentLocation.RANGED_ITEM;
item.setRequiredClass(CharacterClass.RUNE_KEEPER);
} else if ("Warden Carvings".equals(_section)) {
item.setSubCategory("Warden:Carving");
slot = EquipmentLocation.CLASS_SLOT;
item.setRequiredClass(CharacterClass.WARDEN);
}
if (slot != null) {
item.setEquipmentLocation(slot);
}
return item;
}
use of delta.games.lotro.lore.items.EquipmentLocation in project lotro-tools by dmorcellet.
the class ItemNormalization method normalizeLegendaryItem.
private Item normalizeLegendaryItem(Item item) {
String name = item.getName();
ItemQuality quality = null;
if (name == null)
return item;
if (name.endsWith("of the First Age"))
quality = ItemQuality.LEGENDARY;
else if (name.endsWith("of the Second Age"))
quality = ItemQuality.INCOMPARABLE;
else if (name.endsWith("of the Third Age"))
quality = ItemQuality.RARE;
if (quality != null) {
CharacterClass cClass = null;
if (name.indexOf("Champion") != -1)
cClass = CharacterClass.CHAMPION;
else if (name.indexOf("Captain") != -1)
cClass = CharacterClass.CAPTAIN;
else if (name.indexOf("Beorning") != -1)
cClass = CharacterClass.BEORNING;
else if (name.indexOf("Burglar") != -1)
cClass = CharacterClass.BURGLAR;
else if (name.indexOf("Guardian") != -1)
cClass = CharacterClass.GUARDIAN;
else if (name.indexOf("Hunter") != -1)
cClass = CharacterClass.HUNTER;
else if (name.indexOf("Lore-master") != -1)
cClass = CharacterClass.LORE_MASTER;
else if (name.indexOf("Minstrel") != -1)
cClass = CharacterClass.MINSTREL;
else if (name.indexOf("Rune-keeper") != -1)
cClass = CharacterClass.RUNE_KEEPER;
else if (name.indexOf("Warden") != -1)
cClass = CharacterClass.WARDEN;
WeaponType weaponType = null;
String classItemType = null;
boolean bridle = false;
if (name.indexOf("Great Club") != -1)
weaponType = WeaponType.TWO_HANDED_CLUB;
else if (name.indexOf("Great Axe") != -1)
weaponType = WeaponType.TWO_HANDED_AXE;
else if (name.indexOf("Great Sword") != -1)
weaponType = WeaponType.TWO_HANDED_SWORD;
else if (name.indexOf("Greatsword") != -1)
weaponType = WeaponType.TWO_HANDED_SWORD;
else if (name.indexOf("Great Hammer") != -1)
weaponType = WeaponType.TWO_HANDED_HAMMER;
else if (name.indexOf("Halberd") != -1)
weaponType = WeaponType.HALBERD;
else if (name.indexOf("Club") != -1)
weaponType = WeaponType.ONE_HANDED_CLUB;
else if (name.indexOf("Axe") != -1)
weaponType = WeaponType.ONE_HANDED_AXE;
else if (name.indexOf("Sword") != -1)
weaponType = WeaponType.ONE_HANDED_SWORD;
else if (name.indexOf("Hammer") != -1)
weaponType = WeaponType.ONE_HANDED_HAMMER;
else if (name.indexOf("Dagger") != -1)
weaponType = WeaponType.DAGGER;
else if (name.indexOf("Spear") != -1)
weaponType = WeaponType.SPEAR;
else if (name.indexOf("Mace") != -1)
weaponType = WeaponType.ONE_HANDED_MACE;
else if (name.indexOf("Rune-stone") != -1) {
weaponType = WeaponType.RUNE_STONE;
cClass = CharacterClass.RUNE_KEEPER;
} else if (name.indexOf("Stone") != -1) {
weaponType = WeaponType.RUNE_STONE;
cClass = CharacterClass.RUNE_KEEPER;
} else if (name.indexOf("Staff") != -1)
weaponType = WeaponType.STAFF;
else if (name.indexOf("Carving") != -1)
classItemType = "Carving";
else if (name.indexOf("Tools") != -1)
classItemType = "Tools";
else if (name.indexOf("Emblem") != -1)
classItemType = "Emblem";
else if (name.indexOf("Rune-satchel") != -1)
classItemType = "Rune-satchel";
else if (name.indexOf("Rune") != -1)
classItemType = "Rune";
else if (name.indexOf("Belt") != -1)
classItemType = "Belt";
else if (name.indexOf("Crossbow") != -1)
weaponType = WeaponType.CROSSBOW;
else if (name.indexOf("Bow") != -1)
weaponType = WeaponType.BOW;
else if (name.indexOf("Book") != -1)
classItemType = "Book";
else if (name.indexOf("Songbook") != -1)
classItemType = "Songbook";
else if (name.indexOf("Javelin") != -1)
weaponType = WeaponType.JAVELIN;
else if (name.indexOf("Bridle") != -1)
bridle = true;
if ((weaponType != null) || (classItemType != null) || (bridle)) {
item.setQuality(quality);
item.setRequiredClass(cClass);
String category = null;
if ((classItemType != null) || (bridle)) {
LegendaryItem legendaryItem;
if (item instanceof LegendaryItem) {
legendaryItem = (LegendaryItem) item;
} else {
legendaryItem = new LegendaryItem();
legendaryItem.copyFrom(item);
item = legendaryItem;
}
}
if (bridle) {
category = "Bridle";
item.setEquipmentLocation(EquipmentLocation.BRIDLE);
} else if (classItemType != null) {
category = cClass.getLabel() + ":" + classItemType;
item.setEquipmentLocation(EquipmentLocation.CLASS_SLOT);
} else if (weaponType != null) {
LegendaryWeapon weapon;
if (item instanceof LegendaryWeapon) {
weapon = (LegendaryWeapon) item;
} else {
weapon = new LegendaryWeapon();
weapon.copyFrom(item);
item = weapon;
}
EquipmentLocation location = weaponType.isRanged() ? EquipmentLocation.RANGED_ITEM : EquipmentLocation.MAIN_HAND;
weapon.setEquipmentLocation(location);
weapon.setWeaponType(weaponType);
}
item.setSubCategory(category);
item.removeProperty(ItemPropertyNames.TULKAS_CATEGORY);
item.removeProperty(ItemPropertyNames.LEGACY_CATEGORY);
// System.out.println(name+", class="+cClass+", category="+category+", weapon type="+type);
}
}
return item;
}
use of delta.games.lotro.lore.items.EquipmentLocation in project lotro-tools by dmorcellet.
the class ItemNormalization method normalizeJewels.
private Item normalizeJewels(Item item) {
Item ret = item;
// int id=item.getIdentifier();
String categoryProp = item.getProperty(ItemPropertyNames.TULKAS_CATEGORY);
String subCategory = item.getSubCategory();
if (("49".equals(categoryProp)) || ("49".equals(subCategory))) {
String previousSubCategory = ret.getSubCategory();
// Pocket=103, Wrist=211, Ear=211, Neck=170, Finger=198
if ("Pocket".equals(previousSubCategory)) {
ret.setEquipmentLocation(EquipmentLocation.POCKET);
ret.setSubCategory(null);
} else if ("Wrist".equals(previousSubCategory)) {
ret.setEquipmentLocation(EquipmentLocation.WRIST);
ret.setSubCategory(null);
} else if ("Ear".equals(previousSubCategory)) {
ret.setEquipmentLocation(EquipmentLocation.EAR);
ret.setSubCategory(null);
} else if ("Neck".equals(previousSubCategory)) {
ret.setEquipmentLocation(EquipmentLocation.NECK);
ret.setSubCategory(null);
} else if ("Finger".equals(previousSubCategory)) {
ret.setEquipmentLocation(EquipmentLocation.FINGER);
ret.setSubCategory(null);
} else {
EquipmentLocation loc = ret.getEquipmentLocation();
if (loc != null) {
ret.setSubCategory(null);
} else {
ret.setSubCategory("Jewelry");
normalizeJewelByName(ret, "Token", EquipmentLocation.POCKET);
normalizeJewelByName(ret, "Earring", EquipmentLocation.EAR);
normalizeJewelByName(ret, "Bauble", EquipmentLocation.POCKET);
normalizeJewelByName(ret, "Necklace", EquipmentLocation.NECK);
normalizeJewelByName(ret, "Ring", EquipmentLocation.FINGER);
normalizeJewelByName(ret, "Bracelet", EquipmentLocation.WRIST);
normalizeJewelByName(ret, "Cuff", EquipmentLocation.WRIST);
normalizeJewelByName(ret, "Ear Cuff", EquipmentLocation.EAR);
normalizeJewelByName(ret, "Barrow-brie", EquipmentLocation.POCKET);
normalizeJewelByName(ret, "Stone", EquipmentLocation.POCKET);
normalizeJewelByName(ret, "Pendant", EquipmentLocation.NECK);
normalizeJewelByName(ret, "Choker", EquipmentLocation.NECK);
normalizeJewelByName(ret, "Band ", EquipmentLocation.FINGER);
normalizeJewelByName(ret, "Armlet", EquipmentLocation.WRIST);
// normalizeJewelByName(ret,"Bangle of Deep Waters",EquipmentLocation.WRIST);
normalizeJewelByName(ret, "Mountain-stone", EquipmentLocation.POCKET);
normalizeJewelByName(ret, "Scroll", EquipmentLocation.POCKET);
normalizeJewelByName(ret, "Phial", EquipmentLocation.POCKET);
normalizeJewelByName(ret, "Pocket-square", EquipmentLocation.POCKET);
normalizeJewelByName(ret, "Locket", EquipmentLocation.POCKET);
// Specific names for pocket items
normalizeJewelByName(ret, "Carved Jewellery Box", EquipmentLocation.POCKET);
String name = ret.getName();
if ("Plains Walker's Symbol".equals(name)) {
ret.setRequiredClass(CharacterClass.BEORNING);
ret.setEquipmentLocation(EquipmentLocation.POCKET);
ret.setSubCategory(null);
} else if ("Talisman of the Tundra Cub".equals(name)) {
ret.setRequiredClass(CharacterClass.LORE_MASTER);
ret.setEquipmentLocation(null);
ret.setSubCategory(CharacterClass.LORE_MASTER.getLabel() + ":Talisman");
}
}
}
EquipmentLocation slot = ret.getEquipmentLocation();
if (slot == null) {
String name = ret.getName();
System.out.println("Slot not found for jewel: " + name);
}
ret.removeProperty(ItemPropertyNames.TULKAS_CATEGORY);
ret.removeProperty(ItemPropertyNames.LEGACY_CATEGORY);
if (ret instanceof Armour) {
Armour armour = (Armour) ret;
int armourValue = armour.getArmourValue();
// Transmutate to item so that further filtering works good
Item newItem = new Item();
newItem.copyFrom(ret);
newItem.getStats().setStat(STAT.ARMOUR, new FixedDecimalsInteger(armourValue));
ret = newItem;
}
}
return ret;
}
use of delta.games.lotro.lore.items.EquipmentLocation in project lotro-tools by dmorcellet.
the class MergeWithTulkasNew method mergeItems.
private Item mergeItems(Item source, Item tulkas) {
int id = source.getIdentifier();
Item result = source;
// Check types
if (source.getClass() != tulkas.getClass()) {
// System.out.println("ID: " + id+": type conflict: tulkas=" + tulkas.getClass() + ", source=" + source.getClass());
if (source.getClass() == Item.class) {
if (tulkas instanceof Weapon) {
Weapon weapon = new Weapon();
Weapon tulkasWeapon = (Weapon) tulkas;
result = weapon;
weapon.copyFrom(source);
weapon.setMinDamage(tulkasWeapon.getMinDamage());
weapon.setMaxDamage(tulkasWeapon.getMaxDamage());
weapon.setDPS(tulkasWeapon.getDPS());
weapon.setDamageType(tulkasWeapon.getDamageType());
weapon.setWeaponType(tulkasWeapon.getWeaponType());
} else if (tulkas instanceof Armour) {
Armour armour = new Armour();
Armour tulkasArmour = (Armour) tulkas;
result = armour;
armour.copyFrom(source);
armour.setArmourValue(tulkasArmour.getArmourValue());
armour.setArmourType(tulkasArmour.getArmourType());
}
} else {
System.out.println("Unmanaged cast");
}
} else {
result = source;
}
String sourceName = source.getName();
// Name
{
String tulkasName = tulkas.getName();
if (!tulkasName.equals(sourceName)) {
// System.out.println("ID: " + id+": name conflict: tulkas=" + tulkasName + ", source=" + sourceName);
if (tulkasName != null) {
result.setProperty(ItemPropertyNames.OLD_TULKAS_NAME, tulkasName);
}
}
}
// Required level
{
Integer tulkasMinLevel = tulkas.getMinLevel();
Integer sourceMinLevel = result.getMinLevel();
boolean conflict = false;
if (tulkasMinLevel != null) {
if (sourceMinLevel == null) {
// conflict=true;
result.setMinLevel(tulkasMinLevel);
} else {
if (tulkasMinLevel.intValue() != sourceMinLevel.intValue()) {
conflict = true;
result.setMinLevel(tulkasMinLevel);
}
}
} else {
if (sourceMinLevel != null) {
conflict = true;
result.setMinLevel(sourceMinLevel);
}
}
if (conflict) {
// System.out.println("ID: " + id+": min level conflict: tulkas=" + tulkasMinLevel + ", source=" + sourceMinLevel);
}
}
// Item level
{
result.setItemLevel(tulkas.getItemLevel());
}
// Required class
{
CharacterClass tulkasClass = tulkas.getRequiredClass();
CharacterClass sourceClass = source.getRequiredClass();
if (tulkasClass != sourceClass) {
if ((tulkasClass != null) && (sourceClass == null)) {
result.setRequiredClass(tulkasClass);
} else {
System.out.println("ID: " + id + ": required class conflict: tulkas=" + tulkasClass + ", source=" + sourceClass);
}
}
}
// Quality
{
ItemQuality tulkasQuality = tulkas.getQuality();
ItemQuality sourceQuality = source.getQuality();
if (tulkasQuality != sourceQuality) {
// Use source quality since it comes from tulkas index (17.1), which is more recent that tulkas new (13.1)
result.setQuality(sourceQuality);
// System.out.println("ID: " + id+": quality conflict: tulkas=" + tulkasQuality + ", source=" + sourceQuality);
}
}
// Bonus
if (result != source) {
result.getBonus().clear();
result.getBonus().addAll(source.getBonus());
}
// Stats
result.getStats().setStats(tulkas.getStats());
// Slot
{
EquipmentLocation tulkasSlot = tulkas.getEquipmentLocation();
EquipmentLocation sourceSlot = source.getEquipmentLocation();
if (tulkasSlot != sourceSlot) {
// Use tulkas slot since it is not set in source
result.setEquipmentLocation(tulkasSlot);
// System.out.println("ID: " + id+": slot conflict: tulkas=" + tulkasSlot + ", source=" + sourceSlot);
}
}
return result;
}
Aggregations