Search in sources :

Example 41 with Item

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

the class ItemNormalization method trimData.

private void trimData(List<Item> items) {
    for (Item item : items) {
        // Remove money
        item.setValue(null);
        // Remove bonuses
        item.getBonus().clear();
        // Remove useless properties
        item.removeProperty(ItemPropertyNames.ICON_URL);
        item.removeProperty(ItemPropertyNames.ITEM_KEY);
        item.removeProperty(ItemPropertyNames.LEGACY_NAME);
        item.removeProperty(ItemPropertyNames.OLD_TULKAS_NAME);
        item.removeProperty(ItemPropertyNames.LEGACY_CATEGORY);
        item.removeProperty(ItemPropertyNames.TULKAS_CATEGORY);
    }
}
Also used : LegendaryItem(delta.games.lotro.lore.items.legendary.LegendaryItem) Item(delta.games.lotro.lore.items.Item)

Example 42 with Item

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

the class ItemNormalization method loadItemsFile.

private HashMap<Integer, Item> loadItemsFile(File file) {
    List<Item> items = ItemSaxParser.parseItemsFile(file);
    HashMap<Integer, Item> ret = new HashMap<Integer, Item>();
    for (Item item : items) {
        ret.put(Integer.valueOf(item.getIdentifier()), item);
    }
    return ret;
}
Also used : FixedDecimalsInteger(delta.games.lotro.utils.FixedDecimalsInteger) LegendaryItem(delta.games.lotro.lore.items.legendary.LegendaryItem) Item(delta.games.lotro.lore.items.Item) HashMap(java.util.HashMap)

Example 43 with Item

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

the class ItemNormalization method normalizeJewels.

