Search in sources :

Example 11 with ItemQuality

use of delta.games.lotro.lore.items.ItemQuality 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 12 with ItemQuality

use of delta.games.lotro.lore.items.ItemQuality in project lotro-tools by dmorcellet.

the class ScalableStatChartController method createDataset.

private XYSeriesCollection createDataset() {
    ItemQuality[] qualities = { ItemQuality.UNCOMMON, ItemQuality.RARE, ItemQuality.INCOMPARABLE, ItemQuality.LEGENDARY };
    XYSeriesCollection data = new XYSeriesCollection();
    for (ItemQuality quality : qualities) {
        addSeries(data, quality);
    }
    return data;
}
Also used : ItemQuality(delta.games.lotro.lore.items.ItemQuality) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection)

Example 13 with ItemQuality

use of delta.games.lotro.lore.items.ItemQuality in project lotro-tools by dmorcellet.

the class ScalableItemsFinder method generateItems.

private Map<String, Item> generateItems() {
    Map<String, Item> ret = new HashMap<String, Item>();
    for (int i = 0; i < PREFIXES.length; i++) {
        ItemQuality quality = PREFIX_QUALITY[i];
        String prefix = PREFIXES[i];
        for (String[] items : ITEMS) {
            for (int j = 0; j < items.length; j++) {
                String itemName = items[j];
                EquipmentLocation location = null;
                ArmourType armourType = null;
                WeaponType weaponType = null;
                if (items == JEWELS) {
                    location = JEWEL_LOCATIONS[j];
                } else if (items == ARMOURS) {
                    location = ARMOUR_LOCATIONS[j];
                    armourType = ARMOUR_TYPES[j];
                } else if (items == SHIELDS) {
                    location = EquipmentLocation.OFF_HAND;
                    armourType = SHIELD_TYPES[j];
                } else if (items == WEAPONS) {
                    weaponType = WEAPON_TYPES[j];
                    location = weaponType.isRanged() ? EquipmentLocation.RANGED_ITEM : EquipmentLocation.MAIN_HAND;
                }
                for (String adjective : ADJECTIVES) {
                    for (String suffix : SUFFIXES) {
                        String name = generateName(prefix, adjective, itemName, suffix);
                        Item item = null;
                        if (armourType != null) {
                            Armour armour = new Armour();
                            armour.setArmourType(armourType);
                            item = armour;
                        } else if (weaponType != null) {
                            Weapon weapon = new Weapon();
                            weapon.setWeaponType(weaponType);
                            item = weapon;
                        } else {
                            item = new Item();
                        }
                        item.setName(name);
                        item.setQuality(quality);
                        item.setEquipmentLocation(location);
                        ret.put(name, item);
                    }
                }
            }
        }
    }
    return ret;
}
Also used : Item(delta.games.lotro.lore.items.Item) ArmourType(delta.games.lotro.lore.items.ArmourType) Armour(delta.games.lotro.lore.items.Armour) HashMap(java.util.HashMap) EquipmentLocation(delta.games.lotro.lore.items.EquipmentLocation) WeaponType(delta.games.lotro.lore.items.WeaponType) ItemQuality(delta.games.lotro.lore.items.ItemQuality) Weapon(delta.games.lotro.lore.items.Weapon)

Aggregations

ItemQuality (delta.games.lotro.lore.items.ItemQuality)13 ArmourType (delta.games.lotro.lore.items.ArmourType)7 EquipmentLocation (delta.games.lotro.lore.items.EquipmentLocation)7 WeaponType (delta.games.lotro.lore.items.WeaponType)7 Armour (delta.games.lotro.lore.items.Armour)5 Item (delta.games.lotro.lore.items.Item)5 CharacterClass (delta.games.lotro.common.CharacterClass)4 Weapon (delta.games.lotro.lore.items.Weapon)4 BasicStatsSet (delta.games.lotro.character.stats.BasicStatsSet)3 STAT (delta.games.lotro.character.stats.STAT)3 FixedDecimalsInteger (delta.games.lotro.utils.FixedDecimalsInteger)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 DamageType (delta.games.lotro.lore.items.DamageType)2 ComboBoxController (delta.common.ui.swing.combobox.ComboBoxController)1 ItemSelectionListener (delta.common.ui.swing.combobox.ItemSelectionListener)1 DynamicTextEditionController (delta.common.ui.swing.text.DynamicTextEditionController)1 TextListener (delta.common.ui.swing.text.TextListener)1 IntegerHolder (delta.common.utils.misc.IntegerHolder)1 ItemSturdiness (delta.games.lotro.lore.items.ItemSturdiness)1