Search in sources :

Example 1 with ItemStatSliceData

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

the class MainTestStatsComputer method doStat.

private void doStat(int itemLevel, String formula) {
    ItemStatSliceData slice = SliceFormulaParser.parse(formula);
    SlicesBasedItemStatsProvider provider = new SlicesBasedItemStatsProvider();
    provider.addSlice(slice);
    BasicStatsSet stats = provider.getStats(itemLevel);
    System.out.println(stats);
}
Also used : SlicesBasedItemStatsProvider(delta.games.lotro.lore.items.stats.SlicesBasedItemStatsProvider) ItemStatSliceData(delta.games.lotro.lore.items.stats.ItemStatSliceData) BasicStatsSet(delta.games.lotro.character.stats.BasicStatsSet)

Example 2 with ItemStatSliceData

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

the class LotroPlanTable method loadStats.

/**
 * Load stats from fields.
 * @param fields Fields to read.
 * @return An item stats provider or <code>null</code>.
 */
public ItemStatsProvider loadStats(String[] fields) {
    SlicesBasedItemStatsProvider provider = new SlicesBasedItemStatsProvider();
    int nbStats = _stats.length;
    for (int index = 0; index < nbStats; index++) {
        STAT stat = _stats[index];
        if (stat == null)
            continue;
        if (index >= fields.length)
            continue;
        String valueStr = fields[index];
        if (valueStr.contains("CALCSLICE")) {
            ItemStatSliceData slice = SliceFormulaParser.parse(valueStr);
            if (slice != null) {
                provider.addSlice(slice);
            }
        } else {
            FixedDecimalsInteger value = StatValueParser.parseStatValue(valueStr);
            if (value != null) {
                provider.setStat(stat, value);
            }
        }
    }
    return provider;
}
Also used : STAT(delta.games.lotro.character.stats.STAT) FixedDecimalsInteger(delta.games.lotro.utils.FixedDecimalsInteger) SlicesBasedItemStatsProvider(delta.games.lotro.lore.items.stats.SlicesBasedItemStatsProvider) ItemStatSliceData(delta.games.lotro.lore.items.stats.ItemStatSliceData)

Example 3 with ItemStatSliceData

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

the class SliceFormulaParser method parse.

/**
 * Parse formula.
 * @param formula Formula string.
 * @return Slice parameters or <code>null</code>.
 */
public static ItemStatSliceData parse(String formula) {
    ItemStatSliceData ret = null;
    if ((formula.startsWith(CALCSLICE_SEED)) && (formula.endsWith(CALCSLICE_END))) {
        String paramsStr = formula.substring(CALCSLICE_SEED.length());
        paramsStr = paramsStr.substring(0, paramsStr.length() - CALCSLICE_END.length());
        String[] params = paramsStr.split(";");
        if ((params.length == 2) || (params.length == 3)) {
            String statName = params[0];
            // String itemLevelCell=params[1];
            String sliceCountStr = (params.length == 3) ? params[2] : null;
            if ((statName.startsWith("\"")) && (statName.endsWith("\""))) {
                statName = statName.substring(1, statName.length() - 1);
                Float sliceCount = null;
                if (sliceCountStr != null) {
                    sliceCountStr = sliceCountStr.replace(',', '.').trim();
                    sliceCount = NumericTools.parseFloat(sliceCountStr);
                }
                STAT stat = getStatFromStatName(statName);
                String additionalParameter = null;
                if (stat == STAT.ARMOUR) {
                    additionalParameter = statName;
                }
                if (stat != null) {
                    ret = new ItemStatSliceData(stat, sliceCount, additionalParameter);
                }
            }
        }
    }
    return ret;
}
Also used : STAT(delta.games.lotro.character.stats.STAT) ItemStatSliceData(delta.games.lotro.lore.items.stats.ItemStatSliceData)

Example 4 with ItemStatSliceData

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

the class ScalingParametersFinder method findScalingParameters.

