Search in sources :

Example 1 with Money

use of delta.games.lotro.common.Money in project lotro-tools by dmorcellet.

the class ItemPageParser method parseMoneyReward.

private Money parseMoneyReward(Element rewardDiv) {
    Money m = new Money();
    List<Segment> nodes = JerichoHtmlUtils.getChildNodes(rewardDiv);
    int nb = nodes.size();
    for (int i = 0; i < nb; i++) {
        Segment s = nodes.get(i);
        if (s.getClass() == Segment.class) {
            String text = s.toString();
            if (text.equalsIgnoreCase("Worth"))
                continue;
            int nbCoins = NumericTools.parseInt(s.toString(), 0);
            if ((nbCoins > 0) && (i < nb - 1)) {
                Segment tmp = nodes.get(i + 1);
                if (tmp instanceof StartTag) {
                    String className = ((StartTag) tmp).getAttributeValue("class");
                    if ("coin".equals(className)) {
                        String type = ((StartTag) tmp).getAttributeValue("src");
                        if (type != null) {
                            if (type.contains("silver")) {
                                m.setSilverCoins(nbCoins);
                            } else if (type.contains("copper")) {
                                m.setCopperCoins(nbCoins);
                            } else if (type.contains("gold")) {
                                m.setGoldCoins(nbCoins);
                            } else {
                                _logger.warn("Item [" + _key + "]. Unknown coin type [" + type + "]");
                            }
                        }
                    }
                }
            }
        }
    }
    return m;
/*
     <div class="itemworth">
        Worth&nbsp;&nbsp;&nbsp;3
        <img class="coin" src="http://content.turbine.com/sites/lorebook.lotro.com/images/icons/currency/silver.gif">
        &nbsp;30
        <img class="coin" src="http://content.turbine.com/sites/lorebook.lotro.com/images/icons/currency/copper.gif">
     </div>
    */
}
Also used : Money(delta.games.lotro.common.Money) Segment(net.htmlparser.jericho.Segment) StartTag(net.htmlparser.jericho.StartTag)

Example 2 with Money

use of delta.games.lotro.common.Money 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 3 with Money

use of delta.games.lotro.common.Money in project lotro-tools by dmorcellet.

the class RewardsHTMLParser method parseReward.

private void parseReward(Element rewardDiv, Rewards rewards) {
    List<Element> strongs = rewardDiv.getAllElements(HTMLElementName.STRONG);
    if ((strongs != null) && (strongs.size() >= 1)) {
        Element strong = strongs.get(0);
        String key = CharacterReference.decodeCollapseWhiteSpace(strong.getContent());
        key = cleanupFieldName(key);
        if ("Money".equals(key)) {
            Money m = parseMoneyReward(rewardDiv);
            rewards.getMoney().add(m);
        } else if ("Reputation".equals(key)) {
            Reputation r = parseReputationReward(rewardDiv);
            rewards.getReputation().add(r);
        } else if ((RECEIVE_KEY.equals(key)) || (SELECT_ONE_OF_KEY.equals(key))) {
            parseItemReward(rewardDiv, rewards);
        } else if ("IXP".equals(key)) {
            boolean itemXP = parseItemXPReward(rewardDiv);
            rewards.setHasItemXP(itemXP);
        } else if ("Traits".equals(key)) {
            parseTraitReward(rewardDiv, rewards);
        } else if ("Titles".equals(key)) {
            parseTitleReward(rewardDiv, rewards);
        } else if ("Virtues".equals(key)) {
            parseVirtuesReward(rewardDiv, rewards);
        } else if ("Emotes".equals(key)) {
            parseEmoteReward(rewardDiv, rewards);
        } else if ("Destiny Points".equals(key)) {
            int nb = parseDestinyPoints(rewardDiv);
            rewards.setDestinyPoints(nb);
        } else {
            _logger.error(_objectId + ": unknown reward type: " + key);
        }
    }
}
Also used : Money(delta.games.lotro.common.Money) Element(net.htmlparser.jericho.Element) Reputation(delta.games.lotro.common.Reputation)

Example 4 with Money

use of delta.games.lotro.common.Money in project lotro-tools by dmorcellet.

the class RewardsHTMLParser method parseMoneyReward.

private Money parseMoneyReward(Element rewardDiv) {
    // System.out.println("Money reward!");
    Money m = new Money();
    List<Element> elements = rewardDiv.getChildElements();
    if ((elements != null) && (elements.size() == 2)) {
        Element moneyNode = elements.get(1);
        List<Segment> nodes = JerichoHtmlUtils.getChildNodes(moneyNode);
        int nb = nodes.size();
        for (int i = 0; i < nb; i++) {
            Segment s = nodes.get(i);
            if (s.getClass() == Segment.class) {
                int nbCoins = NumericTools.parseInt(s.toString(), 0);
                if ((nbCoins > 0) && (i < nb - 1)) {
                    Segment tmp = nodes.get(i + 1);
                    if (tmp instanceof StartTag) {
                        String className = ((StartTag) tmp).getAttributeValue("class");
                        if ("coin".equals(className)) {
                            String type = ((StartTag) tmp).getAttributeValue("src");
                            if (type != null) {
                                if (type.contains("silver")) {
                                    m.setSilverCoins(nbCoins);
                                } else if (type.contains("copper")) {
                                    m.setCopperCoins(nbCoins);
                                } else if (type.contains("gold")) {
                                    m.setGoldCoins(nbCoins);
                                } else {
                                    _logger.warn(_objectId + ": unknown coin type [" + type + "]");
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return m;
/*
    <div class="questReward">
    <div>
    <strong>Money:</strong>
    </div>
    <div>
    29
    <img class="coin" src="http://content.turbine.com/sites/lorebook.lotro.com/images/icons/currency/silver.gif">
    &nbsp;5
    <img class="coin" src="http://content.turbine.com/sites/lorebook.lotro.com/images/icons/currency/copper.gif">
    </div>
    </div>
    */
}
Also used : Money(delta.games.lotro.common.Money) Element(net.htmlparser.jericho.Element) Segment(net.htmlparser.jericho.Segment) StartTag(net.htmlparser.jericho.StartTag)

Aggregations

Money (delta.games.lotro.common.Money)4 Element (net.htmlparser.jericho.Element)3 Segment (net.htmlparser.jericho.Segment)2 StartTag (net.htmlparser.jericho.StartTag)2 CharacterClass (delta.games.lotro.common.CharacterClass)1 Reputation (delta.games.lotro.common.Reputation)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 ItemsSet (delta.games.lotro.lore.items.ItemsSet)1 Weapon (delta.games.lotro.lore.items.Weapon)1 WeaponType (delta.games.lotro.lore.items.WeaponType)1 ArrayList (java.util.ArrayList)1