private Item normalizeJewels(Item item) {
    Item ret = item;
    // int id=item.getIdentifier();
    String categoryProp = item.getProperty(ItemPropertyNames.TULKAS_CATEGORY);
    String subCategory = item.getSubCategory();
    if (("49".equals(categoryProp)) || ("49".equals(subCategory))) {
        String previousSubCategory = ret.getSubCategory();
        // Pocket=103, Wrist=211, Ear=211, Neck=170, Finger=198
        if ("Pocket".equals(previousSubCategory)) {
            ret.setEquipmentLocation(EquipmentLocation.POCKET);
            ret.setSubCategory(null);
        } else if ("Wrist".equals(previousSubCategory)) {
            ret.setEquipmentLocation(EquipmentLocation.WRIST);
            ret.setSubCategory(null);
        } else if ("Ear".equals(previousSubCategory)) {
            ret.setEquipmentLocation(EquipmentLocation.EAR);
            ret.setSubCategory(null);
        } else if ("Neck".equals(previousSubCategory)) {
            ret.setEquipmentLocation(EquipmentLocation.NECK);
            ret.setSubCategory(null);
        } else if ("Finger".equals(previousSubCategory)) {
            ret.setEquipmentLocation(EquipmentLocation.FINGER);
            ret.setSubCategory(null);
        } else {
            EquipmentLocation loc = ret.getEquipmentLocation();
            if (loc != null) {
                ret.setSubCategory(null);
            } else {
                ret.setSubCategory("Jewelry");
                normalizeJewelByName(ret, "Token", EquipmentLocation.POCKET);
                normalizeJewelByName(ret, "Earring", EquipmentLocation.EAR);
                normalizeJewelByName(ret, "Bauble", EquipmentLocation.POCKET);
                normalizeJewelByName(ret, "Necklace", EquipmentLocation.NECK);
                normalizeJewelByName(ret, "Ring", EquipmentLocation.FINGER);
                normalizeJewelByName(ret, "Bracelet", EquipmentLocation.WRIST);
                normalizeJewelByName(ret, "Cuff", EquipmentLocation.WRIST);
                normalizeJewelByName(ret, "Ear Cuff", EquipmentLocation.EAR);
                normalizeJewelByName(ret, "Barrow-brie", EquipmentLocation.POCKET);
                normalizeJewelByName(ret, "Stone", EquipmentLocation.POCKET);
                normalizeJewelByName(ret, "Pendant", EquipmentLocation.NECK);
                normalizeJewelByName(ret, "Choker", EquipmentLocation.NECK);
                normalizeJewelByName(ret, "Band ", EquipmentLocation.FINGER);
                normalizeJewelByName(ret, "Armlet", EquipmentLocation.WRIST);
                // normalizeJewelByName(ret,"Bangle of Deep Waters",EquipmentLocation.WRIST);
                normalizeJewelByName(ret, "Mountain-stone", EquipmentLocation.POCKET);
                normalizeJewelByName(ret, "Scroll", EquipmentLocation.POCKET);
                normalizeJewelByName(ret, "Phial", EquipmentLocation.POCKET);
                normalizeJewelByName(ret, "Pocket-square", EquipmentLocation.POCKET);
                normalizeJewelByName(ret, "Locket", EquipmentLocation.POCKET);
                // Specific names for pocket items
                normalizeJewelByName(ret, "Carved Jewellery Box", EquipmentLocation.POCKET);
                String name = ret.getName();
                if ("Plains Walker's Symbol".equals(name)) {
                    ret.setRequiredClass(CharacterClass.BEORNING);
                    ret.setEquipmentLocation(EquipmentLocation.POCKET);
                    ret.setSubCategory(null);
                } else if ("Talisman of the Tundra Cub".equals(name)) {
                    ret.setRequiredClass(CharacterClass.LORE_MASTER);
                    ret.setEquipmentLocation(null);
                    ret.setSubCategory(CharacterClass.LORE_MASTER.getLabel() + ":Talisman");
                }
            }
        }
        EquipmentLocation slot = ret.getEquipmentLocation();
        if (slot == null) {
            String name = ret.getName();
            System.out.println("Slot not found for jewel: " + name);
        }
        ret.removeProperty(ItemPropertyNames.TULKAS_CATEGORY);
        ret.removeProperty(ItemPropertyNames.LEGACY_CATEGORY);
        if (ret instanceof Armour) {
            Armour armour = (Armour) ret;
            int armourValue = armour.getArmourValue();
            // Transmutate to item so that further filtering works good
            Item newItem = new Item();
            newItem.copyFrom(ret);
            newItem.getStats().setStat(STAT.ARMOUR, new FixedDecimalsInteger(armourValue));
            ret = newItem;
        }
    }
    return ret;
}
Also used : LegendaryItem(delta.games.lotro.lore.items.legendary.LegendaryItem) Item(delta.games.lotro.lore.items.Item) Armour(delta.games.lotro.lore.items.Armour) EquipmentLocation(delta.games.lotro.lore.items.EquipmentLocation) FixedDecimalsInteger(delta.games.lotro.utils.FixedDecimalsInteger)

Example 44 with Item

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

the class ItemNormalization method doIt.

/**
 * Do the job.
 */
