use of delta.games.lotro.common.CharacterClass in project lotro-tools by dmorcellet.
the class ItemNormalization method filterItems.
/**
* Filter items that are accessible within LotroCompanion.
* @param items List to filter.
* @return a list that contains the filtered items.
*/
private List<Item> filterItems(List<Item> items) {
ItemsManager manager = new ItemsManager(items);
Set<Integer> selectedIds = new HashSet<Integer>();
// Iterate on classes then on slots to find all reachable items
for (CharacterClass cClass : CharacterClass.ALL_CLASSES) {
CharacterData c = new CharacterData();
c.setCharacterClass(cClass);
c.setLevel(105);
for (EQUIMENT_SLOT slot : EQUIMENT_SLOT.values()) {
List<Item> selectedItems = manager.getItems(c, slot);
for (Item selectedItem : selectedItems) {
selectedIds.add(Integer.valueOf(selectedItem.getIdentifier()));
}
}
}
// Essences
List<Item> essences = manager.getEssences();
for (Item essence : essences) {
selectedIds.add(Integer.valueOf(essence.getIdentifier()));
}
// Build final list
List<Item> selectedItems = new ArrayList<Item>();
for (Item item : items) {
if (selectedIds.contains(Integer.valueOf(item.getIdentifier()))) {
selectedItems.add(item);
}
}
return selectedItems;
}
use of delta.games.lotro.common.CharacterClass 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.common.CharacterClass 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;
}
use of delta.games.lotro.common.CharacterClass in project lotro-tools by dmorcellet.
the class LotroCompendiumDeedsLoader method handleType.
private void handleType(DeedDescription deed, String type) {
CharacterClass characterClass = null;
DeedType deedType = null;
if ("Minstrel".equals(type)) {
deedType = DeedType.CLASS;
characterClass = CharacterClass.MINSTREL;
}
if ("Hunter".equals(type)) {
deedType = DeedType.CLASS;
characterClass = CharacterClass.HUNTER;
}
if ("Lore-master".equals(type)) {
deedType = DeedType.CLASS;
characterClass = CharacterClass.LORE_MASTER;
}
if ("Captain".equals(type)) {
deedType = DeedType.CLASS;
characterClass = CharacterClass.CAPTAIN;
}
if ("Warden".equals(type)) {
deedType = DeedType.CLASS;
characterClass = CharacterClass.WARDEN;
}
if ("Champion".equals(type)) {
deedType = DeedType.CLASS;
characterClass = CharacterClass.CHAMPION;
}
if ("Rune-keeper".equals(type)) {
deedType = DeedType.CLASS;
characterClass = CharacterClass.RUNE_KEEPER;
}
if ("Burglar".equals(type)) {
deedType = DeedType.CLASS;
characterClass = CharacterClass.BURGLAR;
}
if ("Guardian".equals(type)) {
deedType = DeedType.CLASS;
characterClass = CharacterClass.GUARDIAN;
}
if ("Event".equals(type))
deedType = DeedType.EVENT;
if ("Explorer".equals(type))
deedType = DeedType.EXPLORER;
if ("Lore".equals(type))
deedType = DeedType.LORE;
if ("Slayer".equals(type))
deedType = DeedType.SLAYER;
if ("Reputation".equals(type))
deedType = DeedType.REPUTATION;
if (deedType == null) {
String name = deed.getName();
if (name != null) {
if (name.toLowerCase().indexOf("slayer") != -1) {
deedType = DeedType.SLAYER;
}
}
}
deed.setType(deedType);
deed.setRequiredClass(characterClass);
}
use of delta.games.lotro.common.CharacterClass in project lotro-tools by dmorcellet.
the class ItemPageParser method parseItemDescription.
private void parseItemDescription(Element itemTooltip) {
// Name
String name = findName(itemTooltip);
// Find out type of item
Armour armour = null;
// Armor?
// <div class="itemarmor">1130 Armour Value</div>
String armorStr = getTagContent(itemTooltip, "itemarmor");
Weapon weapon = null;
// Weapon?
// <div class="itemdps">126.5 DPS</div>
String dpsStr = getTagContent(itemTooltip, "itemdps");
if (armorStr != null) {
// Armour!
armour = new Armour();
_item = armour;
Integer armourValue = getArmour(armorStr);
if (armourValue != null) {
armour.setArmourValue(armourValue.intValue());
}
String armourTypeStr = getTagContent(itemTooltip, "itemtype");
ArmourType armourType = ArmourType.getArmourTypeByName(armourTypeStr);
if (armourType == null) {
// Assume light armour...
armourType = ArmourType.LIGHT;
_logger.warn("Unknown armour type: " + armourTypeStr + " (name=" + name + ")");
}
armour.setArmourType(armourType);
} else if (dpsStr != null) {
// Weapon!
weapon = new Weapon();
_item = weapon;
Float dpsValue = getDPS(dpsStr);
if (dpsValue != null) {
weapon.setDPS(dpsValue.floatValue());
}
String weaponTypeStr = getTagContent(itemTooltip, "itemtype");
if (weaponTypeStr != null) {
WeaponType type = WeaponType.getWeaponTypeByName(weaponTypeStr);
if (type != null) {
weapon.setWeaponType(type);
} else {
_logger.warn("Unknown weapon type: " + weaponTypeStr + " (name=" + name + ")");
}
}
} else {
_item = new Item();
}
// Icon
// <div class="itemicon"><img src="http://content.turbine.com/sites/lorebook.lotro.com/images/icons/item/tool/eq_c_craft_tool_voc_explorer_tier6.png"></div>
String url = getIconURL(itemTooltip);
// Name
_item.setName(name);
if (url != null) {
_item.setIconURL(url);
}
// Item sub-category
// <div class="itemtype">Craft Tool</div>
// TODO: duplicated with weapon type and armor type...
String subCategory = getTagContent(itemTooltip, "itemtype");
_item.setSubCategory(subCategory);
// Uniqueness
// <div class="itemunique"></div>
String uniqueStr = getTagContent(itemTooltip, "itemunique");
if ("Unique".equalsIgnoreCase(uniqueStr)) {
_item.setUnique(true);
}
// Item bind
// <div class="itembind">Bind on Equip</div>
String itemBindStr = getTagContent(itemTooltip, "itembind");
ItemBinding binding = getBinding(itemBindStr);
_item.setBinding(binding);
// Damage:
// <div class="itemdamage">197 - 359 Common Damage</div>
String damage = getTagContent(itemTooltip, "itemdamage");
if (damage != null) {
try {
if (damage.endsWith("Damage")) {
String tmp = damage.substring(0, damage.length() - 6).trim();
String[] split = tmp.split(" ", 4);
int minDamage = Integer.parseInt(split[0]);
int maxDamage = Integer.parseInt(split[2]);
String typeStr = split[3];
DamageType type = DamageType.getDamageTypeByName(typeStr);
if (type == null) {
type = DamageType.COMMON;
_logger.warn("Unmanaged damage type [" + typeStr + "]");
}
weapon.setMinDamage(minDamage);
weapon.setMaxDamage(maxDamage);
weapon.setDamageType(type);
}
} catch (Exception e) {
_logger.error("Damage parsing exception on [" + damage + "]", e);
}
}
// Bonuses
// <div class="itemes">
// <div class="iteme">
// <div>-3s Forester Chopping Duration</div>
// </div>
// ...
// </div>
List<String> bonuses = new ArrayList<String>();
Element itemsContainer = JerichoHtmlUtils.findElementByTagNameAndAttributeValue(itemTooltip, HTMLElementName.DIV, "class", "itemes");
if (itemsContainer != null) {
List<Element> itemsList = JerichoHtmlUtils.findElementsByTagNameAndAttributeValue(itemsContainer, HTMLElementName.DIV, "class", "iteme");
for (Element item : itemsList) {
List<Element> children = item.getChildElements();
if (children != null) {
for (Element child : children) {
String line = JerichoHtmlUtils.getTagContents(child, HTMLElementName.DIV);
bonuses.add(line);
}
}
}
}
_item.setBonus(bonuses);
// TODO <div class="itemmsi">+5 Damage to The Dead</div>
String msi = getTagContent(itemTooltip, "itemmsi");
if ((msi != null) && (msi.length() > 0)) {
_logger.warn("Unmanaged itemmsi [" + msi + "] for " + _item.getName());
}
// Item set
ItemsSet set = parseItemsSet(itemTooltip);
if (set != null) {
_item.setSetKey(set.getKey());
_item.setItemsSet(set);
}
// Possible legacies TODO
/*
<div class="itemes">Possible Initial Legacies:</div>
<div>Focus Bow Critical Multiplier (Tier(s):
<span class="legacytier rare">4</span>
,
<span class="legacytier incomparable">5</span>
,
<span class="legacytier incomparable">6</span>
)
</div>
<div>Focus Bow Power Cost (Tier(s):
<span class="legacytier rare">4</span>
,
<span class="legacytier incomparable">5</span>
,
<span class="legacytier incomparable">6</span>
)
</div>
<div>
Induction Bow Critical Multiplier (Tier(s):
<span class="legacytier rare">4</span>
,
<span class="legacytier incomparable">5</span>
,
<span class="legacytier incomparable">6</span>
)
</div>
<div>
<div>
Merciful Shot Cooldown (Tier(s):
<span class="legacytier rare">4</span>
,
<span class="legacytier incomparable">5</span>
,
<span class="legacytier incomparable">6</span>
)
</div>
<div>
Quick Shot Critical Chance (Tier(s):
<span class="legacytier rare">4</span>
,
<span class="legacytier incomparable">5</span>
,
<span class="legacytier incomparable">6</span>
)
</div>
<div>
Ranged Skill Block Chance Modifier (Tier(s):
<span class="legacytier rare">4</span>
,
<span class="legacytier incomparable">5</span>
,
<span class="legacytier incomparable">6</span>
)
</div>
<div>
Ranged Skill Evade Chance Modifier (Tier(s):
<span class="legacytier rare">4</span>
,
<span class="legacytier incomparable">5</span>
,
<span class="legacytier incomparable">6</span>
)
</div>
<div>
Strength Quick Shot Slow (Tier(s):
<span class="legacytier rare">4</span>
,
<span class="legacytier incomparable">5</span>
,
<span class="legacytier incomparable">6</span>
)
</div>
*
*/
// Item durability:
// - durability
// <div class="itemdurability">Durability 60 / 60</div>
String durabilityStr = getTagContent(itemTooltip, "itemdurability");
Integer durability = getDurability(durabilityStr);
_item.setDurability(durability);
// - sturdiness
// <div class="itemsturdiness">Tough</div>
String sturdinessStr = getTagContent(itemTooltip, "itemsturdiness");
ItemSturdiness sturdiness = getSturdiness(sturdinessStr);
_item.setSturdiness(sturdiness);
// Item requirements
List<Element> requirements = JerichoHtmlUtils.findElementsByTagNameAndAttributeValue(itemTooltip, HTMLElementName.DIV, "class", "itemrequirement");
for (Element requirement : requirements) {
// String contents=getTagContent(requirement,"itemrequirement");
String contents = CharacterReference.decodeCollapseWhiteSpace(requirement.getContent());
if (contents.contains("Minimum Level")) {
// - minimum level
// <div class="itemrequirement">Minimum Level: 55</div>
String minLevelStr = getTagContent(itemTooltip, "itemrequirement");
Integer minLevel = getMinLevel(minLevelStr);
_item.setMinLevel(minLevel);
} else if (contents.contains("Class")) {
// - class
String className = parseClassRequirement(requirement);
if (className != null) {
CharacterClass cClass = CharacterClass.getByName(className);
_item.setRequiredClass(cClass);
}
}
}
// Description
// <div class="itemdescription">A collection of indispensable tools for tailors, foresters, and prospectors.</div>
// String description=getTagContent(itemTooltip,"");
Element element = JerichoHtmlUtils.findElementByTagNameAndAttributeValue(itemTooltip, HTMLElementName.DIV, "class", "itemdescription");
if (element != null) {
String description = JerichoHtmlUtils.getTextFromTag(element);
_item.setDescription(description);
}
// Money
// <div class="itemworth">
Element worth = JerichoHtmlUtils.findElementByTagNameAndAttributeValue(itemTooltip, HTMLElementName.DIV, "class", "itemworth");
if (worth != null) {
Money m = parseMoneyReward(worth);
_item.setValue(m);
}
// Stackability
// <div class="itemstacksize">Stacks to 100</div>
String stackabilityStr = getTagContent(itemTooltip, "itemstacksize");
Integer stackSize = getStackSize(stackabilityStr);
_item.setStackMax(stackSize);
/*
// Item category: Armour, Tool, ...
private ItemCategory _category;
// Item identifier: "Jacket_of_the_Impossible_Shot", ...
private String _id;
*/
}
Aggregations