private void findScalingParameters(Item item) {
    BasicStatsSet stats = item.getStats();
    if (stats.getStatsCount() == 0) {
        System.err.println("Cannot manage item: " + item + ": no stats");
        return;
    }
    Integer itemLevel = item.getItemLevel();
    if (itemLevel == null) {
        System.err.println("Cannot manage item: " + item + ": no item level");
        return;
    }
    SliceCountFinder converter = _converters.get(itemLevel);
    if (converter == null) {
        converter = new SliceCountFinder(itemLevel.intValue());
        _converters.put(itemLevel, converter);
    }
    if (item instanceof Armour) {
        Armour armour = (Armour) item;
        int armourValue = armour.getArmourValue();
        stats.setStat(STAT.ARMOUR, new FixedDecimalsInteger(armourValue));
    }
    SlicesBasedItemStatsProvider provider = new SlicesBasedItemStatsProvider();
    for (STAT stat : stats.getStats()) {
        FixedDecimalsInteger value = stats.getStat(stat);
        int statValue = value.getInternalValue();
        ItemStatSliceData slice = null;
        // Specific case for armour
        if (stat == STAT.ARMOUR) {
            ArmourDescriptionFinder armourConverter = _armourConverters.get(itemLevel);
            if (armourConverter == null) {
                armourConverter = new ArmourDescriptionFinder(itemLevel.intValue(), false);
                _armourConverters.put(itemLevel, armourConverter);
            }
            ArmourType armourType = ((Armour) item).getArmourType();
            EquipmentLocation location = item.getEquipmentLocation();
            ItemQuality quality = item.getQuality();
            String label = armourConverter.getArmourDescription(statValue, armourType, location, quality);
            if (label != null) {
                slice = new ItemStatSliceData(stat, null, label);
            } else {
                System.err.println("Armour not found: " + statValue + " for item " + item + ", quality=" + item.getQuality() + ", slot=" + item.getEquipmentLocation() + ", type=" + armourType);
            }
        } else if ((stat == STAT.PARRY_PERCENTAGE) || (stat == STAT.RANGED_DEFENCE_PERCENTAGE)) {
        // Skip... will be put as raw stats
        } else // Other stats
        {
            Float sliceCount = converter.getSliceCount(stat, statValue);
            if (sliceCount != null) {
                slice = new ItemStatSliceData(stat, sliceCount, null);
            } else {
                System.err.println("Stat not found: " + stat + "=" + statValue + " for item " + item + ", quality=" + item.getQuality() + ", slot=" + item.getEquipmentLocation());
            }
        }
        if (slice != null) {
            provider.addSlice(slice);
        } else {
            provider.setStat(stat, value);
        }
    }
    stats.removeStat(STAT.ARMOUR);
    String slices = provider.toPersistableString();
    item.setProperty(ItemPropertyNames.FORMULAS, slices);
    item.setProperty(ItemPropertyNames.SCALING, _scalingId);
}
Also used : ArmourType(delta.games.lotro.lore.items.ArmourType) ItemQuality(delta.games.lotro.lore.items.ItemQuality) BasicStatsSet(delta.games.lotro.character.stats.BasicStatsSet) FixedDecimalsInteger(delta.games.lotro.utils.FixedDecimalsInteger) STAT(delta.games.lotro.character.stats.STAT) 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) ItemStatSliceData(delta.games.lotro.lore.items.stats.ItemStatSliceData)

Example 5 with ItemStatSliceData

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

the class ItemNormalization method findArmourTypeFromFormulas.

private void findArmourTypeFromFormulas(Armour armour) {
    String slices = armour.getProperty(ItemPropertyNames.FORMULAS);
    if (slices != null) {
        SlicesBasedItemStatsProvider provider = SlicesBasedItemStatsProvider.fromPersistedString(slices);
        ItemStatSliceData data = provider.getSliceForStat(STAT.ARMOUR);
        if (data != null) {
            String armourDescription = data.getAdditionalParameter();
            ArmourType sliceType = SlicesBasedItemStatsProvider.getArmorType(armourDescription);
            if (sliceType != null) {
                ArmourType itemType = armour.getArmourType();
                if (itemType != sliceType) {
                    if (itemType != null) {
                        System.out.println("Updated armour type from: " + itemType + " to " + sliceType + " for " + armour);
                    }
                    armour.setArmourType(sliceType);
                }
            }
        }
    }
}
Also used : ArmourType(delta.games.lotro.lore.items.ArmourType) SlicesBasedItemStatsProvider(delta.games.lotro.lore.items.stats.SlicesBasedItemStatsProvider) ItemStatSliceData(delta.games.lotro.lore.items.stats.ItemStatSliceData)

Aggregations

ItemStatSliceData (delta.games.lotro.lore.items.stats.ItemStatSliceData)5 SlicesBasedItemStatsProvider (delta.games.lotro.lore.items.stats.SlicesBasedItemStatsProvider)4 STAT (delta.games.lotro.character.stats.STAT)3 BasicStatsSet (delta.games.lotro.character.stats.BasicStatsSet)2 ArmourType (delta.games.lotro.lore.items.ArmourType)2 FixedDecimalsInteger (delta.games.lotro.utils.FixedDecimalsInteger)2 Armour (delta.games.lotro.lore.items.Armour)1 EquipmentLocation (delta.games.lotro.lore.items.EquipmentLocation)1 ItemQuality (delta.games.lotro.lore.items.ItemQuality)1