Search in sources :

Example 6 with Weapon

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

the class MergeWithTulkasNew method mergeItems.

private Item mergeItems(Item source, Item tulkas) {
    int id = source.getIdentifier();
    Item result = source;
    // Check types
    if (source.getClass() != tulkas.getClass()) {
        // System.out.println("ID: " + id+": type conflict: tulkas=" + tulkas.getClass() + ", source=" + source.getClass());
        if (source.getClass() == Item.class) {
            if (tulkas instanceof Weapon) {
                Weapon weapon = new Weapon();
                Weapon tulkasWeapon = (Weapon) tulkas;
                result = weapon;
                weapon.copyFrom(source);
                weapon.setMinDamage(tulkasWeapon.getMinDamage());
                weapon.setMaxDamage(tulkasWeapon.getMaxDamage());
                weapon.setDPS(tulkasWeapon.getDPS());
                weapon.setDamageType(tulkasWeapon.getDamageType());
                weapon.setWeaponType(tulkasWeapon.getWeaponType());
            } else if (tulkas instanceof Armour) {
                Armour armour = new Armour();
                Armour tulkasArmour = (Armour) tulkas;
                result = armour;
                armour.copyFrom(source);
                armour.setArmourValue(tulkasArmour.getArmourValue());
                armour.setArmourType(tulkasArmour.getArmourType());
            }
        } else {
            System.out.println("Unmanaged cast");
        }
    } else {
        result = source;
    }
    String sourceName = source.getName();
    // Name
    {
        String tulkasName = tulkas.getName();
        if (!tulkasName.equals(sourceName)) {
            // System.out.println("ID: " + id+": name conflict: tulkas=" + tulkasName + ", source=" + sourceName);
            if (tulkasName != null) {
                result.setProperty(ItemPropertyNames.OLD_TULKAS_NAME, tulkasName);
            }
        }
    }
    // Required level
    {
        Integer tulkasMinLevel = tulkas.getMinLevel();
        Integer sourceMinLevel = result.getMinLevel();
        boolean conflict = false;
        if (tulkasMinLevel != null) {
            if (sourceMinLevel == null) {
                // conflict=true;
                result.setMinLevel(tulkasMinLevel);
            } else {
                if (tulkasMinLevel.intValue() != sourceMinLevel.intValue()) {
                    conflict = true;
                    result.setMinLevel(tulkasMinLevel);
                }
            }
        } else {
            if (sourceMinLevel != null) {
                conflict = true;
                result.setMinLevel(sourceMinLevel);
            }
        }
        if (conflict) {
        // System.out.println("ID: " + id+": min level conflict: tulkas=" + tulkasMinLevel + ", source=" + sourceMinLevel);
        }
    }
    // Item level
    {
        result.setItemLevel(tulkas.getItemLevel());
    }
    // Required class
    {
        CharacterClass tulkasClass = tulkas.getRequiredClass();
        CharacterClass sourceClass = source.getRequiredClass();
        if (tulkasClass != sourceClass) {
            if ((tulkasClass != null) && (sourceClass == null)) {
                result.setRequiredClass(tulkasClass);
            } else {
                System.out.println("ID: " + id + ": required class conflict: tulkas=" + tulkasClass + ", source=" + sourceClass);
            }
        }
    }
    // Quality
    {
        ItemQuality tulkasQuality = tulkas.getQuality();
        ItemQuality sourceQuality = source.getQuality();
        if (tulkasQuality != sourceQuality) {
            // Use source quality since it comes from tulkas index (17.1), which is more recent that tulkas new (13.1)
            result.setQuality(sourceQuality);
        // System.out.println("ID: " + id+": quality conflict: tulkas=" + tulkasQuality + ", source=" + sourceQuality);
        }
    }
    // Bonus
    if (result != source) {
        result.getBonus().clear();
        result.getBonus().addAll(source.getBonus());
    }
    // Stats
    result.getStats().setStats(tulkas.getStats());
    // Slot
    {
        EquipmentLocation tulkasSlot = tulkas.getEquipmentLocation();
        EquipmentLocation sourceSlot = source.getEquipmentLocation();
        if (tulkasSlot != sourceSlot) {
            // Use tulkas slot since it is not set in source
            result.setEquipmentLocation(tulkasSlot);
        // System.out.println("ID: " + id+": slot conflict: tulkas=" + tulkasSlot + ", source=" + sourceSlot);
        }
    }
    return result;
}
Also used : Item(delta.games.lotro.lore.items.Item) Armour(delta.games.lotro.lore.items.Armour) EquipmentLocation(delta.games.lotro.lore.items.EquipmentLocation) ItemQuality(delta.games.lotro.lore.items.ItemQuality) Weapon(delta.games.lotro.lore.items.Weapon) CharacterClass(delta.games.lotro.common.CharacterClass)

