use of delta.games.lotro.lore.items.WeaponType in project lotro-companion by dmorcellet.
the class ItemFilterConfiguration method initFromItems.
/**
* Init from a collection of items.
* @param items Items to use.
*/
public void initFromItems(List<Item> items) {
_armourTypes.clear();
_shieldTypes.clear();
_weaponTypes.clear();
for (Item item : items) {
// Armour
if (item instanceof Armour) {
Armour weapon = (Armour) item;
ArmourType type = weapon.getArmourType();
if (type != null) {
if (type.isShield()) {
_shieldTypes.add(type);
} else {
_armourTypes.add(type);
}
}
}
// Weapon
if (item instanceof Weapon) {
Weapon weapon = (Weapon) item;
WeaponType type = weapon.getWeaponType();
if (type != null) {
_weaponTypes.add(type);
}
}
}
}
use of delta.games.lotro.lore.items.WeaponType in project lotro-companion by dmorcellet.
the class ItemFilterController method build.
private JPanel build() {
JPanel panel = GuiFactory.buildPanel(new GridBagLayout());
JPanel line1Panel = GuiFactory.buildPanel(new FlowLayout(FlowLayout.LEADING, 5, 0));
// Quality
{
JPanel qualityPanel = GuiFactory.buildPanel(new FlowLayout(FlowLayout.LEADING));
qualityPanel.add(GuiFactory.buildLabel("Quality:"));
_quality = ItemUiTools.buildQualityCombo();
ItemSelectionListener<ItemQuality> qualityListener = new ItemSelectionListener<ItemQuality>() {
@Override
public void itemSelected(ItemQuality quality) {
_qualityFilter.setQuality(quality);
filterUpdated();
}
};
_quality.addListener(qualityListener);
qualityPanel.add(_quality.getComboBox());
line1Panel.add(qualityPanel);
}
// Label filter
{
JPanel containsPanel = GuiFactory.buildPanel(new FlowLayout(FlowLayout.LEADING));
containsPanel.add(GuiFactory.buildLabel("Label filter:"));
_contains = GuiFactory.buildTextField("");
_contains.setColumns(20);
containsPanel.add(_contains);
TextListener listener = new TextListener() {
@Override
public void textChanged(String newText) {
if (newText.length() == 0)
newText = null;
_nameFilter.setPattern(newText);
filterUpdated();
}
};
_textController = new DynamicTextEditionController(_contains, listener);
line1Panel.add(containsPanel);
}
// Line 2: weapon type, armour type, shield type
JPanel line2Panel = GuiFactory.buildPanel(new FlowLayout(FlowLayout.LEADING));
// Weapon type
if (_weaponType != null) {
JPanel weaponTypePanel = GuiFactory.buildPanel(new FlowLayout(FlowLayout.LEADING, 5, 0));
weaponTypePanel.add(GuiFactory.buildLabel("Weapon type:"));
ItemSelectionListener<WeaponType> weaponTypeListener = new ItemSelectionListener<WeaponType>() {
@Override
public void itemSelected(WeaponType type) {
_weaponTypeFilter.setWeaponType(type);
// If a weapon type is selected,
if (type != null) {
// Reset the shield type combo
if (_armourType != null) {
_armourType.selectItem(null);
}
// Reset the shield type combo
if (_shieldType != null) {
_shieldType.selectItem(null);
}
}
filterUpdated();
}
};
_weaponType.addListener(weaponTypeListener);
weaponTypePanel.add(_weaponType.getComboBox());
line2Panel.add(weaponTypePanel);
}
// Armour type
if (_armourType != null) {
JPanel armourTypePanel = GuiFactory.buildPanel(new FlowLayout(FlowLayout.LEADING));
armourTypePanel.add(GuiFactory.buildLabel("Armour type:"));
ItemSelectionListener<ArmourType> armourTypeListener = new ItemSelectionListener<ArmourType>() {
@Override
public void itemSelected(ArmourType type) {
_armourTypeFilter.setArmourType(type);
// If an armour type is selected,
if (type != null) {
// Reset the weapon type combo
if (_weaponType != null) {
_weaponType.selectItem(null);
}
// Reset the shield type combo
if (_shieldType != null) {
_shieldType.selectItem(null);
}
}
filterUpdated();
}
};
_armourType.addListener(armourTypeListener);
armourTypePanel.add(_armourType.getComboBox());
line2Panel.add(armourTypePanel);
}
// Shield type
if (_shieldType != null) {
JPanel shieldTypePanel = GuiFactory.buildPanel(new FlowLayout(FlowLayout.LEADING));
shieldTypePanel.add(GuiFactory.buildLabel("Shield type:"));
ItemSelectionListener<ArmourType> shieldTypeListener = new ItemSelectionListener<ArmourType>() {
@Override
public void itemSelected(ArmourType type) {
_shieldTypeFilter.setArmourType(type);
// If a shield type is selected,
if (type != null) {
// Reset the weapon type combo
if (_weaponType != null) {
_weaponType.selectItem(null);
}
// Reset the armour type combo
if (_armourType != null) {
_armourType.selectItem(null);
}
}
filterUpdated();
}
};
_shieldType.addListener(shieldTypeListener);
shieldTypePanel.add(_shieldType.getComboBox());
line2Panel.add(shieldTypePanel);
}
GridBagConstraints c = new GridBagConstraints(0, 0, 1, 1, 1.0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
panel.add(line1Panel, c);
c = new GridBagConstraints(0, 1, 1, 1, 1.0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
panel.add(line2Panel, c);
return panel;
}
use of delta.games.lotro.lore.items.WeaponType in project lotro-tools by dmorcellet.
the class ItemNormalization method normalizeLegendaryItem.
private Item normalizeLegendaryItem(Item item) {
String name = item.getName();
ItemQuality quality = null;
if (name == null)
return item;
if (name.endsWith("of the First Age"))
quality = ItemQuality.LEGENDARY;
else if (name.endsWith("of the Second Age"))
quality = ItemQuality.INCOMPARABLE;
else if (name.endsWith("of the Third Age"))
quality = ItemQuality.RARE;
if (quality != null) {
CharacterClass cClass = null;
if (name.indexOf("Champion") != -1)
cClass = CharacterClass.CHAMPION;
else if (name.indexOf("Captain") != -1)
cClass = CharacterClass.CAPTAIN;
else if (name.indexOf("Beorning") != -1)
cClass = CharacterClass.BEORNING;
else if (name.indexOf("Burglar") != -1)
cClass = CharacterClass.BURGLAR;
else if (name.indexOf("Guardian") != -1)
cClass = CharacterClass.GUARDIAN;
else if (name.indexOf("Hunter") != -1)
cClass = CharacterClass.HUNTER;
else if (name.indexOf("Lore-master") != -1)
cClass = CharacterClass.LORE_MASTER;
else if (name.indexOf("Minstrel") != -1)
cClass = CharacterClass.MINSTREL;
else if (name.indexOf("Rune-keeper") != -1)
cClass = CharacterClass.RUNE_KEEPER;
else if (name.indexOf("Warden") != -1)
cClass = CharacterClass.WARDEN;
WeaponType weaponType = null;
String classItemType = null;
boolean bridle = false;
if (name.indexOf("Great Club") != -1)
weaponType = WeaponType.TWO_HANDED_CLUB;
else if (name.indexOf("Great Axe") != -1)
weaponType = WeaponType.TWO_HANDED_AXE;
else if (name.indexOf("Great Sword") != -1)
weaponType = WeaponType.TWO_HANDED_SWORD;
else if (name.indexOf("Greatsword") != -1)
weaponType = WeaponType.TWO_HANDED_SWORD;
else if (name.indexOf("Great Hammer") != -1)
weaponType = WeaponType.TWO_HANDED_HAMMER;
else if (name.indexOf("Halberd") != -1)
weaponType = WeaponType.HALBERD;
else if (name.indexOf("Club") != -1)
weaponType = WeaponType.ONE_HANDED_CLUB;
else if (name.indexOf("Axe") != -1)
weaponType = WeaponType.ONE_HANDED_AXE;
else if (name.indexOf("Sword") != -1)
weaponType = WeaponType.ONE_HANDED_SWORD;
else if (name.indexOf("Hammer") != -1)
weaponType = WeaponType.ONE_HANDED_HAMMER;
else if (name.indexOf("Dagger") != -1)
weaponType = WeaponType.DAGGER;
else if (name.indexOf("Spear") != -1)
weaponType = WeaponType.SPEAR;
else if (name.indexOf("Mace") != -1)
weaponType = WeaponType.ONE_HANDED_MACE;
else if (name.indexOf("Rune-stone") != -1) {
weaponType = WeaponType.RUNE_STONE;
cClass = CharacterClass.RUNE_KEEPER;
} else if (name.indexOf("Stone") != -1) {
weaponType = WeaponType.RUNE_STONE;
cClass = CharacterClass.RUNE_KEEPER;
} else if (name.indexOf("Staff") != -1)
weaponType = WeaponType.STAFF;
else if (name.indexOf("Carving") != -1)
classItemType = "Carving";
else if (name.indexOf("Tools") != -1)
classItemType = "Tools";
else if (name.indexOf("Emblem") != -1)
classItemType = "Emblem";
else if (name.indexOf("Rune-satchel") != -1)
classItemType = "Rune-satchel";
else if (name.indexOf("Rune") != -1)
classItemType = "Rune";
else if (name.indexOf("Belt") != -1)
classItemType = "Belt";
else if (name.indexOf("Crossbow") != -1)
weaponType = WeaponType.CROSSBOW;
else if (name.indexOf("Bow") != -1)
weaponType = WeaponType.BOW;
else if (name.indexOf("Book") != -1)
classItemType = "Book";
else if (name.indexOf("Songbook") != -1)
classItemType = "Songbook";
else if (name.indexOf("Javelin") != -1)
weaponType = WeaponType.JAVELIN;
else if (name.indexOf("Bridle") != -1)
bridle = true;
if ((weaponType != null) || (classItemType != null) || (bridle)) {
item.setQuality(quality);
item.setRequiredClass(cClass);
String category = null;
if ((classItemType != null) || (bridle)) {
LegendaryItem legendaryItem;
if (item instanceof LegendaryItem) {
legendaryItem = (LegendaryItem) item;
} else {
legendaryItem = new LegendaryItem();
legendaryItem.copyFrom(item);
item = legendaryItem;
}
}
if (bridle) {
category = "Bridle";
item.setEquipmentLocation(EquipmentLocation.BRIDLE);
} else if (classItemType != null) {
category = cClass.getLabel() + ":" + classItemType;
item.setEquipmentLocation(EquipmentLocation.CLASS_SLOT);
} else if (weaponType != null) {
LegendaryWeapon weapon;
if (item instanceof LegendaryWeapon) {
weapon = (LegendaryWeapon) item;
} else {
weapon = new LegendaryWeapon();
weapon.copyFrom(item);
item = weapon;
}
EquipmentLocation location = weaponType.isRanged() ? EquipmentLocation.RANGED_ITEM : EquipmentLocation.MAIN_HAND;
weapon.setEquipmentLocation(location);
weapon.setWeaponType(weaponType);
}
item.setSubCategory(category);
item.removeProperty(ItemPropertyNames.TULKAS_CATEGORY);
item.removeProperty(ItemPropertyNames.LEGACY_CATEGORY);
// System.out.println(name+", class="+cClass+", category="+category+", weapon type="+type);
}
}
return item;
}
use of delta.games.lotro.lore.items.WeaponType in project lotro-tools by dmorcellet.
the class ItemNormalization method setWeaponTypeFromCategory.
private Item setWeaponTypeFromCategory(Item item, String category, WeaponType type) {
Weapon ret = null;
if ((category == null) || (category.equals(item.getSubCategory()))) {
if (item.getClass() == Item.class) {
ret = new Weapon();
ret.copyFrom(item);
} else {
ret = (Weapon) item;
}
WeaponType oldType = ret.getWeaponType();
if (oldType == null) {
ret.setWeaponType(type);
} else {
if (type != oldType) {
System.out.println("Conflict weapon type for ID:" + item.getIdentifier() + ", name:" + item.getName() + ": from:" + oldType + " to:" + type);
}
}
}
if (ret != null) {
if (type.isRanged()) {
ret.setEquipmentLocation(EquipmentLocation.RANGED_ITEM);
} else {
ret.setEquipmentLocation(EquipmentLocation.MAIN_HAND);
}
}
return (ret != null) ? ret : item;
}
use of delta.games.lotro.lore.items.WeaponType 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;
*/
}
Aggregations