use of delta.games.lotro.character.stats.STAT in project lotro-tools by dmorcellet.
the class CharacterPageParser method parseStats.
private void parseStats(Element charPanel) {
BasicStatsSet stats = _character.getStats();
// <table class="stat_list">
List<Element> statsTables = JerichoHtmlUtils.findElementsByTagNameAndAttributeValue(charPanel, HTMLElementName.TABLE, "class", "stat_list");
for (Element statsTable : statsTables) {
List<Element> rows = statsTable.getAllElements(HTMLElementName.TR);
for (Element row : rows) {
String statName = JerichoHtmlUtils.getTagContents(row, HTMLElementName.TH);
if (statName != null) {
statName = statName.trim();
if (statName.length() > 0) {
String statValue = JerichoHtmlUtils.getTagContents(row, HTMLElementName.TD);
STAT stat = getStatByName(statName);
if (stat != null) {
Integer value = null;
if (!"N/A".equals(statValue)) {
value = NumericTools.parseInteger(statValue);
}
if (value != null) {
stats.setStat(stat, value.intValue());
}
// System.out.println("Stat : name=["+statName+"], value=["+value+"]");
}
}
}
}
}
}
use of delta.games.lotro.character.stats.STAT in project lotro-tools by dmorcellet.
the class DataLotroCharacterPageParser method parseCharacter.
private CharacterData parseCharacter(byte[] xmlBuffer) {
CharacterData ret = null;
if (xmlBuffer != null) {
ByteArrayInputStream bis = new ByteArrayInputStream(xmlBuffer);
Element root = DOMParsingTools.parse(bis);
if (root != null) {
Element characterTag = DOMParsingTools.getChildTagByName(root, "character");
if (characterTag != null) {
ret = new CharacterData();
// Character name
NamedNodeMap attrs = characterTag.getAttributes();
String charName = DOMParsingTools.getStringAttribute(attrs, "name", null);
ret.setName(charName);
// World/server
String server = DOMParsingTools.getStringAttribute(attrs, "world", null);
ret.setServer(server);
// Class
String charClassName = DOMParsingTools.getStringAttribute(attrs, "class", null);
CharacterClass cClass = CharacterClass.getByName(charClassName);
ret.setCharacterClass(cClass);
// Race
String charRace = DOMParsingTools.getStringAttribute(attrs, "race", null);
Race race = Race.getByLabel(charRace);
ret.setRace(race);
// Nation/origin
String charNation = DOMParsingTools.getStringAttribute(attrs, "origin", null);
if (charNation != null) {
charNation = charNation.replace('_', ' ');
}
ret.setRegion(charNation);
// Level
String charLevelStr = DOMParsingTools.getStringAttribute(attrs, "level", null);
int charLevel = NumericTools.parseInt(charLevelStr, 0);
ret.setLevel(charLevel);
// System.out.println("Class ["+charClassName+"], Race ["+charRace+"], Nation ["+charNation+"], Level="+charLevel);
Element statsTag = DOMParsingTools.getChildTagByName(characterTag, "stats");
if (statsTag != null) {
BasicStatsSet stats = ret.getStats();
List<Element> statTags = DOMParsingTools.getChildTagsByName(statsTag, "stat");
for (Element statTag : statTags) {
NamedNodeMap statAttrs = statTag.getAttributes();
String statName = DOMParsingTools.getStringAttribute(statAttrs, "name", null);
String statValue = DOMParsingTools.getStringAttribute(statAttrs, "value", null);
Integer value = null;
if ((!"N/A".equals(statValue)) && (!("??".equals(statValue)))) {
value = NumericTools.parseInteger(statValue);
}
if (value != null) {
STAT stat = getStatByName(statName);
if (stat != null) {
stats.setStat(stat, value.intValue());
}
}
}
}
// Equipment
Element equipmentTag = DOMParsingTools.getChildTagByName(characterTag, "equipment");
if (equipmentTag != null) {
CharacterEquipment equipment = ret.getEquipment();
List<Element> itemTags = DOMParsingTools.getChildTagsByName(equipmentTag, "item");
for (Element itemTag : itemTags) {
NamedNodeMap itemAttrs = itemTag.getAttributes();
// Identifier
int itemId = DOMParsingTools.getIntAttribute(itemAttrs, "item_id", 0);
// String objectPageURL=DOMParsingTools.getStringAttribute(itemAttrs,"lorebookEntry",null);
String slotName = DOMParsingTools.getStringAttribute(itemAttrs, "slot", null);
EQUIMENT_SLOT slot = getSlotByName(slotName);
if (slot != null) {
SlotContents contents = equipment.getSlotContents(slot, true);
if (itemId != 0) {
contents.setItemId(Integer.valueOf(itemId));
}
}
}
}
}
}
}
return ret;
}
use of delta.games.lotro.character.stats.STAT in project lotro-tools by dmorcellet.
the class ItemsMerger method compareStats.
private boolean compareStats(BasicStatsSet expected, BasicStatsSet actual) {
int expectedCount = expected.getStatsCount();
int actualCount = actual.getStatsCount();
if (expectedCount != actualCount) {
return false;
}
for (STAT stat : expected.getStats()) {
FixedDecimalsInteger expectedValue = expected.getStat(stat);
FixedDecimalsInteger actualValue = actual.getStat(stat);
if (actualValue == null) {
return false;
}
int expectedInternalValue = expectedValue.getInternalValue();
int actualInternalValue = actualValue.getInternalValue();
if (Math.abs(expectedInternalValue - actualInternalValue) > 100) {
return false;
}
}
return true;
}
use of delta.games.lotro.character.stats.STAT 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;
}
use of delta.games.lotro.character.stats.STAT in project lotro-tools by dmorcellet.
the class RelicsIndexPageParser method parseStats.
private BasicStatsSet parseStats(String statsStr) {
// System.out.println(statsStr);
BasicStatsSet statsSet = new BasicStatsSet();
String[] lines = statsStr.split("\n");
for (String line : lines) {
line = line.trim();
int firstSpaceIndex = line.indexOf(" ");
if (firstSpaceIndex != -1) {
String valueStr = line.substring(0, firstSpaceIndex);
String statName = line.substring(firstSpaceIndex + 1).trim();
// System.out.println("Value: "+valueStr);
// System.out.println("Stat: "+statName);
Float value = parseValue(valueStr);
STAT[] stats = parseStat(statName);
if ((value != null) && (stats != null)) {
for (STAT stat : stats) {
statsSet.addStat(stat, new FixedDecimalsInteger(value.floatValue()));
}
}
} else {
System.err.println("Cannot parse: " + line);
}
}
return statsSet;
}
Aggregations