Example 7 with Weapon

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

the class ItemPageParser method parseItemDescription.

private void parseItemDescription(Element itemTooltip) {
    // Name
    String name = findName(itemTooltip);
    // Find out type of item
    Armour armour = null;
    // Armor?
    // <div class="itemarmor">1130 Armour Value</div>
    String armorStr = getTagContent(itemTooltip, "itemarmor");
    Weapon weapon = null;
    // Weapon?
    // <div class="itemdps">126.5 DPS</div>
    String dpsStr = getTagContent(itemTooltip, "itemdps");
    if (armorStr != null) {
        // Armour!
        armour = new Armour();
        _item = armour;
        Integer armourValue = getArmour(armorStr);
        if (armourValue != null) {
            armour.setArmourValue(armourValue.intValue());
        }
        String armourTypeStr = getTagContent(itemTooltip, "itemtype");
        ArmourType armourType = ArmourType.getArmourTypeByName(armourTypeStr);
        if (armourType == null) {
            // Assume light armour...
            armourType = ArmourType.LIGHT;
            _logger.warn("Unknown armour type: " + armourTypeStr + " (name=" + name + ")");
        }
        armour.setArmourType(armourType);
    } else if (dpsStr != null) {
        // Weapon!
        weapon = new Weapon();
        _item = weapon;
        Float dpsValue = getDPS(dpsStr);
        if (dpsValue != null) {
            weapon.setDPS(dpsValue.floatValue());
        }
        String weaponTypeStr = getTagContent(itemTooltip, "itemtype");
        if (weaponTypeStr != null) {
            WeaponType type = WeaponType.getWeaponTypeByName(weaponTypeStr);
            if (type != null) {
                weapon.setWeaponType(type);
            } else {
                _logger.warn("Unknown weapon type: " + weaponTypeStr + " (name=" + name + ")");
            }
        }
    } else {
        _item = new Item();
    }
    // Icon
    // <div class="itemicon"><img src="http://content.turbine.com/sites/lorebook.lotro.com/images/icons/item/tool/eq_c_craft_tool_voc_explorer_tier6.png"></div>
    String url = getIconURL(itemTooltip);
    // Name
    _item.setName(name);
    if (url != null) {
        _item.setIconURL(url);
    }
    // Item sub-category
    // <div class="itemtype">Craft Tool</div>
    // TODO: duplicated with weapon type and armor type...
    String subCategory = getTagContent(itemTooltip, "itemtype");
    _item.setSubCategory(subCategory);
    // Uniqueness
    // <div class="itemunique"></div>
    String uniqueStr = getTagContent(itemTooltip, "itemunique");
    if ("Unique".equalsIgnoreCase(uniqueStr)) {
        _item.setUnique(true);
    }
    // Item bind
    // <div class="itembind">Bind on Equip</div>
    String itemBindStr = getTagContent(itemTooltip, "itembind");
    ItemBinding binding = getBinding(itemBindStr);
    _item.setBinding(binding);
    // Damage:
    // <div class="itemdamage">197 - 359 Common Damage</div>
    String damage = getTagContent(itemTooltip, "itemdamage");
    if (damage != null) {
        try {
            if (damage.endsWith("Damage")) {
                String tmp = damage.substring(0, damage.length() - 6).trim();
                String[] split = tmp.split(" ", 4);
                int minDamage = Integer.parseInt(split[0]);
                int maxDamage = Integer.parseInt(split[2]);
                String typeStr = split[3];
                DamageType type = DamageType.getDamageTypeByName(typeStr);
                if (type == null) {
                    type = DamageType.COMMON;
                    _logger.warn("Unmanaged damage type [" + typeStr + "]");
                }
                weapon.setMinDamage(minDamage);
                weapon.setMaxDamage(maxDamage);
                weapon.setDamageType(type);
            }
        } catch (Exception e) {
            _logger.error("Damage parsing exception on [" + damage + "]", e);
        }
    }
    // Bonuses
    // <div class="itemes">
    // <div class="iteme">
    // <div>-3s Forester Chopping Duration</div>
    // </div>
    // ...
    // </div>
    List<String> bonuses = new ArrayList<String>();
    Element itemsContainer = JerichoHtmlUtils.findElementByTagNameAndAttributeValue(itemTooltip, HTMLElementName.DIV, "class", "itemes");
    if (itemsContainer != null) {
        List<Element> itemsList = JerichoHtmlUtils.findElementsByTagNameAndAttributeValue(itemsContainer, HTMLElementName.DIV, "class", "iteme");
        for (Element item : itemsList) {
            List<Element> children = item.getChildElements();
            if (children != null) {
                for (Element child : children) {
                    String line = JerichoHtmlUtils.getTagContents(child, HTMLElementName.DIV);
                    bonuses.add(line);
                }
            }
        }
    }
    _item.setBonus(bonuses);
    // TODO <div class="itemmsi">+5 Damage to The Dead</div>
    String msi = getTagContent(itemTooltip, "itemmsi");
    if ((msi != null) && (msi.length() > 0)) {
        _logger.warn("Unmanaged itemmsi [" + msi + "] for " + _item.getName());
    }
    // Item set
    ItemsSet set = parseItemsSet(itemTooltip);
    if (set != null) {
        _item.setSetKey(set.getKey());
        _item.setItemsSet(set);
    }
    // Possible legacies TODO
    /*
<div class="itemes">Possible Initial Legacies:</div>
  <div>Focus Bow Critical Multiplier (Tier(s):
    <span class="legacytier rare">4</span>
    ,
    <span class="legacytier incomparable">5</span>
    ,
    <span class="legacytier incomparable">6</span>
    )
  </div>
  <div>Focus Bow Power Cost (Tier(s):
    <span class="legacytier rare">4</span>
    ,
    <span class="legacytier incomparable">5</span>
    ,
    <span class="legacytier incomparable">6</span>
  )
  </div>
<div>
Induction Bow Critical Multiplier (Tier(s):
<span class="legacytier rare">4</span>
,
<span class="legacytier incomparable">5</span>
,
<span class="legacytier incomparable">6</span>
)
</div>
<div>
<div>
Merciful Shot Cooldown (Tier(s):
<span class="legacytier rare">4</span>
,
<span class="legacytier incomparable">5</span>
,
<span class="legacytier incomparable">6</span>
)
</div>
<div>
Quick Shot Critical Chance (Tier(s):
<span class="legacytier rare">4</span>
,
<span class="legacytier incomparable">5</span>
,
<span class="legacytier incomparable">6</span>
)
</div>
<div>
Ranged Skill Block Chance Modifier (Tier(s):
<span class="legacytier rare">4</span>
,
<span class="legacytier incomparable">5</span>
,
<span class="legacytier incomparable">6</span>
)
</div>
<div>
Ranged Skill Evade Chance Modifier (Tier(s):
<span class="legacytier rare">4</span>
,
<span class="legacytier incomparable">5</span>
,
<span class="legacytier incomparable">6</span>
)
</div>
<div>
Strength Quick Shot Slow (Tier(s):
<span class="legacytier rare">4</span>
,
<span class="legacytier incomparable">5</span>
,
<span class="legacytier incomparable">6</span>
)
</div>
     * 
     */
    // Item durability:
    // - durability
    // <div class="itemdurability">Durability 60 / 60</div>
    String durabilityStr = getTagContent(itemTooltip, "itemdurability");
    Integer durability = getDurability(durabilityStr);
    _item.setDurability(durability);
    // - sturdiness
    // <div class="itemsturdiness">Tough</div>
    String sturdinessStr = getTagContent(itemTooltip, "itemsturdiness");
    ItemSturdiness sturdiness = getSturdiness(sturdinessStr);
    _item.setSturdiness(sturdiness);
    // Item requirements
    List<Element> requirements = JerichoHtmlUtils.findElementsByTagNameAndAttributeValue(itemTooltip, HTMLElementName.DIV, "class", "itemrequirement");
    for (Element requirement : requirements) {
        // String contents=getTagContent(requirement,"itemrequirement");
        String contents = CharacterReference.decodeCollapseWhiteSpace(requirement.getContent());
        if (contents.contains("Minimum Level")) {
            // - minimum level
            // <div class="itemrequirement">Minimum Level: 55</div>
            String minLevelStr = getTagContent(itemTooltip, "itemrequirement");
            Integer minLevel = getMinLevel(minLevelStr);
            _item.setMinLevel(minLevel);
        } else if (contents.contains("Class")) {
            // - class
            String className = parseClassRequirement(requirement);
            if (className != null) {
                CharacterClass cClass = CharacterClass.getByName(className);
                _item.setRequiredClass(cClass);
            }
        }
    }
    // Description
    // <div class="itemdescription">A collection of indispensable tools for tailors, foresters, and prospectors.</div>
    // String description=getTagContent(itemTooltip,"");
    Element element = JerichoHtmlUtils.findElementByTagNameAndAttributeValue(itemTooltip, HTMLElementName.DIV, "class", "itemdescription");
    if (element != null) {
        String description = JerichoHtmlUtils.getTextFromTag(element);
        _item.setDescription(description);
    }
    // Money
    // <div class="itemworth">
    Element worth = JerichoHtmlUtils.findElementByTagNameAndAttributeValue(itemTooltip, HTMLElementName.DIV, "class", "itemworth");
    if (worth != null) {
        Money m = parseMoneyReward(worth);
        _item.setValue(m);
    }
    // Stackability
    // <div class="itemstacksize">Stacks to 100</div>
    String stackabilityStr = getTagContent(itemTooltip, "itemstacksize");
    Integer stackSize = getStackSize(stackabilityStr);
    _item.setStackMax(stackSize);
/*
    // Item category: Armour, Tool, ...
    private ItemCategory _category;
    // Item identifier: "Jacket_of_the_Impossible_Shot", ...
    private String _id;
    */
}
Also used : ArmourType(delta.games.lotro.lore.items.ArmourType) Element(net.htmlparser.jericho.Element) ArrayList(java.util.ArrayList) Weapon(delta.games.lotro.lore.items.Weapon) DamageType(delta.games.lotro.lore.items.DamageType) CharacterClass(delta.games.lotro.common.CharacterClass) Item(delta.games.lotro.lore.items.Item) ItemBinding(delta.games.lotro.lore.items.ItemBinding) Money(delta.games.lotro.common.Money) Armour(delta.games.lotro.lore.items.Armour) ItemsSet(delta.games.lotro.lore.items.ItemsSet) WeaponType(delta.games.lotro.lore.items.WeaponType) ItemSturdiness(delta.games.lotro.lore.items.ItemSturdiness)

