Search in sources :

Example 6 with BasicStatsSet

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

the class StatsEditionPanelController method getStats.

/**
 * Get the current stats.
 * @return the current stats.
 */
public BasicStatsSet getStats() {
    BasicStatsSet stats = new BasicStatsSet();
    for (SingleStatController ctrl : _statControllers) {
        ComboBoxController<STAT> comboCtrl = ctrl.getStatComboController();
        STAT stat = comboCtrl.getSelectedItem();
        if (stat != null) {
            String valueStr = ctrl.getValue().getText();
            Float value = NumericTools.parseFloat(valueStr, false);
            if (value != null) {
                stats.setStat(stat, value.floatValue());
            }
        }
    }
    return stats;
}
Also used : STAT(delta.games.lotro.character.stats.STAT) BasicStatsSet(delta.games.lotro.character.stats.BasicStatsSet)

Example 7 with BasicStatsSet

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

the class EssencesSummaryPanelController method updateStatsPanel.

private void updateStatsPanel() {
    // Raw
    BasicStatsSet raw = _summary.getStats();
    updateStatsPanel(_rawStatsPanel, raw);
    // Cumulated
    DerivatedStatsContributionsMgr derivedStatsMgr = new DerivatedStatsContributionsMgr();
    CharacterClass characterClass = _toon.getCharacterClass();
    BasicStatsSet derivated = derivedStatsMgr.getContribution(characterClass, raw);
    BasicStatsSet cumulated = new BasicStatsSet();
    cumulated.addStats(raw);
    cumulated.addStats(derivated);
    updateStatsPanel(_cumulatedStatsPanel, cumulated);
}
Also used : DerivatedStatsContributionsMgr(delta.games.lotro.character.stats.base.DerivatedStatsContributionsMgr) BasicStatsSet(delta.games.lotro.character.stats.BasicStatsSet) CharacterClass(delta.games.lotro.common.CharacterClass)

Example 8 with BasicStatsSet

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

the class EssencesSummaryPanelController method updateStatsPanel.

private void updateStatsPanel(JPanel panel, BasicStatsSet stats) {
    panel.removeAll();
    int rowIndex = 0;
    GridBagConstraints strutConstraints = new GridBagConstraints(0, rowIndex, 3, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 0, 0);
    panel.add(Box.createHorizontalStrut(100), strutConstraints);
    rowIndex++;
    int statsCount = stats.getStatsCount();
    if (statsCount > 0) {
        // Grab toon stats
        BasicStatsSet toonStats = _toon.getStats();
        // Build display
        for (STAT stat : STAT.values()) {
            FixedDecimalsInteger value = stats.getStat(stat);
            if (value != null) {
                // Value label
                JLabel valueLabel = GuiFactory.buildLabel(value.toString());
                GridBagConstraints c = new GridBagConstraints(0, rowIndex, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 0, 0);
                panel.add(valueLabel, c);
                // Name label
                String name = StatLabels.getStatLabel(stat);
                JLabel statLabel = GuiFactory.buildLabel(name);
                c = new GridBagConstraints(1, rowIndex, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 0), 0, 0);
                panel.add(statLabel, c);
                // Percentage
                FixedDecimalsInteger toonStat = toonStats.getStat(stat);
                String percentageStr = "";
                if (toonStat != null) {
                    float percentage = 100 * (value.floatValue() / toonStat.floatValue());
                    percentageStr = String.format("%.1f%%", Float.valueOf(percentage));
                }
                JLabel percentageLabel = GuiFactory.buildLabel(percentageStr);
                c = new GridBagConstraints(2, rowIndex, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0);
                panel.add(percentageLabel, c);
                rowIndex++;
            }
        }
    }
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) STAT(delta.games.lotro.character.stats.STAT) Insets(java.awt.Insets) FixedDecimalsInteger(delta.games.lotro.utils.FixedDecimalsInteger) JLabel(javax.swing.JLabel) BasicStatsSet(delta.games.lotro.character.stats.BasicStatsSet)

Example 9 with BasicStatsSet

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

the class BuffIconController method buildToolTip.

private String buildToolTip() {
    Buff buff = _buff.getBuff();
    StringBuilder sb = new StringBuilder();
    sb.append(buff.getLabel()).append(EndOfLine.NATIVE_EOL);
    BasicStatsSet stats = _buff.getStats(_toon);
    if (stats != null) {
        for (STAT stat : stats.getStats()) {
            String name = stat.getName();
            String value = stats.getStat(stat).toString();
            sb.append(name).append(": ").append(value).append(EndOfLine.NATIVE_EOL);
        }
    }
    String text = sb.toString().trim();
    String html = "<html>" + text.replace(EndOfLine.NATIVE_EOL, "<br>") + "</html>";
    return html;
}
Also used : STAT(delta.games.lotro.character.stats.STAT) Buff(delta.games.lotro.character.stats.buffs.Buff) BasicStatsSet(delta.games.lotro.character.stats.BasicStatsSet)