public void doIt() {
    File file1 = new File("data/items/tmp/items-rc.xml");
    HashMap<Integer, Item> sourceItems = loadItemsFile(file1);
    System.out.println(sourceItems.size());
    List<Integer> ids = new ArrayList<Integer>(sourceItems.keySet());
    for (Integer id : ids) {
        Item sourceItem = sourceItems.get(id);
        sourceItem = normalizeItem(sourceItem);
        if (sourceItem != null) {
            sourceItems.put(id, sourceItem);
        } else {
            sourceItems.remove(id);
        }
    }
    // Essences stats injection
    new EssenceStatsInjector().doIt(sourceItems.values());
    // Build final items list
    List<Item> items = new ArrayList<Item>(sourceItems.values());
    // Find/handle scalable items
    // - scalable instances rewards
    {
        List<Item> scalableInstancesRewards = new ScalableItemsFinder().findScalableItems(items);
        System.out.println("Found " + scalableInstancesRewards.size() + " scalable instances rewards");
        new ScalingParametersFinder(ScalingRulesNames.SCALABLE_REWARDS).findScalingParameters(scalableInstancesRewards);
    }
    // - Big Battles rewards
    {
        List<Item> bbJewels = new BigBattlesJewelsFinder().findScalableItems(items);
        System.out.println("Found " + bbJewels.size() + " BB jewels:");
        new ScalingParametersFinder(ScalingRulesNames.BIG_BATTLES).findScalingParameters(bbJewels);
        new ItemStatistics().showStatistics(bbJewels);
    }
    // Guess armor types from formulas
    findArmourTypeFromFormulas(items);
    // Trim useless data
    trimData(items);
    // Sort items by ID
    Collections.sort(items, new ItemIdComparator());
    // Consistency checks
    new ConsistencyChecks().consistencyChecks(items);
    // Filtering items
    List<Item> filteredItems = filterItems(items);
    // Write result files
    File toFile = new File("data/items/items.xml").getAbsoluteFile();
    ItemXMLWriter.writeItemsFile(toFile, items);
    File filteredItemsFile = new File("data/items/items_filtered.xml").getAbsoluteFile();
    ItemXMLWriter.writeItemsFile(filteredItemsFile, filteredItems);
    // Dump unmanaged items
    if (_byCategory.size() > 0) {
        System.out.println("There are unmanaged item categories:");
        List<String> categories = new ArrayList<String>(_byCategory.keySet());
        Collections.sort(categories);
        int totalSize = 0;
        for (String category : categories) {
            int size = _byCategory.get(category).size();
            System.out.println(category + "  =>  " + size + _byCategory.get(category));
            totalSize += size;
        }
        System.out.println(totalSize);
    }
    new ItemStatistics().showStatistics(filteredItems);
/*
    ItemsSorter sorter=new ItemsSorter();
    sorter.sortItems(items);
    File rootDir=new File("sorted");
    rootDir.mkdirs();
    sorter.writeToFiles(rootDir);
    */
}
Also used : ItemIdComparator(delta.games.lotro.lore.items.comparators.ItemIdComparator) EssenceStatsInjector(delta.games.lotro.tools.lore.items.lotroplan.essences.EssenceStatsInjector) ArrayList(java.util.ArrayList) BigBattlesJewelsFinder(delta.games.lotro.tools.lore.items.scalables.BigBattlesJewelsFinder) ConsistencyChecks(delta.games.lotro.tools.lore.items.ConsistencyChecks) ScalingParametersFinder(delta.games.lotro.tools.lore.items.scalables.ScalingParametersFinder) FixedDecimalsInteger(delta.games.lotro.utils.FixedDecimalsInteger) LegendaryItem(delta.games.lotro.lore.items.legendary.LegendaryItem) Item(delta.games.lotro.lore.items.Item) ItemStatistics(delta.games.lotro.tools.lore.items.ItemStatistics) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) ScalableItemsFinder(delta.games.lotro.tools.lore.items.scalables.ScalableItemsFinder)

Example 45 with Item

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

the class MergeItemsLegacyAndTulkasIndex method loadItemsFile.

// Map tulkas subcategories int ids to list of legacy subcategories names
// private HashMap<String,HashMap<String,IntegerHolder>> _tulkas2legacySubCategoriesMap;
// private HashMap<String,Set<String>> _legacy2tulkasSubCategoriesMap;
private HashMap<Integer, Item> loadItemsFile(File file) {
    List<Item> items = ItemSaxParser.parseItemsFile(file);
    HashMap<Integer, Item> ret = new HashMap<Integer, Item>();
    for (Item item : items) {
        ret.put(Integer.valueOf(item.getIdentifier()), item);
    }
    return ret;
}
Also used : Item(delta.games.lotro.lore.items.Item) HashMap(java.util.HashMap)

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