Search in sources :

Example 21 with Item

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

the class ItemsAndIconsManager method loadItems.

private void loadItems(String key) {
    System.out.println("Loading item [" + key + "]");
    File itemsDir = LotroCoreConfig.getInstance().getItemsDir();
    if (!itemsDir.exists()) {
        itemsDir.mkdirs();
    }
    key = Escapes.escapeIdentifier(key);
    String url = "http://lorebook.lotro.com/wiki/" + key;
    ItemPageParser parser = new ItemPageParser();
    List<Item> items = parser.parseItemPage(url);
    if ((items != null) && (items.size() > 0)) {
        ItemsManager itemsManager = ItemsManager.getInstance();
        for (Item item : items) {
            System.out.println(item.dump());
            int id = item.getIdentifier();
            if (id != 0) {
                itemsManager.writeItemFile(item);
            } else {
                _logger.warn("Item [" + key + "]: identifier=0!");
            }
        }
    } else {
        _logger.error("Cannot parse item [" + key + "] at URL [" + url + "]!");
    }
}
Also used : Item(delta.games.lotro.lore.items.Item) ItemsManager(delta.games.lotro.lore.items.ItemsManager) File(java.io.File)

Example 22 with Item

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

the class ItemsDbLoader method main.

/**
 * Main method.
 * @param args Not used.
 */
public static void main(String[] args) {
    LotroDataSource ds = LotroDataSource.getInstance("lotro");
    ObjectsManager<Item> itemsSource = ds.getManager(Item.class);
    ItemsManager mgr = ItemsManager.getInstance();
    File itemsDir = LotroCoreConfig.getInstance().getItemsDir();
    FileFilter fileFilter = new ExtensionPredicate("xml");
    File[] itemFiles = itemsDir.listFiles(fileFilter);
    if (itemFiles != null) {
        HashMap<String, IntegerHolder> other = new HashMap<String, IntegerHolder>();
        // HashMap<String,List<String>> itemsByCategory=new HashMap<String,List<String>>();
        for (File itemFile : itemFiles) {
            // if (nb==10000) break;
            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 = mgr.getItem(Integer.valueOf(id));
                // System.out.println(item.dump());
                BonusManager bonusMgr = item.getBonusManager();
                if (bonusMgr != null) {
                    // System.out.println(bonusMgr.dump());
                    int nbBonus = bonusMgr.getNumberOfBonus();
                    for (int i = 0; i < nbBonus; i++) {
                        Bonus bonus = bonusMgr.getBonusAt(i);
                        if (bonus.getBonusType() == BonusType.OTHER) {
                            String value = (String) bonus.getValue();
                            IntegerHolder holder = other.get(value);
                            if (holder == null) {
                                holder = new IntegerHolder();
                                other.put(value, holder);
                            }
                            holder.setInt(holder.getInt() + 1);
                        }
                    }
                }
                itemsSource.create(item);
            }
        // nb++;
        }
        List<String> others = new ArrayList<String>(other.keySet());
        Collections.sort(others);
        for (String value : others) {
            IntegerHolder counter = other.get(value);
            System.out.println(value + " -> " + counter);
        }
    /*
      for(Map.Entry<String,IntegerHolder> entry : other.entrySet())
      {
        System.out.println(entry.getKey()+" -> "+entry.getValue());
      }
      */
    }
}
Also used : ItemsManager(delta.games.lotro.lore.items.ItemsManager) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ExtensionPredicate(delta.common.utils.files.filter.ExtensionPredicate) Bonus(delta.games.lotro.lore.items.bonus.Bonus) LotroDataSource(delta.games.lotro.lore.sql.LotroDataSource) Item(delta.games.lotro.lore.items.Item) IntegerHolder(delta.common.utils.misc.IntegerHolder) BonusManager(delta.games.lotro.lore.items.bonus.BonusManager) FileFilter(java.io.FileFilter) File(java.io.File)

Example 23 with Item

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

the class IconsDbBuilder method doIt.

private void doIt() {
    _iconsDbDir.mkdirs();
    File toFile = new File("items.xml").getAbsoluteFile();
    HashMap<Integer, Item> items = loadItemsFile(toFile);
    System.out.println(items.size());
    for (Integer id : items.keySet()) {
        Item item = items.get(id);
        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;
        List<Integer> list = _iconIds2Ids.get(key);
        if (list == null) {
            list = new ArrayList<Integer>();
            _iconIds2Ids.put(key, list);
        }
        list.add(id);
    }
    System.out.println(_iconIds2Ids.size());
    System.out.println(_iconsIds.size());
    System.out.println(_backgroundIconsIds.size());
    for (Map.Entry<String, List<Integer>> entry : _iconIds2Ids.entrySet()) {
        handleIconList(items, entry.getKey(), entry.getValue());
    /*
      int size=entry.getValue().size();
      if (size > 10)
      {
        System.out.println(entry.getKey() + " -> " + size);
      }
      */
    }
    System.out.println("Nb items with icon: " + _nbItemsWithIcon);
    System.out.println("Nb items with no icon: " + _nbItemsWithNoIcon);
    System.out.println("Nb icons missing: " + _nbDifferentIconsMissing);
// System.out.println(_iconIds2Ids);
}
Also used : Item(delta.games.lotro.lore.items.Item) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) HashMap(java.util.HashMap) Map(java.util.Map)

Example 24 with Item

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

the class ScalableItemsSamplesLoader method loadTable.

/**
 * Load items from a table.
 * @param filename Name of file to read.
 * @return A list of items.
 */
public List<Item> loadTable(String filename) {
    URL url = URLTools.getFromClassPath(filename, ScalableItemsSamplesLoader.class.getPackage());
    TextFileReader reader = new TextFileReader(url, EncodingNames.UTF_8);
    List<String> lines = TextUtils.readAsLines(reader);
    List<Item> items = new ArrayList<Item>();
    lines.remove(0);
    for (String line : lines) {
        Item item = buildItemFromLine(line);
        if (item != null) {
            items.add(item);
        }
    }
    return items;
}
Also used : Item(delta.games.lotro.lore.items.Item) ArrayList(java.util.ArrayList) URL(java.net.URL) TextFileReader(delta.common.utils.files.TextFileReader)

Example 25 with Item

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

the class LotroPlanItemsDbLoader method doIt.

/**
 * Do the job.
 */
public void doIt() {
    _merger = new ItemsMerger();
    List<Item> items = loadTable("itemsdb.txt");
    _merger.registerItems(items);
    for (String tableName : NAMES) {
        handleAdditionalTable(tableName);
    }
    File toFile = new File("data/items/tmp/itemsdb.xml").getAbsoluteFile();
    items = _merger.getItems();
    setScalingRules(items);
    ItemXMLWriter.writeItemsFile(toFile, items);
// List<Integer> ids=new ArrayList<Integer>(_failedItems.keySet());
// new BuildItemsDbForIcons().buildDb(_failedItems,ids);
}
Also used : Item(delta.games.lotro.lore.items.Item) 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