Search in sources :

Example 1 with ItemsManager

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

the class UpdateItemDefinitions method main.

/**
 * @param args
 */
public static void main(String[] args) {
    ItemsManager mgr = ItemsManager.getInstance();
    File itemsDir = LotroCoreConfig.getInstance().getItemsDir();
    FileFilter fileFilter = new ExtensionPredicate("xml");
    File[] itemFiles = itemsDir.listFiles(fileFilter);
    if (itemFiles != null) {
        for (File itemFile : itemFiles) {
            String name = itemFile.getName();
            name = name.substring(0, name.length() - 4);
            int id = NumericTools.parseInt(name, -1);
            if (id != -1) {
                itemFile.delete();
                mgr.getItem(Integer.valueOf(id));
            }
        }
    }
}
Also used : ItemsManager(delta.games.lotro.lore.items.ItemsManager) ExtensionPredicate(delta.common.utils.files.filter.ExtensionPredicate) FileFilter(java.io.FileFilter) File(java.io.File)

Example 2 with ItemsManager

use of delta.games.lotro.lore.items.ItemsManager 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 3 with ItemsManager

use of delta.games.lotro.lore.items.ItemsManager 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 4 with ItemsManager

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

the class ItemNormalization method filterItems.

/**
 * Filter items that are accessible within LotroCompanion.
 * @param items List to filter.
 * @return a list that contains the filtered items.
 */
private List<Item> filterItems(List<Item> items) {
    ItemsManager manager = new ItemsManager(items);
    Set<Integer> selectedIds = new HashSet<Integer>();
    // Iterate on classes then on slots to find all reachable items
    for (CharacterClass cClass : CharacterClass.ALL_CLASSES) {
        CharacterData c = new CharacterData();
        c.setCharacterClass(cClass);
        c.setLevel(105);
        for (EQUIMENT_SLOT slot : EQUIMENT_SLOT.values()) {
            List<Item> selectedItems = manager.getItems(c, slot);
            for (Item selectedItem : selectedItems) {
                selectedIds.add(Integer.valueOf(selectedItem.getIdentifier()));
            }
        }
    }
    // Essences
    List<Item> essences = manager.getEssences();
    for (Item essence : essences) {
        selectedIds.add(Integer.valueOf(essence.getIdentifier()));
    }
    // Build final list
    List<Item> selectedItems = new ArrayList<Item>();
    for (Item item : items) {
        if (selectedIds.contains(Integer.valueOf(item.getIdentifier()))) {
            selectedItems.add(item);
        }
    }
    return selectedItems;
}
Also used : FixedDecimalsInteger(delta.games.lotro.utils.FixedDecimalsInteger) LegendaryItem(delta.games.lotro.lore.items.legendary.LegendaryItem) Item(delta.games.lotro.lore.items.Item) ItemsManager(delta.games.lotro.lore.items.ItemsManager) CharacterData(delta.games.lotro.character.CharacterData) EQUIMENT_SLOT(delta.games.lotro.character.CharacterEquipment.EQUIMENT_SLOT) ArrayList(java.util.ArrayList) CharacterClass(delta.games.lotro.common.CharacterClass) HashSet(java.util.HashSet)

Example 5 with ItemsManager

use of delta.games.lotro.lore.items.ItemsManager in project lotro-companion by dmorcellet.

the class EquipmentPanelController method chooseItem.

private Item chooseItem(EQUIMENT_SLOT slot, List<Item> items) {
    ItemsManager itemsManager = new ItemsManager(items);
    List<Item> selectedItems = itemsManager.getItems(_toonData, slot);
    ItemFilterConfiguration cfg = new ItemFilterConfiguration();
    cfg.initFromItems(selectedItems);
    ItemFilterController filterController = new ItemFilterController(cfg);
    Filter<Item> filter = filterController.getFilter();
    String id = ItemChoiceWindowController.ITEM_CHOOSER_PROPERTIES_ID + "#" + slot.name();
    TypedProperties props = _parentWindow.getUserProperties(id);
    ItemChoiceWindowController choiceCtrl = new ItemChoiceWindowController(_parentWindow, props, selectedItems, filter, filterController);
    Item ret = choiceCtrl.editModal();
    return ret;
}
Also used : JMenuItem(javax.swing.JMenuItem) Item(delta.games.lotro.lore.items.Item) ItemsManager(delta.games.lotro.lore.items.ItemsManager) ItemChoiceWindowController(delta.games.lotro.gui.items.ItemChoiceWindowController) ItemFilterController(delta.games.lotro.gui.items.ItemFilterController) TypedProperties(delta.common.utils.misc.TypedProperties) ItemFilterConfiguration(delta.games.lotro.gui.items.ItemFilterConfiguration)

Aggregations

ItemsManager (delta.games.lotro.lore.items.ItemsManager)8 Item (delta.games.lotro.lore.items.Item)7 ArrayList (java.util.ArrayList)4 File (java.io.File)3 ExtensionPredicate (delta.common.utils.files.filter.ExtensionPredicate)2 FileFilter (java.io.FileFilter)2 HashMap (java.util.HashMap)2 IntegerHolder (delta.common.utils.misc.IntegerHolder)1 TypedProperties (delta.common.utils.misc.TypedProperties)1 CharacterData (delta.games.lotro.character.CharacterData)1 EQUIMENT_SLOT (delta.games.lotro.character.CharacterEquipment.EQUIMENT_SLOT)1 StoredItem (delta.games.lotro.character.storage.StoredItem)1 CharacterClass (delta.games.lotro.common.CharacterClass)1 ItemChoiceWindowController (delta.games.lotro.gui.items.ItemChoiceWindowController)1 ItemFilterConfiguration (delta.games.lotro.gui.items.ItemFilterConfiguration)1 ItemFilterController (delta.games.lotro.gui.items.ItemFilterController)1 Bonus (delta.games.lotro.lore.items.bonus.Bonus)1 BonusManager (delta.games.lotro.lore.items.bonus.BonusManager)1 LegendaryItem (delta.games.lotro.lore.items.legendary.LegendaryItem)1 LotroDataSource (delta.games.lotro.lore.sql.LotroDataSource)1