Search in sources :

Example 1 with ItemStatsProvider

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

the class LotroPlanItemsDbLoader method buildItemFromLine.

private Item buildItemFromLine(LotroPlanTable table, String line) {
    String[] fieldsTrimmed = StringSplitter.split(line.trim(), '\t');
    if (line.startsWith("#")) {
        System.out.println("Ignored: " + line);
        return null;
    }
    if (fieldsTrimmed.length < 2) {
        _section = line.trim();
        System.out.println("Section: " + _section);
        return null;
    }
    String[] fields = StringSplitter.split(line, '\t');
    // Item level
    int itemLevel = NumericTools.parseInt(fields[LotroPlanTable.ITEM_LEVEL_INDEX], -1);
    // Stats
    ItemStatsProvider provider = table.loadStats(fields);
    BasicStatsSet stats = provider.getStats(itemLevel);
    FixedDecimalsInteger armorStat = stats.getStat(STAT.ARMOUR);
    Item item = null;
    Armour armour = null;
    if (armorStat != null) {
        armour = new Armour();
        item = armour;
        armour.setArmourValue(armorStat.intValue());
        stats.removeStat(STAT.ARMOUR);
    } else {
        item = new Item();
    }
    // ID
    String idStr = "";
    int notesIndex = table.getNotesIndex();
    if (fields.length >= notesIndex) {
        idStr = fields[notesIndex].trim();
    }
    int id = 0;
    if (idStr.startsWith("ID:")) {
        idStr = idStr.substring(3).trim();
    }
    id = NumericTools.parseInt(idStr, -1);
    if (id != -1) {
        item.setIdentifier(id);
    }
    // Name
    String name = fields[LotroPlanTable.NAME_INDEX];
    if (name.startsWith("(")) {
        int index = name.indexOf(')');
        idStr = name.substring(1, index).trim();
        id = NumericTools.parseInt(idStr, -1);
        item.setIdentifier(id);
        name = name.substring(index + 1).trim();
    }
    if (name.endsWith(":")) {
        name = name.substring(0, name.length() - 1);
    }
    name = name.replace(' ', ' ');
    if (name.endsWith("s)")) {
        name = name.substring(0, name.length() - 2);
        int index = name.lastIndexOf('(');
        int nbSlots = NumericTools.parseInt(name.substring(index + 1), 0);
        name = name.substring(0, index).trim();
        item.setEssenceSlots(nbSlots);
    }
    if (name.endsWith(")")) {
        String newName = name.substring(0, name.length() - 1);
        int index = newName.lastIndexOf('(');
        String valueStr = newName.substring(index + 1);
        int minLevel;
        if ("TBD".equals(valueStr)) {
            minLevel = -1;
        } else {
            minLevel = NumericTools.parseInt(valueStr, -1);
            name = newName.substring(0, index).trim();
        }
        if (minLevel > 0) {
            item.setMinLevel(Integer.valueOf(minLevel));
        }
    }
    name = name.trim();
    item.setName(name);
    // Item level
    if (itemLevel != -1) {
        item.setItemLevel(Integer.valueOf(itemLevel));
    }
    // Stats
    item.getStats().setStats(stats);
    String slices = provider.toPersistableString();
    int nbSlices = ((SlicesBasedItemStatsProvider) provider).getSlices();
    if (nbSlices > 0) {
        item.setProperty(ItemPropertyNames.FORMULAS, slices);
    }
    // Slot
    EquipmentLocation slot = null;
    if ("Head".equals(_section))
        slot = EquipmentLocation.HEAD;
    else if ("Shoulders".equals(_section))
        slot = EquipmentLocation.SHOULDER;
    else if ("Chest".equals(_section))
        slot = EquipmentLocation.CHEST;
    else if ("Hands".equals(_section))
        slot = EquipmentLocation.HAND;
    else if ("Legs".equals(_section))
        slot = EquipmentLocation.LEGS;
    else if ("Feet".equals(_section))
        slot = EquipmentLocation.FEET;
    else if ("Shields".equals(_section))
        slot = EquipmentLocation.OFF_HAND;
    else if ("Ears".equals(_section))
        slot = EquipmentLocation.EAR;
    else if ("Neck".equals(_section))
        slot = EquipmentLocation.NECK;
    else if ("Wrists".equals(_section))
        slot = EquipmentLocation.WRIST;
    else if ("Fingers".equals(_section))
        slot = EquipmentLocation.FINGER;
    else if ("Pockets".equals(_section))
        slot = EquipmentLocation.POCKET;
    if (slot == null) {
        int categoryIndex = table.getCategoryIndex();
        if ((categoryIndex > 0) && (fields.length >= categoryIndex)) {
            String category = fields[categoryIndex];
            slot = getSlotFromCategory(category);
        }
    }
    // Class requirement
    String classRequirementStr = "";
    int classesIndex = table.getClassesIndex();
    if ((classesIndex != -1) && (fields.length >= classesIndex)) {
        classRequirementStr = fields[classesIndex].trim();
    }
    CharacterClass classRequirement = getClassRequirement(classRequirementStr);
    if (classRequirement != null) {
        item.setRequiredClass(classRequirement);
    }
    if ("Burglar Signals".equals(_section)) {
        item.setSubCategory("Burglar:Signal");
        slot = EquipmentLocation.RANGED_ITEM;
        item.setRequiredClass(CharacterClass.BURGLAR);
    } else if ("Captain Standards".equals(_section)) {
        item.setSubCategory("Captain:Standard");
        slot = EquipmentLocation.RANGED_ITEM;
        item.setRequiredClass(CharacterClass.CAPTAIN);
    } else if ("Hunter Tomes".equals(_section)) {
        String subCategory = "Tome";
        if (name.contains("Wind-rider"))
            subCategory = "Wind-rider";
        if (name.contains("Whisper-draw"))
            subCategory = "Whisper-draw";
        item.setSubCategory("Hunter:" + subCategory);
        slot = EquipmentLocation.CLASS_SLOT;
        item.setRequiredClass(CharacterClass.HUNTER);
    } else if ("Lore-master Brooches".equals(_section)) {
        item.setSubCategory("Lore-master:Stickpin");
        slot = EquipmentLocation.RANGED_ITEM;
        item.setRequiredClass(CharacterClass.LORE_MASTER);
    } else if ("Minstrel Instruments".equals(_section)) {
        item.setSubCategory("Instrument");
        slot = EquipmentLocation.RANGED_ITEM;
        item.setRequiredClass(CharacterClass.MINSTREL);
    } else if ("Rune-keeper Chisels".equals(_section)) {
        String subCategory = "Other";
        if (name.contains("Riffler"))
            subCategory = "Riffler";
        if (name.contains("Chisel"))
            subCategory = "Chisel";
        item.setSubCategory("Rune-keeper:" + subCategory);
        slot = EquipmentLocation.RANGED_ITEM;
        item.setRequiredClass(CharacterClass.RUNE_KEEPER);
    } else if ("Warden Carvings".equals(_section)) {
        item.setSubCategory("Warden:Carving");
        slot = EquipmentLocation.CLASS_SLOT;
        item.setRequiredClass(CharacterClass.WARDEN);
    }
    if (slot != null) {
        item.setEquipmentLocation(slot);
    }
    return item;
}
Also used : SlicesBasedItemStatsProvider(delta.games.lotro.lore.items.stats.SlicesBasedItemStatsProvider) ItemStatsProvider(delta.games.lotro.lore.items.stats.ItemStatsProvider) Item(delta.games.lotro.lore.items.Item) Armour(delta.games.lotro.lore.items.Armour) FixedDecimalsInteger(delta.games.lotro.utils.FixedDecimalsInteger) EquipmentLocation(delta.games.lotro.lore.items.EquipmentLocation) SlicesBasedItemStatsProvider(delta.games.lotro.lore.items.stats.SlicesBasedItemStatsProvider) BasicStatsSet(delta.games.lotro.character.stats.BasicStatsSet) CharacterClass(delta.games.lotro.common.CharacterClass)

Example 2 with ItemStatsProvider

use of delta.games.lotro.lore.items.stats.ItemStatsProvider 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)

Aggregations

BasicStatsSet (delta.games.lotro.character.stats.BasicStatsSet)2 Item (delta.games.lotro.lore.items.Item)2 ItemStatsProvider (delta.games.lotro.lore.items.stats.ItemStatsProvider)2 TextFileReader (delta.common.utils.files.TextFileReader)1 CharacterClass (delta.games.lotro.common.CharacterClass)1 Armour (delta.games.lotro.lore.items.Armour)1 EquipmentLocation (delta.games.lotro.lore.items.EquipmentLocation)1 SlicesBasedItemStatsProvider (delta.games.lotro.lore.items.stats.SlicesBasedItemStatsProvider)1 LotroPlanTable (delta.games.lotro.tools.lore.items.lotroplan.LotroPlanTable)1 FixedDecimalsInteger (delta.games.lotro.utils.FixedDecimalsInteger)1 URL (java.net.URL)1 HashSet (java.util.HashSet)1