Example 10 with BasicStatsSet

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

the class RelicsIndexPageParser method handleTableRow.

private Relic handleTableRow(Element tr, Integer level, RelicType defaultType) {
    Relic relic = null;
    List<Element> tds = JerichoHtmlUtils.findElementsByTagName(tr, HTMLElementName.TD);
    if (tds.size() == 2) {
        // Icon & name
        Element iconAndNameElement = tds.get(0);
        List<Element> as = JerichoHtmlUtils.findElementsByTagName(iconAndNameElement, HTMLElementName.A);
        Element iconElement = as.get(0);
        String iconPath = extractIcon(iconElement);
        // Name
        Element nameElement = as.get(1);
        String name = JerichoHtmlUtils.getTagContents(nameElement, HTMLElementName.SPAN);
        if (name == null) {
            name = JerichoHtmlUtils.getTagContents(nameElement, HTMLElementName.A);
        }
        // Type
        RelicType type = getTypeFromName(name);
        relic = new Relic(name, type, level);
        relic.setIconFilename(iconPath);
        // Stats
        Element statsElement = tds.get(1);
        String statsStr = JerichoHtmlUtils.getTextFromTag(statsElement);
        statsStr = statsStr.replaceAll(",", "\n");
        BasicStatsSet stats = parseStats(statsStr);
        relic.getStats().setStats(stats);
    } else if (tds.size() == 3) {
        // Icon
        Element iconElement = tds.get(0);
        String iconPath = extractIcon(iconElement);
        // Name
        Element nameElement = tds.get(1);
        String name = JerichoHtmlUtils.getTagContents(nameElement, HTMLElementName.A);
        // Type
        RelicType type = getTypeFromName(name);
        relic = new Relic(name, type, level);
        relic.setIconFilename(iconPath);
        // Stats
        Element statsElement = tds.get(2);
        String statsStr = JerichoHtmlUtils.getTextFromTag(statsElement);
        BasicStatsSet stats = parseStats(statsStr);
        relic.getStats().setStats(stats);
    } else if (// Retired relics
    tds.size() == 4) {
        // Icon
        Element iconElement = tds.get(0);
        String iconPath = extractIcon(iconElement);
        // Name
        Element nameElement = tds.get(1);
        String name = JerichoHtmlUtils.getTagContents(nameElement, HTMLElementName.A);
        if (name == null) {
            name = JerichoHtmlUtils.getTagContents(nameElement, HTMLElementName.TD);
        }
        if (name.startsWith("Relic:")) {
            name = name.substring(6).trim();
        }
        // Tier
        /*
      Element tierElement=tds.get(2);
      String tierStr=JerichoHtmlUtils.getTextFromTag(tierElement);
      Integer tier=null;
      if (tierStr.length()>0)
      {
        tier=NumericTools.parseInteger(tierStr.trim());
      }
      else
      {
        tier=null;
      }
      */
        relic = new Relic(name, defaultType, level);
        relic.setIconFilename(iconPath);
        // Stats
        Element statsElements = tds.get(3);
        String statsStr = JerichoHtmlUtils.getTextFromTag(statsElements);
        statsStr = statsStr.replace(", ", "\n");
        BasicStatsSet stats = parseStats(statsStr);
        relic.getStats().setStats(stats);
    } else if (// Crafted relics
    tds.size() == 5) {
        // Icon
        Element iconElement = tds.get(0);
        String iconPath = extractIcon(iconElement);
        // Name
        Element nameElement = tds.get(1);
        String name = JerichoHtmlUtils.getTagContents(nameElement, HTMLElementName.A);
        // Type
        RelicType type = RelicType.CRAFTED_RELIC;
        // Level
        Element levelElement = tds.get(2);
        String levelStr = JerichoHtmlUtils.getTextFromTag(levelElement);
        if (levelStr.length() > 0) {
            level = NumericTools.parseInteger(levelStr.trim());
        } else {
            level = null;
        }
        relic = new Relic(name, type, level);
        relic.setIconFilename(iconPath);
        // Stats
        Element statsElements = tds.get(3);
        String statsStr = JerichoHtmlUtils.getTextFromTag(statsElements);
        BasicStatsSet stats = parseStats(statsStr);
        relic.getStats().setStats(stats);
    }
    // System.out.println(relic);
    return relic;
}
Also used : Relic(delta.games.lotro.lore.items.legendary.relics.Relic) RelicType(delta.games.lotro.lore.items.legendary.relics.RelicType) Element(net.htmlparser.jericho.Element) 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