Example 8 with Weapon

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

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

the class ConsistencyChecks method consistencyChecks.

/**
 * Perform consistency checks.
 * @param items Items to use.
 */
public void consistencyChecks(List<Item> items) {
    int nbMissingArmourValues = 0;
    int nbMissingArmourTypes = 0;
    int nbMissingWeaponTypes = 0;
    int nbScalables = 0;
    int nbFormulas = 0;
    for (Item item : items) {
        checkItemStats(item);
        // Armours
        if (item instanceof Armour) {
            Armour armour = (Armour) item;
            int armourValue = armour.getArmourValue();
            if (armourValue == 0) {
                nbMissingArmourValues++;
            // System.out.println("No armour value for: " + name + " (" + id + ')');
            }
            ArmourType type = armour.getArmourType();
            if (type == null) {
                nbMissingArmourTypes++;
            // System.out.println("No armour type for: " + name + " (" + id + ')');
            }
        }
        // Weapons
        if (item instanceof Weapon) {
            Weapon weapon = (Weapon) item;
            WeaponType type = weapon.getWeaponType();
            if (type == null) {
                nbMissingWeaponTypes++;
            // System.out.println("No weapon type for: " + name + " (" + id + ')');
            }
        }
        // Scalables
        String scalingIds = item.getProperty(ItemPropertyNames.SCALING);
        String slicedStats = item.getProperty(ItemPropertyNames.FORMULAS);
        if (slicedStats != null) {
            nbFormulas++;
            if (scalingIds != null) {
                nbScalables++;
                _scalableItems.add(item);
                if (item instanceof Armour) {
                    Armour armour = (Armour) item;
                    ArmourType type = armour.getArmourType();
                    if (type == null) {
                        System.out.println("No armour type for: " + item + " with formula: " + slicedStats);
                    }
                }
            }
        }
    }
    System.out.println("Nb armours with missing armour type: " + nbMissingArmourTypes);
    System.out.println("Nb armours with missing armour value: " + nbMissingArmourValues);
    System.out.println("Nb weapons with missing type: " + nbMissingWeaponTypes);
    System.out.println("Nb legendary items: " + _nbLegendaryItems);
    System.out.println("Nb items with stats: " + _nbStats);
    System.out.println("Nb items with missing stats: " + _nbMissingStats);
    System.out.println("Nb items with formula: " + nbFormulas);
    System.out.println("Nb scalable items: " + nbScalables);
// new ItemStatistics().showStatistics(_scalableItems);
}
Also used : Item(delta.games.lotro.lore.items.Item) ArmourType(delta.games.lotro.lore.items.ArmourType) Armour(delta.games.lotro.lore.items.Armour) WeaponType(delta.games.lotro.lore.items.WeaponType) Weapon(delta.games.lotro.lore.items.Weapon)

