Search in sources :

Example 26 with BasicStatsSet

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

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

the class ItemEditionPanelController method selectItemLevel.

private void selectItemLevel(Integer itemLevel) {
    if (itemLevel != null) {
        ScalingRule rule = Scaling.getScalingRule(_item);
        if (rule != null) {
            Item item = ItemFactory.clone(_item);
            Scaling.scaleToItemLevel(item, itemLevel.intValue());
            BasicStatsSet stats = item.getStats();
            _stats.initFromStats(stats);
            if (item instanceof Armour) {
                Armour armour = (Armour) item;
                int armourValue = armour.getArmourValue();
                _armourValue.setValue(Integer.valueOf(armourValue));
            }
            Integer requiredLevel = rule.getRequiredLevel(itemLevel.intValue());
            if (requiredLevel != null) {
                _minLevel.selectItem(requiredLevel);
            }
        }
    }
}
Also used : Item(delta.games.lotro.lore.items.Item) Armour(delta.games.lotro.lore.items.Armour) ScalingRule(delta.games.lotro.lore.items.stats.ScalingRule) BasicStatsSet(delta.games.lotro.character.stats.BasicStatsSet)

Example 28 with BasicStatsSet

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

the class TulkasItemsLoader1 method buildItem.

private Item buildItem(Integer id, HashMap<Object, Object> map) {
    String name = (String) map.get("Name");
    String slot = (String) map.get("Slot");
    EquipmentLocation loc = EquipmentLocation.getByName(slot);
    Item ret = null;
    @SuppressWarnings("unchecked") HashMap<Object, Object> statsMap = (HashMap<Object, Object>) map.get("Stats");
    if (TulkasConstants.isArmor(loc)) {
        Armour a = new Armour();
        Integer armourValue = (Integer) statsMap.get("Armour");
        if (armourValue != null) {
            a.setArmourValue(armourValue.intValue());
        }
        String armourTypeStr = (String) map.get("Type");
        ArmourType armourType = ArmourType.getArmourTypeByName(armourTypeStr);
        if (loc == EquipmentLocation.OFF_HAND) {
            String subSlot = (String) map.get("SubSlot");
            if ("Heavy".equals(subSlot))
                armourType = ArmourType.HEAVY_SHIELD;
            else if ("Light".equals(subSlot))
                armourType = ArmourType.SHIELD;
            else if ("Warden".equals(subSlot))
                armourType = ArmourType.WARDEN_SHIELD;
            else {
                // SubSlots:
                // Heavy, Warden, Light,
                _logger.warn("Unmanaged shield type [" + subSlot + "]");
            }
        } else if (loc == EquipmentLocation.BACK) {
            armourType = ArmourType.LIGHT;
        }
        if (armourType == null) {
            _logger.warn("Unknown armour type: [" + armourTypeStr + "] (name=" + name + ")");
        }
        a.setArmourType(armourType);
        ret = a;
    } else {
        String subSlot = (String) map.get("SubSlot");
        WeaponType weaponType = null;
        if ((subSlot != null) && (subSlot.length() > 0)) {
            weaponType = WeaponType.getWeaponTypeByName(subSlot);
        }
        if (weaponType != null) {
            Weapon w = new Weapon();
            w.setWeaponType(weaponType);
            @SuppressWarnings("unchecked") HashMap<Object, Object> damageInfo = (HashMap<Object, Object>) statsMap.get("Damage");
            if (damageInfo != null) {
                Integer minDMG = (Integer) damageInfo.get("MinDMG");
                if (minDMG != null) {
                    w.setMinDamage(minDMG.intValue());
                }
                Integer maxDMG = (Integer) damageInfo.get("MaxDMG");
                if (maxDMG != null) {
                    w.setMaxDamage(maxDMG.intValue());
                }
                Object dpsValue = damageInfo.get("DPS");
                if (dpsValue instanceof Float) {
                    w.setDPS(((Float) dpsValue).floatValue());
                } else if (dpsValue instanceof Integer) {
                    w.setDPS(((Integer) dpsValue).floatValue());
                }
                String typeStr = (String) damageInfo.get("TypeDMG");
                DamageType type = DamageType.getDamageTypeByName(typeStr);
                if (type == null) {
                    type = DamageType.COMMON;
                    _logger.warn("Unmanaged damage type [" + typeStr + "]");
                }
                w.setDamageType(type);
            }
            ret = w;
        }
        if (ret == null) {
            ret = new Item();
        }
    }
    // Name
    ret.setName(name);
    // Slot
    ret.setEquipmentLocation(loc);
    // Required level
    Integer requiredLevel = (Integer) map.get("Level");
    ret.setMinLevel(requiredLevel);
    // Item level
    Integer itemLevel = (Integer) map.get("ItemLevel");
    ret.setItemLevel(itemLevel);
    // Class
    String classStr = (String) map.get("Class");
    if ((classStr != null) && (classStr.length() > 0)) {
        CharacterClass cClass = CharacterClass.getByName(classStr);
        if (cClass != null) {
            ret.setRequiredClass(cClass);
        } else {
            _logger.error("Unknown class: " + classStr);
        }
    }
    // Quality
    String colorStr = (String) map.get("Color");
    ItemQuality quality = null;
    if (colorStr != null) {
        quality = ItemQuality.fromColor(colorStr);
    }
    ret.setQuality((quality != null) ? quality : ItemQuality.COMMON);
    // Bonus
    if (statsMap != null) {
        BasicStatsSet stats = ret.getStats();
        final HashMap<String, Object> bonuses = new HashMap<String, Object>();
        loadBonusItemsVersion1(bonuses, statsMap);
        bonuses.remove("Armour");
        for (int index = 0; index < TulkasConstants.BONUS_NAMES.length; index++) {
            String bonusName = TulkasConstants.BONUS_NAMES[index];
            Object bonusValue = bonuses.get(bonusName);
            if (bonusValue != null) {
                STAT stat = TulkasConstants.STATS[index];
                if (stat != null) {
                    if (stat == STAT.ALL_SKILL_INDUCTION) {
                        if (bonusValue instanceof Integer)
                            bonusValue = Integer.valueOf(-((Integer) bonusValue).intValue());
                        else if (bonusValue instanceof Float)
                            bonusValue = Float.valueOf(-((Float) bonusValue).floatValue());
                    }
                    FixedDecimalsInteger value = TulkasValuesUtils.fromObjectValue(bonusValue);
                    stats.setStat(stat, value);
                } else {
                // _logger.warn("No stat associated to bonus: " + bonusName);
                }
                bonuses.remove(bonusName);
            }
        }
        if (bonuses.size() > 0) {
            _logger.warn("Unmanaged bonuses: " + bonuses);
        }
    }
    return ret;
}
Also used : ArmourType(delta.games.lotro.lore.items.ArmourType) HashMap(java.util.HashMap) ItemQuality(delta.games.lotro.lore.items.ItemQuality) BasicStatsSet(delta.games.lotro.character.stats.BasicStatsSet) Weapon(delta.games.lotro.lore.items.Weapon) DamageType(delta.games.lotro.lore.items.DamageType) CharacterClass(delta.games.lotro.common.CharacterClass) FixedDecimalsInteger(delta.games.lotro.utils.FixedDecimalsInteger) Item(delta.games.lotro.lore.items.Item) STAT(delta.games.lotro.character.stats.STAT) Armour(delta.games.lotro.lore.items.Armour) EquipmentLocation(delta.games.lotro.lore.items.EquipmentLocation) FixedDecimalsInteger(delta.games.lotro.utils.FixedDecimalsInteger) WeaponType(delta.games.lotro.lore.items.WeaponType)

