Search in sources :

Example 16 with FixedDecimalsInteger

use of delta.games.lotro.utils.FixedDecimalsInteger in project lotro-companion by dmorcellet.

the class StatValuesPanelController method buildContents.

private void buildContents() {
    // Clear
    _panel.removeAll();
    GridBagConstraints c = new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 5, 2, 5), 0, 0);
    // First line: Base stat
    // - First cell blank
    c.gridx++;
    // - Stat name
    STAT baseStat = _config.getBaseStat();
    JLabel baseStatNameLabel = GuiFactory.buildLabel(baseStat.getName());
    _panel.add(baseStatNameLabel, c);
    // - Stat value
    c.gridx++;
    FixedDecimalsInteger baseStatValue = _values.getStat(baseStat);
    JLabel baseStatValueLabel = GuiFactory.buildLabel(StatDisplayUtils.getStatDisplay(baseStatValue, baseStat.isPercentage()));
    _panel.add(baseStatValueLabel, c);
    c.gridy++;
    boolean doComputeDelta = (_deltaValues.size() == 0);
    // Stat lines
    int level = _config.getLevel();
    List<SingleStatCurveConfiguration> curveConfigs = _config.getCurveConfigurations();
    int nbCurves = curveConfigs.size();
    int index = 0;
    for (int curveIndex = 0; curveIndex < nbCurves; curveIndex++) {
        SingleStatCurveConfiguration curveConfig = curveConfigs.get(curveIndex);
        Color color = StatCurveChartPanelController.LINE_COLORS[curveIndex];
        List<STAT> stats = curveConfig.getStats();
        for (STAT stat : stats) {
            c.gridx = 0;
            c.fill = GridBagConstraints.NONE;
            c.weightx = 0.0;
            // Add color
            JLabel coloredLabel = buildColoredLabel(color);
            _panel.add(coloredLabel, c);
            c.gridx++;
            // Stat name
            JLabel statNameLabel = GuiFactory.buildLabel(stat.getName());
            _panel.add(statNameLabel, c);
            c.gridx++;
            // Stat value
            FixedDecimalsInteger statValueFromCurve = getStatValue(curveConfig, level, baseStatValue);
            FixedDecimalsInteger statValue = _values.getStat(stat);
            String statValueFromCurveStr = StatDisplayUtils.getStatDisplay(statValueFromCurve, stat.isPercentage());
            JLabel statValueFromCurveLabel = GuiFactory.buildLabel(statValueFromCurveStr);
            _panel.add(statValueFromCurveLabel, c);
            c.gridx++;
            // Bonus
            FixedDecimalsInteger deltaValue = null;
            if (doComputeDelta) {
                deltaValue = getDeltaValue(statValueFromCurve, statValue);
                _deltaValues.add(deltaValue);
            } else {
                deltaValue = _deltaValues.get(index);
            }
            if (deltaValue != null) {
                String deltaValueStr = StatDisplayUtils.getStatDisplay(deltaValue, stat.isPercentage());
                if (deltaValue.getInternalValue() > 0)
                    deltaValueStr = "+" + deltaValueStr;
                FixedDecimalsInteger totalValue = new FixedDecimalsInteger(statValueFromCurve);
                totalValue.add(deltaValue);
                String totalValueStr = StatDisplayUtils.getStatDisplay(totalValue, stat.isPercentage());
                String bonusStr = deltaValueStr + " = " + totalValueStr;
                JLabel bonusLabel = GuiFactory.buildLabel(bonusStr);
                _panel.add(bonusLabel, c);
                c.gridx++;
            }
            // Add 'buffer' empty column
            {
                c.fill = GridBagConstraints.BOTH;
                c.weightx = 1.0;
                Component glue = Box.createGlue();
                _panel.add(glue, c);
            }
            c.gridx++;
            c.gridy++;
            index++;
        }
    }
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) Color(java.awt.Color) JLabel(javax.swing.JLabel) STAT(delta.games.lotro.character.stats.STAT) FixedDecimalsInteger(delta.games.lotro.utils.FixedDecimalsInteger) Component(java.awt.Component)

Example 17 with FixedDecimalsInteger

use of delta.games.lotro.utils.FixedDecimalsInteger in project lotro-companion by dmorcellet.

the class StatValuesPanelController method getDeltaValue.

private FixedDecimalsInteger getDeltaValue(FixedDecimalsInteger statValueFromCurve, FixedDecimalsInteger statValue) {
    FixedDecimalsInteger deltaValue = null;
    if ((statValueFromCurve != null) && (statValue != null)) {
        int delta = statValue.getInternalValue() - statValueFromCurve.getInternalValue();
        if (delta != 0) {
            deltaValue = new FixedDecimalsInteger();
            deltaValue.setRawValue(delta);
        }
    }
    return deltaValue;
}
Also used : FixedDecimalsInteger(delta.games.lotro.utils.FixedDecimalsInteger)

Example 18 with FixedDecimalsInteger

use of delta.games.lotro.utils.FixedDecimalsInteger in project lotro-companion by dmorcellet.

