Search in sources :

Example 31 with Item

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

the class EssenceStatsInjector method findEssences.

private List<Item> findEssences(String[] fields, boolean hasId, HashMap<Integer, Item> essences) {
    List<Item> ret = new ArrayList<Item>();
    Integer id = null;
    if (hasId) {
        id = NumericTools.parseInteger(fields[0]);
    }
    int nameIndex = NAME_INDEX + (hasId ? 1 : 0);
    String name = fields[nameIndex];
    if (name.startsWith("-")) {
        name = name.substring(1).trim();
    }
    for (Item essence : essences.values()) {
        if (id != null) {
            if (id.intValue() == essence.getIdentifier()) {
                ret.add(essence);
                return ret;
            }
        }
        if (name.equals(essence.getName())) {
            ret.add(essence);
        }
    }
    return ret;
}
Also used : Item(delta.games.lotro.lore.items.Item) ArrayList(java.util.ArrayList)

Example 32 with Item

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

the class EssenceStatsInjector method sortByTier.

private HashMap<Integer, HashMap<Integer, Item>> sortByTier(List<Item> essences) {
    List<Integer> tiers = loadTiers();
    HashMap<Integer, HashMap<Integer, Item>> essencesByTier = new HashMap<Integer, HashMap<Integer, Item>>();
    int nbEssences = essences.size();
    int nbTierSpecifications = tiers.size();
    if (nbEssences != nbTierSpecifications) {
        System.err.println("Warning! Bad tier specifications: nbEssences=" + nbEssences + "!=nbTierSpecifications" + nbTierSpecifications);
    }
    for (int i = 0; i < nbEssences; i++) {
        Item item = essences.get(i);
        Integer tier = (i < nbTierSpecifications) ? tiers.get(i) : null;
        // System.out.println(item.getName()+"  =>  "+tier);
        if (tier != null) {
            String category = "Essence:Tier" + tier;
            item.setSubCategory(category);
        } else {
            // Unspecified
            tier = Integer.valueOf(-1);
        }
        HashMap<Integer, Item> essencesOfTier = essencesByTier.get(tier);
        if (essencesOfTier == null) {
            essencesOfTier = new HashMap<Integer, Item>();
            essencesByTier.put(tier, essencesOfTier);
        }
        essencesOfTier.put(Integer.valueOf(item.getIdentifier()), item);
    }
    return essencesByTier;
}
Also used : Item(delta.games.lotro.lore.items.Item) HashMap(java.util.HashMap)

Example 33 with Item

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

the class EssenceStatsInjector method handleTier.

private void handleTier(int tier, HashMap<Integer, Item> essences) {
    URL url = URLTools.getFromClassPath("tier" + tier + ".txt", EssenceStatsInjector.class.getPackage());
    if (url != null) {
        TextFileReader reader = new TextFileReader(url, EncodingNames.UTF_8);
        List<String> lines = TextUtils.readAsLines(reader);
        boolean hasId = lines.get(0).startsWith("ID");
        lines.remove(0);
        HashSet<Integer> unmanaged = new HashSet<Integer>();
        unmanaged.addAll(essences.keySet());
        LotroPlanTable table = new LotroPlanTable(STATS);
        for (String line : lines) {
            String[] fields = StringSplitter.split(line, '\t');
            if (fields.length > 2) {
                List<Item> items = findEssences(fields, hasId, essences);
                for (Item item : items) {
                    if (hasId) {
                        String[] newFields = new String[fields.length - 1];
                        for (int i = 1; i < fields.length; i++) {
                            newFields[i - 1] = fields[i];
                            if (newFields[i - 1].equals(CELLS[i])) {
                                newFields[i - 1] = "";
                            }
                        }
                        fields = newFields;
                    }
                    unmanaged.remove(Integer.valueOf(item.getIdentifier()));
                    // Item level
                    int itemLevel = NumericTools.parseInt(fields[ITEM_LEVEL_INDEX], -1);
                    if (itemLevel != -1) {
                        item.setItemLevel(Integer.valueOf(itemLevel));
                    }
                    // Notes
                    if (fields.length > NOTES_INDEX) {
                        String notes = fields[NOTES_INDEX].trim();
                        if (notes.length() > 0) {
                            item.getBonus().add(notes);
                        }
                    }
                    // Tier
                    item.setSubCategory("Essence:Tier" + tier);
                    // Stats
                    ItemStatsProvider provider = table.loadStats(fields);
                    BasicStatsSet stats = item.getStats();
                    stats.setStats(provider.getStats(itemLevel));
                }
                if (items.size() == 0) {
                    System.out.println("Essence not found: " + fields[0]);
                }
            } else {
                if (!line.startsWith("#")) {
                    System.err.println("Bad fields count: " + line);
                }
            }
        }
        if (unmanaged.size() > 0) {
            System.out.println(unmanaged + " unmanaged essences:");
            for (Integer id : unmanaged) {
                Item essence = essences.get(id);
                System.out.println("\t" + essence);
            }
        }
    }
}
Also used : LotroPlanTable(delta.games.lotro.tools.lore.items.lotroplan.LotroPlanTable) BasicStatsSet(delta.games.lotro.character.stats.BasicStatsSet) URL(java.net.URL) TextFileReader(delta.common.utils.files.TextFileReader) ItemStatsProvider(delta.games.lotro.lore.items.stats.ItemStatsProvider) Item(delta.games.lotro.lore.items.Item) HashSet(java.util.HashSet)

Example 34 with Item

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

the class MainItemStatsSheetTemplateGenerator method getEssences.

private List<Item> getEssences(List<Item> items, int tier) {
    List<Item> ret = new ArrayList<Item>();
    String expectedCategory = "Essence:Tier" + tier;
    for (Item item : items) {
        String category = item.getSubCategory();
        if (expectedCategory.equals(category)) {
            ret.add(item);
        }
    }
    return ret;
}
Also used : Item(delta.games.lotro.lore.items.Item) ArrayList(java.util.ArrayList)

Example 35 with Item

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

the class MainItemStatsSheetTemplateGenerator method doIt.

private void doIt() {
    File newFile = new File("data\\items\\items_filtered.xml").getAbsoluteFile();
    List<Item> newItems = ItemSaxParser.parseItemsFile(newFile);
    List<Item> essences = getEssences(newItems, 10);
    buildTemplate(essences);
}
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