Search in sources :

Example 1 with ItemsSet

use of delta.games.lotro.lore.items.ItemsSet 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;
    */
}
Also used : ArmourType(delta.games.lotro.lore.items.ArmourType) Element(net.htmlparser.jericho.Element) ArrayList(java.util.ArrayList) Weapon(delta.games.lotro.lore.items.Weapon) DamageType(delta.games.lotro.lore.items.DamageType) CharacterClass(delta.games.lotro.common.CharacterClass) Item(delta.games.lotro.lore.items.Item) ItemBinding(delta.games.lotro.lore.items.ItemBinding) Money(delta.games.lotro.common.Money) Armour(delta.games.lotro.lore.items.Armour) ItemsSet(delta.games.lotro.lore.items.ItemsSet) WeaponType(delta.games.lotro.lore.items.WeaponType) ItemSturdiness(delta.games.lotro.lore.items.ItemSturdiness)

Example 2 with ItemsSet

use of delta.games.lotro.lore.items.ItemsSet in project lotro-tools by dmorcellet.

the class TulkasItemsLoader1 method buildSets.

/**
 * Build items sets from raw data items.
 * @param items Loaded data items.
 */
public void buildSets(HashMap<Integer, HashMap<Object, Object>> items) {
    HashMap<String, ItemsSet> sets = new HashMap<String, ItemsSet>();
    List<Integer> keys = new ArrayList<Integer>(items.keySet());
    Collections.sort(keys);
    int nbKeys = keys.size();
    for (int i = 0; i < nbKeys; i++) {
        Integer id = keys.get(i);
        HashMap<Object, Object> data = items.get(id);
        @SuppressWarnings("unchecked") HashMap<Object, Object> setDef = (HashMap<Object, Object>) data.get("Set");
        if (setDef != null) {
            String setName = (String) setDef.get("Name");
            ItemsSet set = sets.get(setName);
            if (set != null)
                continue;
            set = new ItemsSet();
            // Use name as set key
            set.setKey(setName);
            set.setName(setName);
            sets.put(setName, set);
            // System.out.println(setName);
            @SuppressWarnings("unchecked") List<Integer> ids = (List<Integer>) setDef.get("IDs");
            // System.out.println(ids);
            for (Integer setItemId : ids) {
                set.addItem(setItemId.intValue(), "");
            }
            @SuppressWarnings("unchecked") HashMap<Object, Object> bonuses = (HashMap<Object, Object>) setDef.get("Bonus");
            if (bonuses != null) {
                Set<Object> numbers = bonuses.keySet();
                for (Object number : numbers) {
                    Integer nb = (Integer) number;
                    // System.out.println(nb);
                    @SuppressWarnings("unchecked") HashMap<Object, Object> rawSetBonuses = (HashMap<Object, Object>) bonuses.get(nb);
                    HashMap<String, Object> setBonuses = new HashMap<String, Object>();
                    loadBonusItemsVersion1(setBonuses, rawSetBonuses);
                    for (String bonusName : setBonuses.keySet()) {
                        String bonus = bonusName + " : " + setBonuses.get(bonusName);
                        set.addBonus(nb.intValue(), bonus);
                    }
                }
            }
        }
    }
    for (ItemsSet set : sets.values()) {
        System.out.println(set.dump());
    }
// ["Set"] = {["Name"]="Daerdúr Armour";["IDs"] = {1879113508,1879113511,1879113514,1879113517,1879113520,1879113523};["Bonus"] = {[3] = {["Might"]="+15";};[6] = {["Vitality"]="+15";["Fire Mitigation"]="+375";};};};};
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FixedDecimalsInteger(delta.games.lotro.utils.FixedDecimalsInteger) ItemsSet(delta.games.lotro.lore.items.ItemsSet) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with ItemsSet

use of delta.games.lotro.lore.items.ItemsSet in project lotro-tools by dmorcellet.

the class TulkasItemsLoader2 method buildSets.

/**
 * Build items sets from raw data items.
 * @param items Loaded data items.
 */
public void buildSets(HashMap<Integer, HashMap<Object, Object>> items) {
    HashMap<String, ItemsSet> sets = new HashMap<String, ItemsSet>();
    List<Integer> keys = new ArrayList<Integer>(items.keySet());
    Collections.sort(keys);
    int nbKeys = keys.size();
    for (int i = 0; i < nbKeys; i++) {
        Integer id = keys.get(i);
        HashMap<Object, Object> data = items.get(id);
        @SuppressWarnings("unchecked") HashMap<Object, Object> setDef = (HashMap<Object, Object>) data.get(Integer.valueOf(15));
        if (setDef != null) {
            @SuppressWarnings("unchecked") HashMap<Object, Object> nameMap = (HashMap<Object, Object>) setDef.get(Integer.valueOf(1));
            String setName = (String) nameMap.get(Integer.valueOf(1));
            ItemsSet set = sets.get(setName);
            if (set != null)
                continue;
            set = new ItemsSet();
            // Use name as set key
            set.setKey(setName);
            set.setName(setName);
            sets.put(setName, set);
            @SuppressWarnings("unchecked") List<Integer> ids = (List<Integer>) setDef.get(Integer.valueOf(2));
            // System.out.println(ids);
            for (Integer setItemId : ids) {
                set.addItem(setItemId.intValue(), "");
            }
        // No bonus in this file!
        }
    }
    for (ItemsSet set : sets.values()) {
        System.out.println(set.dump());
    }
/*
    [15]={[1]=
        {[1]="Stalwart Captain's Jewelry of Helm's Deep";[2]="";[3]="";[4]="";};
         [2]={1879294461,1879295053,1879299996,1879300219};};};
     */
}
Also used : FixedDecimalsInteger(delta.games.lotro.utils.FixedDecimalsInteger) ItemsSet(delta.games.lotro.lore.items.ItemsSet) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with ItemsSet

use of delta.games.lotro.lore.items.ItemsSet in project lotro-tools by dmorcellet.

the class ItemPageParser method parseItemsSet.

private ItemsSet parseItemsSet(Element itemTooltip) {
    ItemsSet ret = null;
    Element itemsSet = JerichoHtmlUtils.findElementByTagNameAndAttributeValue(itemTooltip, HTMLElementName.DIV, "class", "itemset");
    if (itemsSet != null) {
        ret = new ItemsSet();
        String setKey = null;
        String setName = "";
        String setURL = null;
        Element itemsSetName = JerichoHtmlUtils.findElementByTagNameAndAttributeValue(itemsSet, HTMLElementName.DIV, "class", "itemsn");
        if (itemsSetName != null) {
            Element aElement = itemsSetName.getFirstElement(HTMLElementName.A);
            if (aElement != null) {
                setURL = aElement.getAttributeValue("href");
                if ((setURL != null) && (setURL.startsWith(WIKI_SEED))) {
                    setKey = setURL.substring(WIKI_SEED.length());
                    int index = setKey.indexOf(":");
                    if (index != -1) {
                        setKey = setKey.substring(index + 1);
                    }
                }
                setName = JerichoHtmlUtils.getTagContents(itemsSetName, HTMLElementName.A);
            }
        }
        // System.out.println("Set name: "+setName);
        // System.out.println("Set URL: "+setURL);
        ret.setName(setName);
        ret.setKey(setKey);
        // Set items
        Element setItemsElement = JerichoHtmlUtils.findElementByTagNameAndAttributeValue(itemsSet, HTMLElementName.DIV, "class", "itemsps");
        if (setItemsElement != null) {
            List<Element> setItemElements = JerichoHtmlUtils.findElementsByTagNameAndAttributeValue(itemsSet, HTMLElementName.DIV, "class", "itemsp");
            for (Element setItemElement : setItemElements) {
                String itemKey = null;
                String itemURL = null;
                // String itemName=null;
                Element aElement = setItemElement.getFirstElement(HTMLElementName.A);
                if (aElement != null) {
                    itemURL = aElement.getAttributeValue("href");
                    if ((itemURL != null) && (itemURL.startsWith(WIKI_SEED))) {
                        itemKey = itemURL.substring(WIKI_SEED.length());
                    }
                // itemName=JerichoHtmlUtils.getTagContents(setItemElement,HTMLElementName.A);
                }
                if (itemKey != null) {
                    ret.addItem(0, itemKey);
                }
            // System.out.println("Item ["+itemName+"]. URL=["+itemURL+"]");
            }
        }
        // Set effects
        Element setEffectsElement = JerichoHtmlUtils.findElementByTagNameAndAttributeValue(itemsSet, HTMLElementName.DIV, "class", "itemseteff");
        if (setEffectsElement != null) {
            List<Element> divs = setEffectsElement.getAllElements(HTMLElementName.DIV);
            // Remove self
            divs.remove(0);
            int nbOfItems = 0;
            for (Element div : divs) {
                String effectLine = JerichoHtmlUtils.getTagContents(div, HTMLElementName.DIV);
                // System.out.println("Effect line ["+effectLine+"]");
                effectLine = effectLine.trim();
                if (effectLine.length() > 0) {
                    if ((effectLine.startsWith(SET_NUMBER_SEED)) && (effectLine.endsWith(SET_NUMBER_END))) {
                        String nbStr = TextTools.findBetween(effectLine, SET_NUMBER_SEED, SET_NUMBER_END);
                        nbOfItems = NumericTools.parseInt(nbStr, 0);
                    } else {
                        if (nbOfItems != 0) {
                            ret.addBonus(nbOfItems, effectLine);
                        }
                    }
                }
            }
        }
    }
    /*
<div class="itemset">
  <div class="itemsn"><a href="/wiki/Item:Armaments_of_the_Impossible_Shot">Armaments of the Impossible Shot</a></div>
  <div class="itemsps">
    <div class="itemsp"><a href="/wiki/Armour:Helm_of_the_Impossible_Shot">Helm of the Impossible Shot</a></div>
    <div class="itemsp"><a href="/wiki/Armour:Shoulder_guards_of_Impossible_Shot">Shoulder guards of Impossible Shot</a></div>
    <div class="itemsp"><a href="/wiki/Armour:Jacket_of_the_Impossible_Shot">Jacket of the Impossible Shot</a></div>
    <div class="itemsp"><a href="/wiki/Armour:Leggings_of_the_Impossible_Shot">Leggings of the Impossible Shot</a></div>
    <div class="itemsp"><a href="/wiki/Armour:Gloves_of_the_Impossible_Shot">Gloves of the Impossible Shot</a></div>
    <div class="itemsp"><a href="/wiki/Armour:Boots_of_the_Impossible_Shot">Boots of the Impossible Shot</a></div>
  </div>
  <div class="itemseteff">
    <div>Set (2):</div>
    <div>+52.8 in-Combat Power Regen</div>
    <div>Set (3):</div>
    <div>+10% Heart Seeker Damage</div>
    <div>Set (4):</div>
    <div>+600 Physical Mastery Rating</div>
    <div> </div>
    <div>Set (5):</div>
    <div>Intent Concentration recovers all Archer's Art skills</div>
  </div>
  <div class="itemsd"></div>
</div>
     */
    return ret;
}
Also used : ItemsSet(delta.games.lotro.lore.items.ItemsSet) Element(net.htmlparser.jericho.Element)

Aggregations

ItemsSet (delta.games.lotro.lore.items.ItemsSet)4 ArrayList (java.util.ArrayList)3 FixedDecimalsInteger (delta.games.lotro.utils.FixedDecimalsInteger)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Element (net.htmlparser.jericho.Element)2 CharacterClass (delta.games.lotro.common.CharacterClass)1 Money (delta.games.lotro.common.Money)1 Armour (delta.games.lotro.lore.items.Armour)1 ArmourType (delta.games.lotro.lore.items.ArmourType)1 DamageType (delta.games.lotro.lore.items.DamageType)1 Item (delta.games.lotro.lore.items.Item)1 ItemBinding (delta.games.lotro.lore.items.ItemBinding)1 ItemSturdiness (delta.games.lotro.lore.items.ItemSturdiness)1 Weapon (delta.games.lotro.lore.items.Weapon)1 WeaponType (delta.games.lotro.lore.items.WeaponType)1