the class StatContribsPanelController method updateStat.

private void updateStat(STAT stat) {
    if (stat == null) {
        return;
    }
    ContribsByStat contribs = _contribs.getContribs(stat);
    if (contribs == null) {
        contribs = new ContribsByStat(stat);
    }
    _chartPanel.setContributions(contribs);
    _table.setContributions(contribs);
    FixedDecimalsInteger statValue = _toon.getStats().getStat(stat);
    updateTotals(contribs, statValue);
}
Also used : ContribsByStat(delta.games.lotro.character.stats.contribs.ContribsByStat) FixedDecimalsInteger(delta.games.lotro.utils.FixedDecimalsInteger)

Example 19 with FixedDecimalsInteger

use of delta.games.lotro.utils.FixedDecimalsInteger in project lotro-companion by dmorcellet.

the class MainTestSingleStatWidgetsController method doIt.

private void doIt() {
    BasicStatsSet value = new BasicStatsSet();
    value.addStat(STAT.MORALE, new FixedDecimalsInteger(100));
    value.addStat(STAT.CRITICAL_MELEE_PERCENTAGE, new FixedDecimalsInteger(12.3f));
    BasicStatsSet reference = new BasicStatsSet();
    reference.addStat(STAT.MORALE, new FixedDecimalsInteger(67));
    reference.addStat(STAT.CRITICAL_MELEE_PERCENTAGE, new FixedDecimalsInteger(13.3f));
    JLabel morale = GuiFactory.buildLabel("Morale");
    SingleStatWidgetsController moraleCtrl = new SingleStatWidgetsController(STAT.MORALE, false);
    moraleCtrl.updateStats(reference, value);
    showFrameForStat(morale, moraleCtrl);
    JLabel critMelee = GuiFactory.buildLabel("Crit Melee %");
    SingleStatWidgetsController critCtrl = new SingleStatWidgetsController(STAT.CRITICAL_MELEE_PERCENTAGE, true);
    critCtrl.updateStats(reference, value);
    showFrameForStat(critMelee, critCtrl);
}
Also used : FixedDecimalsInteger(delta.games.lotro.utils.FixedDecimalsInteger) JLabel(javax.swing.JLabel) BasicStatsSet(delta.games.lotro.character.stats.BasicStatsSet)

Example 20 with FixedDecimalsInteger

use of delta.games.lotro.utils.FixedDecimalsInteger in project lotro-tools by dmorcellet.

the class StatValueParser method parseStatValue.

/**
 * Parse a stat value.
 * @param valueStr Input string.
 * @return A value or <code>null</code>.
 */
public static FixedDecimalsInteger parseStatValue(String valueStr) {
    FixedDecimalsInteger ret = null;
    int factor = 1;
    if (valueStr.startsWith("=")) {
        valueStr = valueStr.substring(1);
        factor = 100;
    }
    if (valueStr.endsWith("%")) {
        valueStr = valueStr.substring(0, valueStr.length() - 1);
    }
    valueStr = valueStr.replace(',', '.').trim();
    if (valueStr.contains(".")) {
        Float statValue = NumericTools.parseFloat(valueStr);
        if (statValue != null) {
            float value = statValue.floatValue();
            value *= factor;
            ret = new FixedDecimalsInteger(value);
        }
    } else {
        Integer statValue = NumericTools.parseInteger(valueStr);
        if (statValue != null) {
            int value = statValue.intValue();
            ret = new FixedDecimalsInteger(value);
        }
    }
    return ret;
}
Also used : FixedDecimalsInteger(delta.games.lotro.utils.FixedDecimalsInteger) FixedDecimalsInteger(delta.games.lotro.utils.FixedDecimalsInteger)

Aggregations

FixedDecimalsInteger (delta.games.lotro.utils.FixedDecimalsInteger)25 BasicStatsSet (delta.games.lotro.character.stats.BasicStatsSet)11 STAT (delta.games.lotro.character.stats.STAT)11 Armour (delta.games.lotro.lore.items.Armour)7 Item (delta.games.lotro.lore.items.Item)7 EquipmentLocation (delta.games.lotro.lore.items.EquipmentLocation)6 CharacterClass (delta.games.lotro.common.CharacterClass)4 ArmourType (delta.games.lotro.lore.items.ArmourType)3 ItemQuality (delta.games.lotro.lore.items.ItemQuality)3 SlicesBasedItemStatsProvider (delta.games.lotro.lore.items.stats.SlicesBasedItemStatsProvider)3 JLabel (javax.swing.JLabel)3 StatContribution (delta.games.lotro.character.stats.contribs.StatContribution)2 DamageType (delta.games.lotro.lore.items.DamageType)2 Weapon (delta.games.lotro.lore.items.Weapon)2 WeaponType (delta.games.lotro.lore.items.WeaponType)2 ItemStatSliceData (delta.games.lotro.lore.items.stats.ItemStatSliceData)2 Color (java.awt.Color)2 GridBagConstraints (java.awt.GridBagConstraints)2 Insets (java.awt.Insets)2 HashMap (java.util.HashMap)2