Search in sources :

Example 76 with Item

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

the class BuildItemsDbForIcons method doIt.

private void doIt(HashMap<Integer, Item> items) {
    for (Integer id : items.keySet()) {
        Item item = items.get(id);
        // Filter on essences: (set USE_UNIQUE_ICONS to false)
        // String tulkas=item.getProperty(ItemPropertyNames.TULKAS_CATEGORY);
        // String category=item.getSubCategory();
        // if ((category==null) || (!category.contains("Essence"))) continue;
        // Filter on some specific item ids:
        // int idValue=id.intValue();
        // if ((idValue==1879097298) || (idValue==1879109623)
        // || (idValue==1879109618) || (idValue==1879083770) || (idValue==1879115686))
        // {
        String iconId = item.getProperty(ItemPropertyNames.ICON_ID);
        _iconsIds.add(iconId);
        String backgroundIconId = item.getProperty(ItemPropertyNames.BACKGROUND_ICON_ID);
        _backgroundIconsIds.add(backgroundIconId);
        String key = iconId + "-" + backgroundIconId;
        // ImageIcon icon=IconsManager.getItemIcon(iconId,backgroundIconId);
        // if (icon!=null) continue;
        List<Integer> list = _iconIds2Ids.get(key);
        if (list == null) {
            list = new ArrayList<Integer>();
            _iconIds2Ids.put(key, list);
        }
        list.add(id);
    // }
    }
    buildDb(items);
    System.out.println("#Icon/Background icon pairs: " + _iconIds2Ids.size());
    System.out.println("#Icon IDs: " + _iconsIds.size());
    System.out.println("#Background icon IDs: " + _backgroundIconsIds.size());
}
Also used : Item(delta.games.lotro.lore.items.Item)

Example 77 with Item

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

the class ItemPageParser method internalParseItemPage.

/**
 * Parse the item page at the given URL.
 * @param url URL of item page.
 * @return An item or <code>null</code> if an error occurred.
 */
private List<Item> internalParseItemPage(String url) {
    List<Item> items = null;
    try {
        DownloadService downloader = DownloadService.getInstance();
        String page = downloader.getPage(url);
        Source source = new Source(page);
        // <div id="lorebookNoedit">
        // Element lorebook=JerichoHtmlUtils.findElementByTagNameAndAttributeValue(source,HTMLElementName.DIV,"id","lorebookNoedit");
        // if (lorebook!=null)
        {
            items = new ArrayList<Item>();
            // Fetch identifier
            List<Element> itemSections = JerichoHtmlUtils.findElementsByTagNameAndAttributeValue(source, HTMLElementName.TABLE, "class", "tooltip");
            if ((itemSections != null) && (itemSections.size() > 0)) {
                String key = fetchItemKey(source);
                _key = key;
                for (Element itemSection : itemSections) {
                    Item item = parseItemSection(itemSection);
                    if (item != null) {
                        items.add(item);
                        item.setKey(key);
                    }
                }
                findIdentifiers(items);
            }
            List<Element> resourceSections = JerichoHtmlUtils.findElementsByTagNameAndAttributeValue(source, HTMLElementName.DIV, "class", "lorebookresource");
            if ((resourceSections != null) && (resourceSections.size() > 0)) {
                String key = fetchItemKey(source);
                _key = key;
                for (Element resourceSection : resourceSections) {
                    Item item = parseResourceSection(resourceSection);
                    if (item != null) {
                        items.add(item);
                        item.setKey(key);
                    }
                }
                findIdentifiers(items);
            }
        }
    } catch (Exception e) {
        items = null;
        _logger.error("Cannot parse item page [" + url + "]", e);
    }
    return items;
}
Also used : Item(delta.games.lotro.lore.items.Item) Element(net.htmlparser.jericho.Element) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) DownloadService(delta.games.lotro.utils.DownloadService) Source(net.htmlparser.jericho.Source) InputSource(org.xml.sax.InputSource)

Example 78 with Item

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

the class ItemPageParser method parseItemSection.

private Item parseItemSection(Element itemSection) {
    Item ret = null;
    try {
        _item = null;
        Element itemTooltip = JerichoHtmlUtils.findElementByTagNameAndAttributeValue(itemSection, HTMLElementName.TABLE, "class", "tooltip");
        if (itemTooltip != null) {
            parseItemDescription(itemTooltip);
        }
        ret = _item;
    } catch (Exception e) {
        ret = null;
        _logger.error("Item [" + _key + "]. Cannot parse item section!", e);
    }
    return ret;
}
Also used : Item(delta.games.lotro.lore.items.Item) Element(net.htmlparser.jericho.Element)

Example 79 with Item

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

the class ItemPageParser method parseResourceSection.

