use of delta.games.lotro.lore.items.Item in project lotro-tools by dmorcellet.
the class BuildItemsDbForIcons method doIt.
private void doIt() {
File oldFile = new File("data\\items\\items.old.xml").getAbsoluteFile();
oldFile = null;
File newFile = new File("data\\items\\items_filtered.xml").getAbsoluteFile();
HashMap<Integer, Item> items = loadItemsFile(oldFile, newFile);
doIt(items);
System.out.println("Total items count: " + items.size());
}
use of delta.games.lotro.lore.items.Item in project lotro-tools by dmorcellet.
the class BuildItemsDbForIcons method buildDb.
/**
* Build a LUA database using the given item IDs.
* @param items Items database.
* @param ids Identifiers to use.
*/
public void buildDb(HashMap<Integer, Item> items, List<Integer> ids) {
StringBuilder sb = new StringBuilder();
sb.append("_ITEMSDB =").append("\n");
sb.append("{").append("\n");
Collections.sort(ids);
List<String> iconIds = new ArrayList<String>();
for (Integer id : ids) {
Item item = items.get(id);
int iconId = NumericTools.parseInt(item.getProperty(ItemPropertyNames.ICON_ID), 0);
String name = item.getName();
if (name == null)
name = "";
name = name.replace("\n", "");
name = name.replace("\r", "");
String hexIconId = Integer.toHexString(iconId).toUpperCase();
int backgroundIconId = NumericTools.parseInt(item.getProperty(ItemPropertyNames.BACKGROUND_ICON_ID), 0);
String hexBackgroundIconId = Integer.toHexString(backgroundIconId).toUpperCase();
sb.append("[").append(id).append("]={[1]=\"");
sb.append(name).append("\";[2]=\"\";[3]=5;[4]=4;[5]=3;[6]=false;[7]=false;[8]=0x");
sb.append(hexIconId).append(";[9]=0x").append(hexBackgroundIconId).append(";};\n");
iconIds.add(iconId + "-" + backgroundIconId);
}
sb.append("};\n");
// Write LUA file
{
TextFileWriter writer = new TextFileWriter(LUA_FILE);
writer.start();
writer.writeSomeText(sb.toString());
writer.terminate();
}
// Write icon IDs file
{
TextFileWriter writer = new TextFileWriter(ICON_IDS_FILE);
writer.start();
for (String iconId : iconIds) {
writer.writeNextLine(iconId);
}
writer.terminate();
}
}
use of delta.games.lotro.lore.items.Item 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.Item in project lotro-tools by dmorcellet.
the class ItemsMerger method findItem.
private Item findItem(List<Item> selectedItems, Item item) {
if (selectedItems != null) {
// Use identifier if we can
if (item.getIdentifier() != 0) {
for (Item currentItem : selectedItems) {
if (currentItem.getIdentifier() == item.getIdentifier()) {
return currentItem;
}
}
return null;
}
List<Item> goodItems = null;
// Use item level
for (Item currentItem : selectedItems) {
if (areEqual(currentItem.getItemLevel(), item.getItemLevel())) {
if (goodItems == null) {
goodItems = new ArrayList<Item>();
}
goodItems.add(currentItem);
}
}
if (goodItems != null) {
if (goodItems.size() == 1) {
return goodItems.get(0);
}
// Several items do match...
Item usingMight = findItemUsingStat(STAT.MIGHT, selectedItems, item);
if (usingMight != null) {
return usingMight;
}
Item usingAgility = findItemUsingStat(STAT.AGILITY, selectedItems, item);
if (usingAgility != null) {
return usingAgility;
}
Item usingWill = findItemUsingStat(STAT.WILL, selectedItems, item);
if (usingWill != null) {
return usingWill;
}
System.out.println("Several items do match " + item + ": " + goodItems);
}
}
return null;
}
use of delta.games.lotro.lore.items.Item in project lotro-tools by dmorcellet.
the class ItemsMerger method newItem.
/**
* Handle a new item.
* @param item Item to add.
* @param armourType Armour type for this item (or <code>null</code>)
*/
public void newItem(Item item, ArmourType armourType) {
String name = item.getName();
name = name.replace(' ', ' ');
updateArmourType(armourType, item);
// Check for known item...
List<Item> selectedItems = _mapByName.get(name);
if (selectedItems == null) {
// Item not known
List<Item> newList = new ArrayList<Item>();
newList.add(item);
_mapByName.put(name, newList);
_items.add(item);
return;
}
// Find item
Item selectedItem = findItem(selectedItems, item);
if (selectedItem != null) {
// Found...
mergeStats(item, selectedItem);
mergeItems(armourType, item, selectedItem);
return;
}
// Item with ID...
int id = item.getIdentifier();
if (id != 0) {
Item itemsdbItem = _mapById.get(Integer.valueOf(id));
if (itemsdbItem == null) {
_items.add(item);
return;
}
}
// Look for different versions of a scalable item
StringBuilder log = new StringBuilder();
selectedItem = inspectScalableItems(item, selectedItems, log);
if (selectedItem != null) {
Integer itemLevel = item.getItemLevel();
Integer selectedItemLevel = selectedItem.getItemLevel();
if (compareItemLevels(itemLevel, selectedItemLevel) > 0) {
mergeStats(item, selectedItem);
}
mergeItems(armourType, item, selectedItem);
return;
}
// Could not handle item correctly, complain!
Integer itemLevel = item.getItemLevel();
System.out.println("Name: " + name + " (" + itemLevel + ") not found. Selection is:" + selectedItems);
System.out.println(log);
if (selectedItems != null) {
for (Item currentItem : selectedItems) {
_failedItems.put(Integer.valueOf(currentItem.getIdentifier()), item);
}
}
}
Aggregations