Example 10 with Weapon

use of delta.games.lotro.lore.items.Weapon 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)

Aggregations

Weapon (delta.games.lotro.lore.items.Weapon)13 Armour (delta.games.lotro.lore.items.Armour)10 WeaponType (delta.games.lotro.lore.items.WeaponType)9 Item (delta.games.lotro.lore.items.Item)8 ArmourType (delta.games.lotro.lore.items.ArmourType)6 EquipmentLocation (delta.games.lotro.lore.items.EquipmentLocation)5 CharacterClass (delta.games.lotro.common.CharacterClass)4 ItemQuality (delta.games.lotro.lore.items.ItemQuality)4 BasicStatsSet (delta.games.lotro.character.stats.BasicStatsSet)3 DamageType (delta.games.lotro.lore.items.DamageType)3 LegendaryWeapon (delta.games.lotro.lore.items.legendary.LegendaryWeapon)3 HashMap (java.util.HashMap)3 STAT (delta.games.lotro.character.stats.STAT)2 Legendary (delta.games.lotro.lore.items.legendary.Legendary)2 FixedDecimalsInteger (delta.games.lotro.utils.FixedDecimalsInteger)2 ArrayList (java.util.ArrayList)2 ComboBoxController (delta.common.ui.swing.combobox.ComboBoxController)1 FloatEditionController (delta.common.ui.swing.text.FloatEditionController)1 IntegerEditionController (delta.common.ui.swing.text.IntegerEditionController)1 Money (delta.games.lotro.common.Money)1