use of delta.games.lotro.common.CharacterClass 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.common.CharacterClass 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.common.CharacterClass in project lotro-tools by dmorcellet.
the class MergeWithLotroPlanDb method mergeItems.
private Item mergeItems(Item source, Item lotroplan) {
int id = source.getIdentifier();
Item result = source;
// Check types
if (source.getClass() != lotroplan.getClass()) {
// System.out.println("ID: " + id+": type conflict: lotroplan=" + lotroplan.getClass() + ", source=" + source.getClass());
if (source.getClass() == Item.class) {
if (lotroplan instanceof Armour) {
Armour armour = new Armour();
Armour lotroplanArmour = (Armour) lotroplan;
result = armour;
armour.copyFrom(source);
armour.setArmourValue(lotroplanArmour.getArmourValue());
armour.setArmourType(lotroplanArmour.getArmourType());
} else {
System.out.println("ID: " + id + ": type conflict: lotroplan=" + lotroplan.getClass() + ", source=" + source.getClass());
}
}
if (source.getClass() == Weapon.class) {
if (lotroplan.getClass() == Item.class) {
result = source;
} else {
System.out.println("ID: " + id + ": type conflict: lotroplan=" + lotroplan.getClass() + ", source=" + source.getClass());
}
}
} else {
result = source;
}
// Name
{
String sourceName = source.getName();
/*
String lotroplanName=lotroplan.getName();
if (!lotroplanName.equals(sourceName))
{
System.out.println("ID: " + id+": name conflict: lotroplan=" + lotroplanName + ", source=" + sourceName);
if (lotroplanName!=null)
{
result.setProperty(ItemPropertyNames.LOTRO_PLAN_NAME, lotroplanName);
}
}
*/
result.setName(sourceName);
}
// Armour
{
if (lotroplan instanceof Armour) {
Armour lotroplanArmour = (Armour) lotroplan;
Armour resultArmour = (Armour) result;
// Check values
{
int lotroplanArmourValue = lotroplanArmour.getArmourValue();
/*
int resultArmourValue=resultArmour.getArmourValue();
if (lotroplanArmourValue!=resultArmourValue)
{
System.out.println("ID: " + id+": armour value conflict: lotroplan=" + lotroplanArmourValue + ", source=" + resultArmourValue);
}
*/
resultArmour.setArmourValue(lotroplanArmourValue);
}
}
}
// Item level
{
Integer sourceItemLevel = source.getItemLevel();
Integer lotroPlanItemLevel = lotroplan.getItemLevel();
boolean conflict = false;
if (lotroPlanItemLevel != null) {
if (sourceItemLevel == null) {
conflict = true;
// result.setMinLevel(tulkasMinLevel);
} else {
if (lotroPlanItemLevel.intValue() != sourceItemLevel.intValue()) {
conflict = true;
// result.setMinLevel(tulkasMinLevel);
}
}
} else {
if (sourceItemLevel != null) {
conflict = true;
// result.setMinLevel(sourceMinLevel);
}
}
if (conflict) {
// System.out.println("ID: " + id+": item level conflict: lotroplan=" + lotroPlanItemLevel + ", source=" + sourceItemLevel);
}
result.setItemLevel(lotroplan.getItemLevel());
}
// Stats
{
BasicStatsSet resultStats = result.getStats();
FixedDecimalsInteger stealth = resultStats.getStat(STAT.STEALTH_LEVEL);
FixedDecimalsInteger tacticalCritMultiplier = resultStats.getStat(STAT.TACTICAL_CRITICAL_MULTIPLIER);
resultStats.clear();
resultStats.setStats(lotroplan.getStats());
if (stealth != null) {
resultStats.setStat(STAT.STEALTH_LEVEL, stealth);
}
if (tacticalCritMultiplier != null) {
resultStats.setStat(STAT.TACTICAL_CRITICAL_MULTIPLIER, tacticalCritMultiplier);
}
}
// Essence slots
result.setEssenceSlots(lotroplan.getEssenceSlots());
// Slot
EquipmentLocation lpLocation = lotroplan.getEquipmentLocation();
if (lpLocation != null) {
EquipmentLocation location = result.getEquipmentLocation();
boolean conflict = false;
if ((location != null) && (location != lpLocation)) {
conflict = true;
}
if (conflict) {
System.out.println("ID: " + id + ": slot conflict: lotroplan=" + lpLocation + ", source=" + location);
}
result.setEquipmentLocation(lpLocation);
}
// Sub-category
String lpSubCategory = lotroplan.getSubCategory();
if ((lpSubCategory != null) && (lpSubCategory.length() > 0)) {
/*
String subCategory=result.getSubCategory();
boolean conflict=false;
if ((subCategory!=null) && (!subCategory.equals(lpSubCategory)))
{
conflict=true;
}
if (conflict)
{
System.out.println("ID: " + id+": category conflict: lotroplan=" + lpSubCategory + ", source=" + subCategory);
}
*/
result.setSubCategory("LP:" + lpSubCategory);
}
// Class requirement
CharacterClass lpClass = lotroplan.getRequiredClass();
if (lpClass != null) {
CharacterClass cClass = result.getRequiredClass();
boolean conflict = false;
if ((cClass != null) && (cClass != lpClass)) {
conflict = true;
}
if (conflict) {
System.out.println("ID: " + id + ": class conflict: lotroplan=" + lpClass + ", source=" + cClass);
}
result.setRequiredClass(lpClass);
}
// Properties
result.getProperties().putAll(lotroplan.getProperties());
return result;
}
Aggregations