use of delta.games.lotro.lore.items.ItemSturdiness 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;
*/
}
use of delta.games.lotro.lore.items.ItemSturdiness in project lotro-tools by dmorcellet.
the class TulkasItemsIndexLoader method buildItems.
/**
* Build items from raw data items.
* @param items Loaded data items.
*/
public void buildItems(HashMap<Integer, HashMap<Object, Object>> items) {
List<Integer> keys = new ArrayList<Integer>(items.keySet());
Collections.sort(keys);
List<Item> itemsList = new ArrayList<Item>();
int nbKeys = keys.size();
System.out.println("Min: " + keys.get(0) + ", max: " + keys.get(nbKeys - 1));
for (int i = 0; i < nbKeys; i++) {
Integer id = keys.get(i);
HashMap<Object, Object> data = items.get(id);
String name = (String) data.get(Integer.valueOf(1));
if ("GNDN".equals(name)) {
continue;
}
String description = (String) data.get(Integer.valueOf(2));
if (description != null) {
if (description.indexOf("string table error") != -1) {
description = "";
}
// description=description.replace(" ", " ");
}
Integer categoryInt = (Integer) data.get(Integer.valueOf(3));
// 4..5: see below (quality, sturdiness)
// 6: isMagic is always false
Boolean isUnique = (Boolean) data.get(Integer.valueOf(7));
Integer iconID = (Integer) data.get(Integer.valueOf(8));
Integer backgroundIconId = (Integer) data.get(Integer.valueOf(9));
Item item = new Item();
item.setIdentifier(id.intValue());
item.setName(name);
item.setDescription(description);
if (iconID != null) {
item.setProperty(ItemPropertyNames.ICON_ID, iconID.toString());
}
if (backgroundIconId != null) {
item.setProperty(ItemPropertyNames.BACKGROUND_ICON_ID, backgroundIconId.toString());
}
if (isUnique != null) {
item.setUnique(isUnique.booleanValue());
}
if (categoryInt != null) {
item.setSubCategory(String.valueOf(categoryInt));
}
// Quality
{
Integer qualityInt = (Integer) data.get(Integer.valueOf(4));
ItemQuality quality = null;
switch(qualityInt.intValue()) {
// special items
case 0:
quality = null;
break;
case 1:
quality = ItemQuality.LEGENDARY;
break;
case 2:
quality = ItemQuality.RARE;
break;
case 3:
quality = ItemQuality.INCOMPARABLE;
break;
case 4:
quality = ItemQuality.UNCOMMON;
break;
case 5:
quality = ItemQuality.COMMON;
break;
}
item.setQuality(quality);
}
// Sturdiness
{
Integer durabilityInt = (Integer) data.get(Integer.valueOf(5));
ItemSturdiness sturdiness = null;
switch(durabilityInt.intValue()) {
// consumables
case 0:
sturdiness = null;
break;
case 1:
sturdiness = ItemSturdiness.SUBSTANTIAL;
break;
case 2:
sturdiness = ItemSturdiness.BRITTLE;
break;
case 3:
sturdiness = ItemSturdiness.NORMAL;
break;
case 4:
sturdiness = ItemSturdiness.TOUGH;
break;
// cosmetics
case 6:
sturdiness = null;
break;
case 7:
sturdiness = ItemSturdiness.WEAK;
break;
}
item.setSturdiness(sturdiness);
}
itemsList.add(item);
// System.out.println(i);
// System.out.println(item.dump());
// writeItemToDB(item);
}
File toFile = new File("data/items/tmp/itemsTulkasIndex.xml").getAbsoluteFile();
ItemXMLWriter.writeItemsFile(toFile, itemsList);
}
use of delta.games.lotro.lore.items.ItemSturdiness in project lotro-companion by dmorcellet.
the class ItemEditionPanelController method buildSturdinessCombo.
private ComboBoxController<ItemSturdiness> buildSturdinessCombo() {
ComboBoxController<ItemSturdiness> ctrl = new ComboBoxController<ItemSturdiness>();
ctrl.addEmptyItem("");
for (ItemSturdiness sturdiness : ItemSturdiness.ALL) {
ctrl.addItem(sturdiness, sturdiness.getLabel());
}
ctrl.selectItem(null);
return ctrl;
}
Aggregations