Search in sources :

Example 46 with Item

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

the class MergeItemsLegacyAndTulkasIndex method doIt.

/**
 * Do the job.
 */
public void doIt() {
    File file1 = new File("data/items/in/itemsLegacy.xml");
    HashMap<Integer, Item> legacyItems = loadItemsFile(file1);
    System.out.println(legacyItems.size());
    File file2 = new File("data/items/tmp/itemsTulkasIndex.xml");
    HashMap<Integer, Item> tulkasItems = loadItemsFile(file2);
    System.out.println(tulkasItems.size());
    HashMap<Integer, Item> mergeResult = new HashMap<Integer, Item>();
    for (Integer id : tulkasItems.keySet()) {
        Item tulkasItem = tulkasItems.get(id);
        Item result = tulkasItem;
        // inspectItemCategories(tulkasItem);
        Item legacyItem = legacyItems.get(id);
        if ((tulkasItem != null) && (legacyItem != null)) {
            result = mergeItems(tulkasItem, legacyItem);
            legacyItems.remove(id);
        }
        String tulkasSubCategory = tulkasItem.getSubCategory();
        result.setProperty(ItemPropertyNames.TULKAS_CATEGORY, tulkasSubCategory);
        mergeResult.put(Integer.valueOf(result.getIdentifier()), result);
    }
    System.out.println(legacyItems.size());
    File toFile = new File("data/items/tmp/itemsLegacy+TulkasIndex.xml").getAbsoluteFile();
    List<Item> items = new ArrayList<Item>(mergeResult.values());
    ItemXMLWriter.writeItemsFile(toFile, items);
// dumpCategoriesInfo();
}
Also used : Item(delta.games.lotro.lore.items.Item) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) File(java.io.File)

Example 47 with Item

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

the class MergeWithLotroPlanDb method doIt.

/**
 * Do the job.
 */
public void doIt() {
    File file1 = new File("data/items/tmp/itemsLegacy+Tulkas.xml");
    HashMap<Integer, Item> sourceItems = loadItemsFile(file1, null);
    System.out.println(sourceItems.size());
    File file2 = new File("data/items/tmp/itemsdb.xml");
    Map<String, Item> itemsWithNoId = new HashMap<String, Item>();
    HashMap<Integer, Item> lotroPlanItems = loadItemsFile(file2, itemsWithNoId);
    System.out.println("LOTRO plan items (with ID): " + lotroPlanItems.size());
    System.out.println("LOTRO plan items (no ID): " + itemsWithNoId.size());
    HashMap<Integer, Item> mergeResult = new HashMap<Integer, Item>();
    for (Integer id : sourceItems.keySet()) {
        Item sourceItem = sourceItems.get(id);
        Item result = sourceItem;
        Item lotroPlanItem = lotroPlanItems.get(id);
        if (lotroPlanItem == null) {
            String sourceName = sourceItem.getName();
            if (sourceName != null) {
                sourceName = sourceName.replace(' ', ' ');
            }
            lotroPlanItem = itemsWithNoId.get(sourceName);
            if (lotroPlanItem != null) {
                itemsWithNoId.remove(sourceName);
            }
        } else {
            lotroPlanItems.remove(id);
        }
        if (lotroPlanItem != null) {
            result = mergeItems(sourceItem, lotroPlanItem);
        }
        mergeResult.put(Integer.valueOf(result.getIdentifier()), result);
    }
    if (lotroPlanItems.size() > 0) {
        System.out.println("LOTRO plan items (with ID), not used: " + lotroPlanItems.size() + ": " + lotroPlanItems);
    }
    if (itemsWithNoId.size() > 0) {
        System.out.println("LOTRO plan items (no ID), not used: " + itemsWithNoId.size() + ": " + itemsWithNoId);
    }
    File toFile = new File("data/items/tmp/items-rc.xml").getAbsoluteFile();
    List<Item> items = new ArrayList<Item>(mergeResult.values());
    ItemXMLWriter.writeItemsFile(toFile, items);
}
Also used : FixedDecimalsInteger(delta.games.lotro.utils.FixedDecimalsInteger) Item(delta.games.lotro.lore.items.Item) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) File(java.io.File)

Example 48 with Item

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

the class MergeWithLotroPlanDb method loadItemsFile.

private HashMap<Integer, Item> loadItemsFile(File file, Map<String, Item> noIdItems) {
    List<Item> items = ItemSaxParser.parseItemsFile(file);
    HashMap<Integer, Item> ret = new HashMap<Integer, Item>();
    for (Item item : items) {
        int id = item.getIdentifier();
        if (id > 0) {
            ret.put(Integer.valueOf(id), item);
        } else {
            if (noIdItems != null) {
                String name = item.getName();
                name = name.replace(' ', ' ');
                Item old = noIdItems.put(name, item);
                if (old != null) {
                    System.err.println("Warning: multiple item with no ID and the same name: " + old);
                }
            }
        }
    }
    return ret;
}
Also used : FixedDecimalsInteger(delta.games.lotro.utils.FixedDecimalsInteger) Item(delta.games.lotro.lore.items.Item) HashMap(java.util.HashMap)

Example 49 with Item

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

the class MergeWithTulkasNew method mergeItems.

