use of delta.games.lotro.character.stats.BasicStatsSet in project lotro-companion by dmorcellet.
the class MainTestSingleStatWidgetsController method doIt.
private void doIt() {
BasicStatsSet value = new BasicStatsSet();
value.addStat(STAT.MORALE, new FixedDecimalsInteger(100));
value.addStat(STAT.CRITICAL_MELEE_PERCENTAGE, new FixedDecimalsInteger(12.3f));
BasicStatsSet reference = new BasicStatsSet();
reference.addStat(STAT.MORALE, new FixedDecimalsInteger(67));
reference.addStat(STAT.CRITICAL_MELEE_PERCENTAGE, new FixedDecimalsInteger(13.3f));
JLabel morale = GuiFactory.buildLabel("Morale");
SingleStatWidgetsController moraleCtrl = new SingleStatWidgetsController(STAT.MORALE, false);
moraleCtrl.updateStats(reference, value);
showFrameForStat(morale, moraleCtrl);
JLabel critMelee = GuiFactory.buildLabel("Crit Melee %");
SingleStatWidgetsController critCtrl = new SingleStatWidgetsController(STAT.CRITICAL_MELEE_PERCENTAGE, true);
critCtrl.updateStats(reference, value);
showFrameForStat(critMelee, critCtrl);
}
use of delta.games.lotro.character.stats.BasicStatsSet in project lotro-companion by dmorcellet.
the class ItemEditionPanelController method selectItemLevel.
private void selectItemLevel(Integer itemLevel) {
if (itemLevel != null) {
ScalingRule rule = Scaling.getScalingRule(_item);
if (rule != null) {
Item item = ItemFactory.clone(_item);
Scaling.scaleToItemLevel(item, itemLevel.intValue());
BasicStatsSet stats = item.getStats();
_stats.initFromStats(stats);
if (item instanceof Armour) {
Armour armour = (Armour) item;
int armourValue = armour.getArmourValue();
_armourValue.setValue(Integer.valueOf(armourValue));
}
Integer requiredLevel = rule.getRequiredLevel(itemLevel.intValue());
if (requiredLevel != null) {
_minLevel.selectItem(requiredLevel);
}
}
}
}
use of delta.games.lotro.character.stats.BasicStatsSet 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.BasicStatsSet 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;
}
use of delta.games.lotro.character.stats.BasicStatsSet in project lotro-tools by dmorcellet.
the class LotroPlanMordorRelicsLoader method itemToRelic.
private Relic itemToRelic(Item item) {
String name = item.getName();
if (name.startsWith("-"))
name = name.substring(1);
name = name.trim();
Integer requiredLevel = item.getItemLevel();
RelicType type = getRelicTypeFromName(name);
Relic relic = new Relic(name, type, requiredLevel);
BasicStatsSet stats = relic.getStats();
stats.setStats(item.getStats());
return relic;
}
Aggregations