Search in sources :

Example 16 with STAT

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

the class TulkasItemsLoader2 method buildItem.

private Item buildItem(Integer id, HashMap<Object, Object> map) {
    /*
    [1879300219]={
      [1]={[1]="Thirteenth Exquisite Captain's Earring of Glittering Caves";[2]="";[3]="";[4]="";};
      [2]=85;[3]=136;[4]=5;[5]=1;
      [6]={[12]=435;[9]=161;[1]=140;[7]=184;[14]=435;};
      [14]=24;
      [15]={[1]=
          {[1]="Stalwart Captain's Jewelry of Helm's Deep";[2]="";[3]="";[4]="";};
           [2]={1879294461,1879295053,1879299996,1879300219};};};
    */
    @SuppressWarnings("unchecked") HashMap<Object, Object> map1 = (HashMap<Object, Object>) map.get(Integer.valueOf(1));
    // label US
    String name = (String) map1.get(Integer.valueOf(1));
    WeaponType weaponType = null;
    EquipmentLocation loc = null;
    // slot
    Integer locValue = (Integer) map.get(Integer.valueOf(5));
    // 5=armor piece: 12=boots, 11=leggings, 10=gauntlets, 8=cloak, 7=shoulders, 6=Head
    if (locValue != null) {
        switch(locValue.intValue()) {
            // Jewels
            case 1:
                loc = EquipmentLocation.EAR;
                break;
            case 2:
                loc = EquipmentLocation.NECK;
                break;
            case 3:
                loc = EquipmentLocation.POCKET;
                break;
            case 4:
                loc = EquipmentLocation.WRIST;
                break;
            case 5:
                loc = EquipmentLocation.FINGER;
                break;
            // Armours
            case 6:
                loc = EquipmentLocation.HEAD;
                break;
            case 7:
                loc = EquipmentLocation.SHOULDER;
                break;
            case 8:
                loc = EquipmentLocation.BACK;
                break;
            case 9:
                loc = EquipmentLocation.CHEST;
                break;
            case 10:
                loc = EquipmentLocation.HAND;
                break;
            case 11:
                loc = EquipmentLocation.LEGS;
                break;
            case 12:
                loc = EquipmentLocation.FEET;
                break;
            // Weapons/tools/class items
            case 13:
                loc = EquipmentLocation.MAIN_HAND;
                break;
            case 14:
                loc = EquipmentLocation.OFF_HAND;
                break;
            case 15:
                loc = EquipmentLocation.RANGED_ITEM;
                break;
            // Rune-stone
            case 16:
                {
                    loc = EquipmentLocation.MAIN_HAND;
                    weaponType = WeaponType.RUNE_STONE;
                }
                break;
            default:
                {
                    _logger.warn("Unmanaged loc value: " + locValue);
                }
        }
    }
    Item ret = null;
    if (TulkasConstants.isArmor(loc)) {
        Armour a = new Armour();
        // 8=armour value
        Integer armourValue = (Integer) map.get(Integer.valueOf(8));
        if (armourValue != null) {
            a.setArmourValue(armourValue.intValue());
        } else {
            _logger.warn("No armour value!");
        }
        // 7=armor type: 1=light, 2=medium, 3=heavy
        Integer armourTypeInt = (Integer) map.get(Integer.valueOf(7));
        ArmourType armourType = null;
        if (armourTypeInt != null) {
            switch(armourTypeInt.intValue()) {
                case 1:
                    armourType = ArmourType.LIGHT;
                    break;
                case 2:
                    armourType = ArmourType.MEDIUM;
                    break;
                case 3:
                    armourType = ArmourType.HEAVY;
                    break;
                default:
                    {
                        _logger.warn("Unmanaged armour type : " + armourTypeInt);
                    }
            }
        }
        armourTypeInt = (Integer) map.get(Integer.valueOf(9));
        if (armourTypeInt != null) {
            switch(armourTypeInt.intValue()) {
                case 14:
                    armourType = ArmourType.SHIELD;
                    break;
                case 15:
                    armourType = ArmourType.HEAVY_SHIELD;
                    break;
                case 16:
                    armourType = ArmourType.WARDEN_SHIELD;
                    break;
                default:
                    {
                        _logger.warn("Unmanaged armour type : " + armourTypeInt);
                    }
            }
        }
        if (loc == EquipmentLocation.BACK) {
            armourType = ArmourType.LIGHT;
        }
        if (armourType == null) {
            _logger.warn("Unknown armour type: [" + armourTypeInt + "] (name=" + name + ")");
        }
        a.setArmourType(armourType);
        ret = a;
    } else {
        Integer weaponTypeInt = (Integer) map.get(Integer.valueOf(9));
        if (weaponTypeInt != null) {
            switch(weaponTypeInt.intValue()) {
                case 1:
                    weaponType = WeaponType.ONE_HANDED_AXE;
                    loc = EquipmentLocation.MAIN_HAND;
                    break;
                case 2:
                    weaponType = WeaponType.TWO_HANDED_AXE;
                    loc = EquipmentLocation.MAIN_HAND;
                    break;
                case 3:
                    weaponType = WeaponType.ONE_HANDED_CLUB;
                    loc = EquipmentLocation.MAIN_HAND;
                    break;
                case 4:
                    weaponType = WeaponType.TWO_HANDED_CLUB;
                    loc = EquipmentLocation.MAIN_HAND;
                    break;
                case 5:
                    weaponType = WeaponType.DAGGER;
                    loc = EquipmentLocation.MAIN_HAND;
                    break;
                case 6:
                    weaponType = WeaponType.HALBERD;
                    loc = EquipmentLocation.MAIN_HAND;
                    break;
                case 7:
                    weaponType = WeaponType.ONE_HANDED_HAMMER;
                    loc = EquipmentLocation.MAIN_HAND;
                    break;
                case 8:
                    weaponType = WeaponType.TWO_HANDED_HAMMER;
                    loc = EquipmentLocation.MAIN_HAND;
                    break;
                case 9:
                    weaponType = WeaponType.ONE_HANDED_MACE;
                    loc = EquipmentLocation.MAIN_HAND;
                    break;
                case 10:
                    weaponType = WeaponType.SPEAR;
                    loc = EquipmentLocation.MAIN_HAND;
                    break;
                case 11:
                    weaponType = WeaponType.STAFF;
                    loc = EquipmentLocation.MAIN_HAND;
                    break;
                case 12:
                    weaponType = WeaponType.ONE_HANDED_SWORD;
                    loc = EquipmentLocation.MAIN_HAND;
                    break;
                case 13:
                    weaponType = WeaponType.TWO_HANDED_SWORD;
                    loc = EquipmentLocation.MAIN_HAND;
                    break;
                case 17:
                    weaponType = WeaponType.BOW;
                    loc = EquipmentLocation.RANGED_ITEM;
                    break;
                case 18:
                    weaponType = WeaponType.CROSSBOW;
                    loc = EquipmentLocation.RANGED_ITEM;
                    break;
                case 19:
                    weaponType = WeaponType.JAVELIN;
                    loc = EquipmentLocation.RANGED_ITEM;
                    break;
                // Instrument
                case 20:
                    weaponType = null;
                    loc = EquipmentLocation.RANGED_ITEM;
                    break;
                // Chisel
                case 21:
                    weaponType = null;
                    loc = EquipmentLocation.RANGED_ITEM;
                    break;
                // Riffler
                case 22:
                    weaponType = null;
                    loc = EquipmentLocation.RANGED_ITEM;
                    break;
                default:
                    _logger.warn("ID=" + id + ": unmanaged weapon type: " + weaponTypeInt.intValue());
            }
        }
        if (weaponType != null) {
            // weapon:
            Weapon w = new Weapon();
            w.setWeaponType(weaponType);
            // [10]=Min damage;
            Integer minDMG = (Integer) map.get(Integer.valueOf(10));
            if (minDMG != null) {
                w.setMinDamage(minDMG.intValue());
            }
            // [11]=Max damage;
            Integer maxDMG = (Integer) map.get(Integer.valueOf(11));
            if (maxDMG != null) {
                w.setMaxDamage(maxDMG.intValue());
            }
            // [12]=DPS;
            Object dpsValue = map.get(Integer.valueOf(12));
            if (dpsValue instanceof Float) {
                w.setDPS(((Float) dpsValue).floatValue());
            } else if (dpsValue instanceof Integer) {
                w.setDPS(((Integer) dpsValue).floatValue());
            }
            // Damage type
            DamageType type = null;
            Integer damageTypeInt = (Integer) map.get(Integer.valueOf(13));
            if (damageTypeInt != null) {
                switch(damageTypeInt.intValue()) {
                    case 1:
                        type = DamageType.COMMON;
                        break;
                    case 2:
                        type = DamageType.BELERIAND;
                        break;
                    case 3:
                        type = DamageType.WESTERNESSE;
                        break;
                    case 4:
                        type = DamageType.ANCIENT_DWARF;
                        break;
                    case 5:
                        type = DamageType.FIRE;
                        break;
                    case 6:
                        type = DamageType.LIGHT;
                        break;
                    case 7:
                        type = DamageType.LIGHTNING;
                        break;
                    case 8:
                        type = DamageType.FROST;
                        break;
                }
            }
            if (type == null) {
                type = DamageType.COMMON;
                _logger.warn("Unmanaged damage type [" + damageTypeInt + "]");
            }
            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(Integer.valueOf(2));
    if ((requiredLevel != null) && (requiredLevel.intValue() > 0)) {
        ret.setMinLevel(requiredLevel);
    }
    // Item level
    Integer itemLevel = (Integer) map.get(Integer.valueOf(3));
    if ((itemLevel != null) && (itemLevel.intValue() > 0)) {
        ret.setItemLevel(itemLevel);
    }
    // Class
    CharacterClass cClass = null;
    Integer classInt = (Integer) map.get(Integer.valueOf(14));
    if (classInt != null) {
        switch(classInt.intValue()) {
            case 40:
                cClass = CharacterClass.BURGLAR;
                break;
            case 24:
                cClass = CharacterClass.CAPTAIN;
                break;
            case 172:
                cClass = CharacterClass.CHAMPION;
                break;
            case 23:
                cClass = CharacterClass.GUARDIAN;
                break;
            case 162:
                cClass = CharacterClass.HUNTER;
                break;
            case 185:
                cClass = CharacterClass.LORE_MASTER;
                break;
            case 31:
                cClass = CharacterClass.MINSTREL;
                break;
            case 193:
                cClass = CharacterClass.RUNE_KEEPER;
                break;
            case 194:
                cClass = CharacterClass.WARDEN;
                break;
            default:
                {
                    _logger.warn("Unmanaged class [" + classInt + "]");
                }
        }
    }
    if (cClass != null) {
        ret.setRequiredClass(cClass);
    }
    // Quality
    ItemQuality quality = ItemQuality.COMMON;
    Integer qualityInt = (Integer) map.get(Integer.valueOf(4));
    if (qualityInt != null) {
        switch(qualityInt.intValue()) {
            case 1:
                quality = ItemQuality.COMMON;
                break;
            case 2:
                quality = ItemQuality.UNCOMMON;
                break;
            case 3:
                quality = ItemQuality.RARE;
                break;
            case 4:
                quality = ItemQuality.INCOMPARABLE;
                break;
            case 5:
                quality = ItemQuality.LEGENDARY;
                break;
            default:
                {
                    _logger.warn("ID: " + id + ": unmanaged quality [" + qualityInt + "]");
                }
        }
    } else {
        _logger.warn("ID: " + id + ": no quality!");
    }
    ret.setQuality(quality);
    // Bonus
    @SuppressWarnings("unchecked") HashMap<Integer, Object> bonuses = (HashMap<Integer, Object>) map.get(Integer.valueOf(6));
    if (bonuses != null) {
        BasicStatsSet stats = ret.getStats();
        List<Integer> keys = new ArrayList<Integer>(bonuses.keySet());
        Collections.sort(keys);
        for (Integer key : keys) {
            int index = key.intValue();
            if ((index >= 0) && (index < TulkasConstants.BONUS_NAMES.length)) {
                String bonusName = TulkasConstants.BONUS_NAMES[index];
                Object bonusValue = bonuses.get(key);
                STAT stat = TulkasConstants.STATS[index];
                if (stat != null) {
                    FixedDecimalsInteger value = TulkasValuesUtils.fromObjectValue(bonusValue);
                    stats.setStat(stat, value);
                } else {
                    _logger.warn("No stat associated to bonus: " + bonusName);
                /*
            BonusType type=BonusType.getByName(bonusName);
            Bonus bonus=new Bonus(type,BONUS_OCCURRENCE.ALWAYS);
            Object value=type.buildValue(bonusValue);
            bonus.setValue(value);
            bonusMgr.add(bonus);
            ret.getBonus().add(bonusName+" : "+bonuses.get(key));
            */
                }
                bonuses.remove(key);
            } else {
                _logger.warn("Unmanaged index: " + index);
            }
        }
        if (bonuses.size() > 0) {
            _logger.warn("Unmanaged bonuses: " + bonuses);
        }
    }
    return ret;
}
Also used : ArmourType(delta.games.lotro.lore.items.ArmourType) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) 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 17 with STAT

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

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

the class DetailedCharacterStatsPanelController method buildMitigationsPanel.

private JPanel buildMitigationsPanel() {
    JPanel panel = GuiFactory.buildBackgroundPanel(new GridBagLayout());
    String[] labelsV = new String[] { "Crit.Def (melee)", "Crit.Def (ranged)", "Crit.Def (tactical)", "Physical", "Orc-craft/Fell-wrought", "Tactical", "Fire", "Lightning", "Frost", "Acid", "Shadow" };
    STAT[] stats = { STAT.CRITICAL_DEFENCE, STAT.CRITICAL_DEFENCE, STAT.CRITICAL_DEFENCE, STAT.PHYSICAL_MITIGATION, STAT.OCFW_MITIGATION, STAT.TACTICAL_MITIGATION, null, null, null, null, null };
    addHeaders(panel, 0, 1, labelsV, stats, false, 1);
    int x = 1;
    String[] labelsH = new String[] { "Rating", "Mitigation %" };
    addHeaders(panel, x, 0, labelsH, null, true, 2);
    int y = 1;
    // Crit/dev defence
    addStatWidgets(panel, STAT.CRITICAL_DEFENCE, x, y, false);
    addStatWidgets(panel, STAT.MELEE_CRITICAL_DEFENCE, x + 2, y, false);
    y++;
    addStatWidgets(panel, STAT.RANGED_CRITICAL_DEFENCE, x + 2, y, false);
    y++;
    addStatWidgets(panel, STAT.TACTICAL_CRITICAL_DEFENCE, x + 2, y, false);
    y++;
    // Physical Mitigation
    addStatWidgets(panel, STAT.PHYSICAL_MITIGATION, x, y, false);
    addStatWidgets(panel, STAT.PHYSICAL_MITIGATION_PERCENTAGE, x + 2, y, false);
    y++;
    // Orc-craft/Fell-wrought Mitigation
    addStatWidgets(panel, STAT.OCFW_MITIGATION, x, y, false);
    addStatWidgets(panel, STAT.OCFW_MITIGATION_PERCENTAGE, x + 2, y, false);
    y++;
    // Tactical Mitigation
    addStatWidgets(panel, STAT.TACTICAL_MITIGATION, x, y, false);
    addStatWidgets(panel, STAT.TACTICAL_MITIGATION_PERCENTAGE, x + 2, y, false);
    y++;
    // Fire Mitigation
    addStatWidgets(panel, STAT.FIRE_MITIGATION_PERCENTAGE, x + 2, y, false);
    y++;
    // Lightning Mitigation
    addStatWidgets(panel, STAT.LIGHTNING_MITIGATION_PERCENTAGE, x + 2, y, false);
    y++;
    // Frost Mitigation
    addStatWidgets(panel, STAT.FROST_MITIGATION_PERCENTAGE, x + 2, y, false);
    y++;
    // Acid Mitigation
    addStatWidgets(panel, STAT.ACID_MITIGATION_PERCENTAGE, x + 2, y, false);
    y++;
    // Shadow Mitigation
    addStatWidgets(panel, STAT.SHADOW_MITIGATION_PERCENTAGE, x + 2, y, false);
    y++;
    TitledBorder border = GuiFactory.buildTitledBorder("Mitigations");
    panel.setBorder(border);
    return panel;
}
Also used : JPanel(javax.swing.JPanel) STAT(delta.games.lotro.character.stats.STAT) GridBagLayout(java.awt.GridBagLayout) TitledBorder(javax.swing.border.TitledBorder)

Example 19 with STAT

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

the class DetailedCharacterStatsPanelController method init.

private void init() {
    for (String key : StatLabels.getTranslatedStats()) {
        STAT stat = STAT.getByName(key);
        addStat(stat);
    }
}
Also used : STAT(delta.games.lotro.character.stats.STAT)

Example 20 with STAT

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

the class DetailedCharacterStatsPanelController method buildHealingPanel.

private JPanel buildHealingPanel() {
    JPanel panel = GuiFactory.buildBackgroundPanel(new GridBagLayout());
    String[] labelsV = { "Incoming", "Outgoing" };
    STAT[] stats = { STAT.INCOMING_HEALING, STAT.OUTGOING_HEALING };
    addHeaders(panel, 0, 1, labelsV, stats, false, 1);
    int x = 1;
    String[] labelsH = new String[] { "Rating", "Healing %" };
    addHeaders(panel, x, 0, labelsH, null, true, 2);
    int y = 1;
    // Incoming Healing
    addStatWidgets(panel, STAT.INCOMING_HEALING, x, y, false);
    addStatWidgets(panel, STAT.INCOMING_HEALING_PERCENTAGE, x + 2, y, false);
    y++;
    addStatWidgets(panel, STAT.OUTGOING_HEALING, x, y, false);
    addStatWidgets(panel, STAT.OUTGOING_HEALING_PERCENTAGE, x + 2, y, false);
    TitledBorder border = GuiFactory.buildTitledBorder("Healing");
    panel.setBorder(border);
    return panel;
}
Also used : JPanel(javax.swing.JPanel) STAT(delta.games.lotro.character.stats.STAT) GridBagLayout(java.awt.GridBagLayout) TitledBorder(javax.swing.border.TitledBorder)

Aggregations

STAT (delta.games.lotro.character.stats.STAT)30 BasicStatsSet (delta.games.lotro.character.stats.BasicStatsSet)12 FixedDecimalsInteger (delta.games.lotro.utils.FixedDecimalsInteger)11 JPanel (javax.swing.JPanel)7 GridBagLayout (java.awt.GridBagLayout)6 TitledBorder (javax.swing.border.TitledBorder)5 GridBagConstraints (java.awt.GridBagConstraints)4 Insets (java.awt.Insets)4 CharacterClass (delta.games.lotro.common.CharacterClass)3 Armour (delta.games.lotro.lore.items.Armour)3 ArmourType (delta.games.lotro.lore.items.ArmourType)3 EquipmentLocation (delta.games.lotro.lore.items.EquipmentLocation)3 ItemQuality (delta.games.lotro.lore.items.ItemQuality)3 ItemStatSliceData (delta.games.lotro.lore.items.stats.ItemStatSliceData)3 JLabel (javax.swing.JLabel)3 ContribsByStat (delta.games.lotro.character.stats.contribs.ContribsByStat)2 TomesSet (delta.games.lotro.character.stats.tomes.TomesSet)2 DamageType (delta.games.lotro.lore.items.DamageType)2 Item (delta.games.lotro.lore.items.Item)2 Weapon (delta.games.lotro.lore.items.Weapon)2