Example 29 with BasicStatsSet

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

the class RelicsIndexPageParser method parseStats.

private BasicStatsSet parseStats(String statsStr) {
    // System.out.println(statsStr);
    BasicStatsSet statsSet = new BasicStatsSet();
    String[] lines = statsStr.split("\n");
    for (String line : lines) {
        line = line.trim();
        int firstSpaceIndex = line.indexOf(" ");
        if (firstSpaceIndex != -1) {
            String valueStr = line.substring(0, firstSpaceIndex);
            String statName = line.substring(firstSpaceIndex + 1).trim();
            // System.out.println("Value: "+valueStr);
            // System.out.println("Stat: "+statName);
            Float value = parseValue(valueStr);
            STAT[] stats = parseStat(statName);
            if ((value != null) && (stats != null)) {
                for (STAT stat : stats) {
                    statsSet.addStat(stat, new FixedDecimalsInteger(value.floatValue()));
                }
            }
        } else {
            System.err.println("Cannot parse: " + line);
        }
    }
    return statsSet;
}
Also used : STAT(delta.games.lotro.character.stats.STAT) FixedDecimalsInteger(delta.games.lotro.utils.FixedDecimalsInteger) BasicStatsSet(delta.games.lotro.character.stats.BasicStatsSet)

Example 30 with BasicStatsSet

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

the class LotroPlanMordorRelicsLoader method itemToRelic.

private Relic itemToRelic(Item item) {
    String name = item.getName();
    if (name.startsWith("-"))
        name = name.substring(1);
    name = name.trim();
    Integer requiredLevel = item.getItemLevel();
    RelicType type = getRelicTypeFromName(name);
    Relic relic = new Relic(name, type, requiredLevel);
    BasicStatsSet stats = relic.getStats();
    stats.setStats(item.getStats());
    return relic;
}
Also used : Relic(delta.games.lotro.lore.items.legendary.relics.Relic) RelicType(delta.games.lotro.lore.items.legendary.relics.RelicType) 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