Search in sources :

Example 26 with Item

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

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

the class LotroPlanItemsDbLoader method setScalingRules.

private void setScalingRules(List<Item> items) {
    for (Item item : items) {
        String scalingRule = null;
        String itemLevels = item.getProperty(ItemPropertyNames.LEVELS);
        if (itemLevels != null) {
            if (itemLevels.endsWith("207]"))
                scalingRule = ScalingRulesNames.TEAL_ARMOR_SETS;
            if ("[201, 221]".equals(itemLevels))
                scalingRule = ScalingRulesNames.OSGILIATH;
            if (scalingRule != null) {
                item.setProperty(ItemPropertyNames.SCALING, scalingRule);
            }
            item.removeProperty(ItemPropertyNames.LEVELS);
        }
    }
}
Also used : Item(delta.games.lotro.lore.items.Item)

Example 28 with Item

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

the class LotroPlanItemsDbLoader method handleAdditionalTable.

private void handleAdditionalTable(String tableName) {
    ArmourType armourType = null;
    if ("heavy.txt".equals(tableName))
        armourType = ArmourType.HEAVY;
    else if ("medium.txt".equals(tableName))
        armourType = ArmourType.MEDIUM;
    else if ("light.txt".equals(tableName))
        armourType = ArmourType.LIGHT;
    List<Item> items = loadTable(tableName);
    for (Item item : items) {
        _merger.newItem(item, armourType);
    }
}
Also used : Item(delta.games.lotro.lore.items.Item) ArmourType(delta.games.lotro.lore.items.ArmourType)

Example 29 with Item

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

the class LotroPlanItemsDbLoader method loadTable.

/**
 * Load the items in a table.
 * @param filename Table name.
 * @return A list of items.
 */
public List<Item> loadTable(String filename) {
    _section = null;
    URL url = URLTools.getFromClassPath(filename, LotroPlanItemsDbLoader.class.getPackage());
    TextFileReader reader = new TextFileReader(url, EncodingNames.UTF_8);
    List<String> lines = TextUtils.readAsLines(reader);
    List<Item> items = new ArrayList<Item>();
    // _fields=StringSplitter.split(lines.get(0),'\t');
    lines.remove(0);
    boolean mordor = useMordorFormat(filename);
    LotroPlanTable table = new LotroPlanTable(mordor);
    for (String line : lines) {
        Item item = buildItemFromLine(table, line);
        if (item != null) {
            items.add(item);
        }
    }
    return items;
}
Also used : Item(delta.games.lotro.lore.items.Item) ArrayList(java.util.ArrayList) URL(java.net.URL) TextFileReader(delta.common.utils.files.TextFileReader)

Example 30 with Item

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

the class EssenceStatsInjector method getEssences.

private List<Item> getEssences(Collection<Item> items) {
    List<Item> itemsSortedById = new ArrayList<Item>(items);
    Collections.sort(itemsSortedById, new ItemIdComparator());
    List<Item> ret = new ArrayList<Item>();
    for (Item item : itemsSortedById) {
        String category = item.getSubCategory();
        if ("Essence".equals(category)) {
            String name = item.getName();
            // Ignore Mordor Essences boxes
            if (name.contains("Mordor - Essences")) {
                item.setSubCategory("Box of Essences");
                continue;
            }
            ret.add(item);
        }
    }
    return ret;
}
Also used : Item(delta.games.lotro.lore.items.Item) ItemIdComparator(delta.games.lotro.lore.items.comparators.ItemIdComparator) ArrayList(java.util.ArrayList)

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