private Item mergeItems(Item source, Item tulkas) {
    int id = source.getIdentifier();
    Item result = source;
    // Check types
    if (source.getClass() != tulkas.getClass()) {
        // System.out.println("ID: " + id+": type conflict: tulkas=" + tulkas.getClass() + ", source=" + source.getClass());
        if (source.getClass() == Item.class) {
            if (tulkas instanceof Weapon) {
                Weapon weapon = new Weapon();
                Weapon tulkasWeapon = (Weapon) tulkas;
                result = weapon;
                weapon.copyFrom(source);
                weapon.setMinDamage(tulkasWeapon.getMinDamage());
                weapon.setMaxDamage(tulkasWeapon.getMaxDamage());
                weapon.setDPS(tulkasWeapon.getDPS());
                weapon.setDamageType(tulkasWeapon.getDamageType());
                weapon.setWeaponType(tulkasWeapon.getWeaponType());
            } else if (tulkas instanceof Armour) {
                Armour armour = new Armour();
                Armour tulkasArmour = (Armour) tulkas;
                result = armour;
                armour.copyFrom(source);
                armour.setArmourValue(tulkasArmour.getArmourValue());
                armour.setArmourType(tulkasArmour.getArmourType());
            }
        } else {
            System.out.println("Unmanaged cast");
        }
    } else {
        result = source;
    }
    String sourceName = source.getName();
    // Name
    {
        String tulkasName = tulkas.getName();
        if (!tulkasName.equals(sourceName)) {
            // System.out.println("ID: " + id+": name conflict: tulkas=" + tulkasName + ", source=" + sourceName);
            if (tulkasName != null) {
                result.setProperty(ItemPropertyNames.OLD_TULKAS_NAME, tulkasName);
            }
        }
    }
    // Required level
    {
        Integer tulkasMinLevel = tulkas.getMinLevel();
        Integer sourceMinLevel = result.getMinLevel();
        boolean conflict = false;
        if (tulkasMinLevel != null) {
            if (sourceMinLevel == null) {
                // conflict=true;
                result.setMinLevel(tulkasMinLevel);
            } else {
                if (tulkasMinLevel.intValue() != sourceMinLevel.intValue()) {
                    conflict = true;
                    result.setMinLevel(tulkasMinLevel);
                }
            }
        } else {
            if (sourceMinLevel != null) {
                conflict = true;
                result.setMinLevel(sourceMinLevel);
            }
        }
        if (conflict) {
        // System.out.println("ID: " + id+": min level conflict: tulkas=" + tulkasMinLevel + ", source=" + sourceMinLevel);
        }
    }
    // Item level
    {
        result.setItemLevel(tulkas.getItemLevel());
    }
    // Required class
    {
        CharacterClass tulkasClass = tulkas.getRequiredClass();
        CharacterClass sourceClass = source.getRequiredClass();
        if (tulkasClass != sourceClass) {
            if ((tulkasClass != null) && (sourceClass == null)) {
                result.setRequiredClass(tulkasClass);
            } else {
                System.out.println("ID: " + id + ": required class conflict: tulkas=" + tulkasClass + ", source=" + sourceClass);
            }
        }
    }
    // Quality
    {
        ItemQuality tulkasQuality = tulkas.getQuality();
        ItemQuality sourceQuality = source.getQuality();
        if (tulkasQuality != sourceQuality) {
            // Use source quality since it comes from tulkas index (17.1), which is more recent that tulkas new (13.1)
            result.setQuality(sourceQuality);
        // System.out.println("ID: " + id+": quality conflict: tulkas=" + tulkasQuality + ", source=" + sourceQuality);
        }
    }
    // Bonus
    if (result != source) {
        result.getBonus().clear();
        result.getBonus().addAll(source.getBonus());
    }
    // Stats
    result.getStats().setStats(tulkas.getStats());
    // Slot
    {
        EquipmentLocation tulkasSlot = tulkas.getEquipmentLocation();
        EquipmentLocation sourceSlot = source.getEquipmentLocation();
        if (tulkasSlot != sourceSlot) {
            // Use tulkas slot since it is not set in source
            result.setEquipmentLocation(tulkasSlot);
        // System.out.println("ID: " + id+": slot conflict: tulkas=" + tulkasSlot + ", source=" + sourceSlot);
        }
    }
    return result;
}
Also used : Item(delta.games.lotro.lore.items.Item) Armour(delta.games.lotro.lore.items.Armour) EquipmentLocation(delta.games.lotro.lore.items.EquipmentLocation) ItemQuality(delta.games.lotro.lore.items.ItemQuality) Weapon(delta.games.lotro.lore.items.Weapon) CharacterClass(delta.games.lotro.common.CharacterClass)

Example 50 with Item

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

the class LotroWikiDeedCategoryPageParser method resolveItem.

private void resolveItem(ObjectItem objectItem) {
    String name = objectItem.getName();
    int itemId = resolveByName(name);
    if (itemId == 0) {
        Item item = _resolver.getItem(name);
        if (item != null) {
            itemId = item.getIdentifier();
        }
    }
    if (itemId != 0) {
        objectItem.setItemId(itemId);
        objectItem.setObjectURL(null);
        objectItem.setIconURL(null);
    } else {
        System.out.println("Item not found [" + name + "]");
    }
}
Also used : Item(delta.games.lotro.lore.items.Item) ObjectItem(delta.games.lotro.common.objects.ObjectItem)

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