use of delta.games.lotro.character.stats.BasicStatsSet in project lotro-tools by dmorcellet.
the class MainTestStatsComputer method doStat.
private void doStat(int itemLevel, String formula) {
ItemStatSliceData slice = SliceFormulaParser.parse(formula);
SlicesBasedItemStatsProvider provider = new SlicesBasedItemStatsProvider();
provider.addSlice(slice);
BasicStatsSet stats = provider.getStats(itemLevel);
System.out.println(stats);
}
use of delta.games.lotro.character.stats.BasicStatsSet in project lotro-tools by dmorcellet.
the class LotroPlanItemsDbLoader method buildItemFromLine.
private Item buildItemFromLine(LotroPlanTable table, String line) {
String[] fieldsTrimmed = StringSplitter.split(line.trim(), '\t');
if (line.startsWith("#")) {
System.out.println("Ignored: " + line);
return null;
}
if (fieldsTrimmed.length < 2) {
_section = line.trim();
System.out.println("Section: " + _section);
return null;
}
String[] fields = StringSplitter.split(line, '\t');
// Item level
int itemLevel = NumericTools.parseInt(fields[LotroPlanTable.ITEM_LEVEL_INDEX], -1);
// Stats
ItemStatsProvider provider = table.loadStats(fields);
BasicStatsSet stats = provider.getStats(itemLevel);
FixedDecimalsInteger armorStat = stats.getStat(STAT.ARMOUR);
Item item = null;
Armour armour = null;
if (armorStat != null) {
armour = new Armour();
item = armour;
armour.setArmourValue(armorStat.intValue());
stats.removeStat(STAT.ARMOUR);
} else {
item = new Item();
}
// ID
String idStr = "";
int notesIndex = table.getNotesIndex();
if (fields.length >= notesIndex) {
idStr = fields[notesIndex].trim();
}
int id = 0;
if (idStr.startsWith("ID:")) {
idStr = idStr.substring(3).trim();
}
id = NumericTools.parseInt(idStr, -1);
if (id != -1) {
item.setIdentifier(id);
}
// Name
String name = fields[LotroPlanTable.NAME_INDEX];
if (name.startsWith("(")) {
int index = name.indexOf(')');
idStr = name.substring(1, index).trim();
id = NumericTools.parseInt(idStr, -1);
item.setIdentifier(id);
name = name.substring(index + 1).trim();
}
if (name.endsWith(":")) {
name = name.substring(0, name.length() - 1);
}
name = name.replace(' ', ' ');
if (name.endsWith("s)")) {
name = name.substring(0, name.length() - 2);
int index = name.lastIndexOf('(');
int nbSlots = NumericTools.parseInt(name.substring(index + 1), 0);
name = name.substring(0, index).trim();
item.setEssenceSlots(nbSlots);
}
if (name.endsWith(")")) {
String newName = name.substring(0, name.length() - 1);
int index = newName.lastIndexOf('(');
String valueStr = newName.substring(index + 1);
int minLevel;
if ("TBD".equals(valueStr)) {
minLevel = -1;
} else {
minLevel = NumericTools.parseInt(valueStr, -1);
name = newName.substring(0, index).trim();
}
if (minLevel > 0) {
item.setMinLevel(Integer.valueOf(minLevel));
}
}
name = name.trim();
item.setName(name);
// Item level
if (itemLevel != -1) {
item.setItemLevel(Integer.valueOf(itemLevel));
}
// Stats
item.getStats().setStats(stats);
String slices = provider.toPersistableString();
int nbSlices = ((SlicesBasedItemStatsProvider) provider).getSlices();
if (nbSlices > 0) {
item.setProperty(ItemPropertyNames.FORMULAS, slices);
}
// Slot
EquipmentLocation slot = null;
if ("Head".equals(_section))
slot = EquipmentLocation.HEAD;
else if ("Shoulders".equals(_section))
slot = EquipmentLocation.SHOULDER;
else if ("Chest".equals(_section))
slot = EquipmentLocation.CHEST;
else if ("Hands".equals(_section))
slot = EquipmentLocation.HAND;
else if ("Legs".equals(_section))
slot = EquipmentLocation.LEGS;
else if ("Feet".equals(_section))
slot = EquipmentLocation.FEET;
else if ("Shields".equals(_section))
slot = EquipmentLocation.OFF_HAND;
else if ("Ears".equals(_section))
slot = EquipmentLocation.EAR;
else if ("Neck".equals(_section))
slot = EquipmentLocation.NECK;
else if ("Wrists".equals(_section))
slot = EquipmentLocation.WRIST;
else if ("Fingers".equals(_section))
slot = EquipmentLocation.FINGER;
else if ("Pockets".equals(_section))
slot = EquipmentLocation.POCKET;
if (slot == null) {
int categoryIndex = table.getCategoryIndex();
if ((categoryIndex > 0) && (fields.length >= categoryIndex)) {
String category = fields[categoryIndex];
slot = getSlotFromCategory(category);
}
}
// Class requirement
String classRequirementStr = "";
int classesIndex = table.getClassesIndex();
if ((classesIndex != -1) && (fields.length >= classesIndex)) {
classRequirementStr = fields[classesIndex].trim();
}
CharacterClass classRequirement = getClassRequirement(classRequirementStr);
if (classRequirement != null) {
item.setRequiredClass(classRequirement);
}
if ("Burglar Signals".equals(_section)) {
item.setSubCategory("Burglar:Signal");
slot = EquipmentLocation.RANGED_ITEM;
item.setRequiredClass(CharacterClass.BURGLAR);
} else if ("Captain Standards".equals(_section)) {
item.setSubCategory("Captain:Standard");
slot = EquipmentLocation.RANGED_ITEM;
item.setRequiredClass(CharacterClass.CAPTAIN);
} else if ("Hunter Tomes".equals(_section)) {
String subCategory = "Tome";
if (name.contains("Wind-rider"))
subCategory = "Wind-rider";
if (name.contains("Whisper-draw"))
subCategory = "Whisper-draw";
item.setSubCategory("Hunter:" + subCategory);
slot = EquipmentLocation.CLASS_SLOT;
item.setRequiredClass(CharacterClass.HUNTER);
} else if ("Lore-master Brooches".equals(_section)) {
item.setSubCategory("Lore-master:Stickpin");
slot = EquipmentLocation.RANGED_ITEM;
item.setRequiredClass(CharacterClass.LORE_MASTER);
} else if ("Minstrel Instruments".equals(_section)) {
item.setSubCategory("Instrument");
slot = EquipmentLocation.RANGED_ITEM;
item.setRequiredClass(CharacterClass.MINSTREL);
} else if ("Rune-keeper Chisels".equals(_section)) {
String subCategory = "Other";
if (name.contains("Riffler"))
subCategory = "Riffler";
if (name.contains("Chisel"))
subCategory = "Chisel";
item.setSubCategory("Rune-keeper:" + subCategory);
slot = EquipmentLocation.RANGED_ITEM;
item.setRequiredClass(CharacterClass.RUNE_KEEPER);
} else if ("Warden Carvings".equals(_section)) {
item.setSubCategory("Warden:Carving");
slot = EquipmentLocation.CLASS_SLOT;
item.setRequiredClass(CharacterClass.WARDEN);
}
if (slot != null) {
item.setEquipmentLocation(slot);
}
return item;
}
use of delta.games.lotro.character.stats.BasicStatsSet in project lotro-tools by dmorcellet.
the class EssenceStatsInjector method handleTier.
private void handleTier(int tier, HashMap<Integer, Item> essences) {
URL url = URLTools.getFromClassPath("tier" + tier + ".txt", EssenceStatsInjector.class.getPackage());
if (url != null) {
TextFileReader reader = new TextFileReader(url, EncodingNames.UTF_8);
List<String> lines = TextUtils.readAsLines(reader);
boolean hasId = lines.get(0).startsWith("ID");
lines.remove(0);
HashSet<Integer> unmanaged = new HashSet<Integer>();
unmanaged.addAll(essences.keySet());
LotroPlanTable table = new LotroPlanTable(STATS);
for (String line : lines) {
String[] fields = StringSplitter.split(line, '\t');
if (fields.length > 2) {
List<Item> items = findEssences(fields, hasId, essences);
for (Item item : items) {
if (hasId) {
String[] newFields = new String[fields.length - 1];
for (int i = 1; i < fields.length; i++) {
newFields[i - 1] = fields[i];
if (newFields[i - 1].equals(CELLS[i])) {
newFields[i - 1] = "";
}
}
fields = newFields;
}
unmanaged.remove(Integer.valueOf(item.getIdentifier()));
// Item level
int itemLevel = NumericTools.parseInt(fields[ITEM_LEVEL_INDEX], -1);
if (itemLevel != -1) {
item.setItemLevel(Integer.valueOf(itemLevel));
}
// Notes
if (fields.length > NOTES_INDEX) {
String notes = fields[NOTES_INDEX].trim();
if (notes.length() > 0) {
item.getBonus().add(notes);
}
}
// Tier
item.setSubCategory("Essence:Tier" + tier);
// Stats
ItemStatsProvider provider = table.loadStats(fields);
BasicStatsSet stats = item.getStats();
stats.setStats(provider.getStats(itemLevel));
}
if (items.size() == 0) {
System.out.println("Essence not found: " + fields[0]);
}
} else {
if (!line.startsWith("#")) {
System.err.println("Bad fields count: " + line);
}
}
}
if (unmanaged.size() > 0) {
System.out.println(unmanaged + " unmanaged essences:");
for (Integer id : unmanaged) {
Item essence = essences.get(id);
System.out.println("\t" + essence);
}
}
}
}
use of delta.games.lotro.character.stats.BasicStatsSet in project lotro-tools by dmorcellet.
the class BonusConverter method getStats.
/**
* Get stats from a bonus manager.
* @param bonusMgr Bonus manager.
* @return A set of stats.
*/
public BasicStatsSet getStats(BonusManager bonusMgr) {
BasicStatsSet stats = new BasicStatsSet();
int nbBonus = bonusMgr.getNumberOfBonus();
for (int i = 0; i < nbBonus; i++) {
Bonus bonus = bonusMgr.getBonusAt(i);
parseBonus(bonus, stats);
}
return stats;
}
use of delta.games.lotro.character.stats.BasicStatsSet 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;
}
Aggregations