private Item parseResourceSection(Element resourceSection) {
    Item ret = null;
    try {
        Element officialSection = JerichoHtmlUtils.findElementByTagNameAndAttributeValue(resourceSection, HTMLElementName.DIV, "class", "officialsection");
        if (officialSection != null) {
            ret = new Item();
            // Name
            String name = null;
            Element nameElement = JerichoHtmlUtils.findElementByTagNameAndAttributeValue(officialSection, HTMLElementName.DIV, "class", "lorebooktitle");
            if (nameElement != null) {
                name = CharacterReference.decodeCollapseWhiteSpace(nameElement.getContent());
                if (name != null) {
                    if (name.startsWith(RESOURCE_SEED)) {
                        name = name.substring(RESOURCE_SEED.length()).trim();
                    }
                }
            }
            ret.setName(name);
            // Description
            List<Element> divs = JerichoHtmlUtils.findElementsByTagName(officialSection, HTMLElementName.DIV);
            if ((divs != null) && (divs.size() >= 4)) {
                Element div = divs.get(3);
                String description = CharacterReference.decodeCollapseWhiteSpace(div.getContent());
                ret.setDescription(description);
            }
        }
    } catch (Exception e) {
        ret = null;
        _logger.error("Item [" + _key + "]. Cannot parse item section!", e);
    }
    return ret;
}
Also used : Item(delta.games.lotro.lore.items.Item) Element(net.htmlparser.jericho.Element)

Example 80 with Item

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

the class ItemsConcat method main.

/**
 * Main method.
 * @param args Not used.
 */
public static void main(String[] args) {
    System.out.println("Concatenation of legacy items into one file...");
    File itemsDir = new File("d:\\dam\\tmp\\items");
    FileFilter fileFilter = new ExtensionPredicate("xml");
    File[] itemFiles = itemsDir.listFiles(fileFilter);
    if (itemFiles != null) {
        // BonusConverter converter=new BonusConverter();
        ItemXMLParser parser = new ItemXMLParser();
        List<Item> itemsList = new ArrayList<Item>();
        for (File itemFile : itemFiles) {
            String idStr = itemFile.getName();
            idStr = idStr.substring(0, idStr.length() - 4);
            int id = NumericTools.parseInt(idStr, -1);
            if (id != -1) {
                // System.out.println(id);
                Item item = parser.parseXML(itemFile);
                /*
          List<String> bonuses=item.getBonus();
          if (bonuses.size()>0)
          {
            RawBonusParser bonusParser=new RawBonusParser();
            BonusManager bonusMgr=bonusParser.build(bonuses);
            if (bonusParser.hasWarn())
            {
              String name=item.getName();
              System.out.println("Item: "+id+", name="+name);
              for(String bonus : bonuses)
              {
                System.out.println("\t"+bonus);
              }
            }
            if (bonusMgr!=null)
            {
              BasicStatsSet stats=converter.getStats(bonusMgr);
              item.getStats().setStats(stats);
            }
          }
          */
                item.setIdentifier(id);
                itemsList.add(item);
            }
        }
        File toFile = new File("itemsLegacy.xml").getAbsoluteFile();
        ItemXMLWriter.writeItemsFile(toFile, itemsList);
    }
}
Also used : Item(delta.games.lotro.lore.items.Item) ItemXMLParser(delta.games.lotro.lore.items.io.xml.ItemXMLParser) ArrayList(java.util.ArrayList) ExtensionPredicate(delta.common.utils.files.filter.ExtensionPredicate) FileFilter(java.io.FileFilter) File(java.io.File)

Aggregations

Item (delta.games.lotro.lore.items.Item)105 ArrayList (java.util.ArrayList)29 HashMap (java.util.HashMap)19 File (java.io.File)17 FixedDecimalsInteger (delta.games.lotro.utils.FixedDecimalsInteger)16 Armour (delta.games.lotro.lore.items.Armour)15 LegendaryItem (delta.games.lotro.lore.items.legendary.LegendaryItem)12 BasicStatsSet (delta.games.lotro.character.stats.BasicStatsSet)11 ArmourType (delta.games.lotro.lore.items.ArmourType)8 EquipmentLocation (delta.games.lotro.lore.items.EquipmentLocation)8 Weapon (delta.games.lotro.lore.items.Weapon)8 JMenuItem (javax.swing.JMenuItem)8 EQUIMENT_SLOT (delta.games.lotro.character.CharacterEquipment.EQUIMENT_SLOT)7 CharacterClass (delta.games.lotro.common.CharacterClass)7 ItemsManager (delta.games.lotro.lore.items.ItemsManager)7 CharacterEquipment (delta.games.lotro.character.CharacterEquipment)6 ItemsStash (delta.games.lotro.character.storage.ItemsStash)6 WeaponType (delta.games.lotro.lore.items.WeaponType)6 ItemQuality (delta.games.lotro.lore.items.ItemQuality)5 List (java.util.List)5