Search in sources :

Example 16 with BasicStatsSet

use of delta.games.lotro.character.stats.BasicStatsSet 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 17 with BasicStatsSet

use of delta.games.lotro.character.stats.BasicStatsSet in project lotro-companion by dmorcellet.

the class EssencesSummary method update.

/**
 * Update counts.
 */
public void update() {
    _count.clear();
    _essencesCount = 0;
    _slotsCount = 0;
    _stats.clear();
    CharacterEquipment equipment = _toon.getEquipment();
    for (EQUIMENT_SLOT slot : EQUIMENT_SLOT.values()) {
        Item item = equipment.getItemForSlot(slot);
        if (item != null) {
            EssencesSet essences = item.getEssences();
            int nbSlots = item.getEssenceSlots();
            int nbEssences = (essences != null) ? essences.getSize() : 0;
            int slotsCount = Math.max(nbSlots, nbEssences);
            // Increment total essence slot count
            _slotsCount += slotsCount;
            if (essences != null) {
                for (int i = 0; i < nbEssences; i++) {
                    Item essence = essences.getEssence(i);
                    if (essence != null) {
                        // Increment by-essence count
                        Integer essenceId = Integer.valueOf(essence.getIdentifier());
                        EssenceCount count = _count.get(essenceId);
                        if (count == null) {
                            count = new EssenceCount(essence);
                            _count.put(essenceId, count);
                        }
                        count.increment();
                        // Increment essences count
                        _essencesCount++;
                        BasicStatsSet essenceStats = essence.getStats();
                        _stats.addStats(essenceStats);
                    }
                }
            }
        }
    }
}
Also used : Item(delta.games.lotro.lore.items.Item) CharacterEquipment(delta.games.lotro.character.CharacterEquipment) EQUIMENT_SLOT(delta.games.lotro.character.CharacterEquipment.EQUIMENT_SLOT) EssencesSet(delta.games.lotro.lore.items.essences.EssencesSet) BasicStatsSet(delta.games.lotro.character.stats.BasicStatsSet)

Example 18 with BasicStatsSet

use of delta.games.lotro.character.stats.BasicStatsSet in project lotro-companion by dmorcellet.

the class CharacterDataWindowController method eventOccurred.

/**
 * Handle character events.
 * @param event Source event.
 */
@Override
public void eventOccurred(CharacterEvent event) {
    CharacterEventType type = event.getType();
    if (type == CharacterEventType.CHARACTER_DATA_UPDATED) {
        CharacterData data = event.getToonData();
        if (data == _data) {
            // Compute new stats
            CharacterStatsComputer computer = new CharacterStatsComputer();
            BasicStatsSet stats = computer.getStats(data);
            BasicStatsSet toonStats = _data.getStats();
            toonStats.clear();
            toonStats.setStats(stats);
            // Update stats display
            _statsController.update();
            // Update buffs display
            _buffsController.update();
        }
    }
    if (type == CharacterEventType.CHARACTER_SUMMARY_UPDATED) {
        CharacterFile toonFile = event.getToonFile();
        if (toonFile == _toonFile) {
            // Update sex
            _attrsController.updateSexDisplay();
        }
    }
}
Also used : CharacterEventType(delta.games.lotro.character.events.CharacterEventType) CharacterData(delta.games.lotro.character.CharacterData) CharacterStatsComputer(delta.games.lotro.character.stats.CharacterStatsComputer) BasicStatsSet(delta.games.lotro.character.stats.BasicStatsSet) CharacterFile(delta.games.lotro.character.CharacterFile)

Example 19 with BasicStatsSet

use of delta.games.lotro.character.stats.BasicStatsSet in project lotro-companion by dmorcellet.

the class CharacterStatsSummaryPanelController method doDetails.

private void doDetails() {
    DetailedCharacterStatsWindowController detailsStatsController = getDetailsController();
    if (detailsStatsController == null) {
        detailsStatsController = new DetailedCharacterStatsWindowController(_parent, _toon);
        _childControllers.registerWindow(detailsStatsController);
        BasicStatsSet referenceStats = new BasicStatsSet(_toon.getStats());
        detailsStatsController.setStats(referenceStats, _toon.getStats());
        detailsStatsController.getWindow().setLocationRelativeTo(_parent.getWindow());
    }
    detailsStatsController.bringToFront();
}
Also used : DetailedCharacterStatsWindowController(delta.games.lotro.gui.character.stats.details.DetailedCharacterStatsWindowController) BasicStatsSet(delta.games.lotro.character.stats.BasicStatsSet)

Example 20 with BasicStatsSet

use of delta.games.lotro.character.stats.BasicStatsSet in project lotro-companion by dmorcellet.

the class StatValuesPanelController method update.

/**
 * Update this panel with new stats.
 * @param values Stats to display.
 */
public void update(BasicStatsSet values) {
    _values = new BasicStatsSet(values);
    _deltaValues.clear();
    update();
}
Also used : BasicStatsSet(delta.games.lotro.character.stats.BasicStatsSet)

Aggregations

BasicStatsSet (delta.games.lotro.character.stats.BasicStatsSet)38 FixedDecimalsInteger (delta.games.lotro.utils.FixedDecimalsInteger)13 STAT (delta.games.lotro.character.stats.STAT)12 Item (delta.games.lotro.lore.items.Item)11 Armour (delta.games.lotro.lore.items.Armour)9 CharacterClass (delta.games.lotro.common.CharacterClass)7 EquipmentLocation (delta.games.lotro.lore.items.EquipmentLocation)6 CharacterData (delta.games.lotro.character.CharacterData)5 CharacterStatsComputer (delta.games.lotro.character.stats.CharacterStatsComputer)4 SlicesBasedItemStatsProvider (delta.games.lotro.lore.items.stats.SlicesBasedItemStatsProvider)4 JPanel (javax.swing.JPanel)4 CharacterEquipment (delta.games.lotro.character.CharacterEquipment)3 EQUIMENT_SLOT (delta.games.lotro.character.CharacterEquipment.EQUIMENT_SLOT)3 ArmourType (delta.games.lotro.lore.items.ArmourType)3 ItemQuality (delta.games.lotro.lore.items.ItemQuality)3 Weapon (delta.games.lotro.lore.items.Weapon)3 ArrayList (java.util.ArrayList)3 JFrame (javax.swing.JFrame)3 Element (net.htmlparser.jericho.Element)3 DefaultWindowController (delta.common.ui.swing.windows.DefaultWindowController)2