use of delta.games.lotro.utils.FixedDecimalsInteger in project lotro-companion by dmorcellet.
the class EssencesSummaryPanelController method updateStatsPanel.
private void updateStatsPanel(JPanel panel, BasicStatsSet stats) {
panel.removeAll();
int rowIndex = 0;
GridBagConstraints strutConstraints = new GridBagConstraints(0, rowIndex, 3, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 0, 0);
panel.add(Box.createHorizontalStrut(100), strutConstraints);
rowIndex++;
int statsCount = stats.getStatsCount();
if (statsCount > 0) {
// Grab toon stats
BasicStatsSet toonStats = _toon.getStats();
// Build display
for (STAT stat : STAT.values()) {
FixedDecimalsInteger value = stats.getStat(stat);
if (value != null) {
// Value label
JLabel valueLabel = GuiFactory.buildLabel(value.toString());
GridBagConstraints c = new GridBagConstraints(0, rowIndex, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 0, 0);
panel.add(valueLabel, c);
// Name label
String name = StatLabels.getStatLabel(stat);
JLabel statLabel = GuiFactory.buildLabel(name);
c = new GridBagConstraints(1, rowIndex, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 0), 0, 0);
panel.add(statLabel, c);
// Percentage
FixedDecimalsInteger toonStat = toonStats.getStat(stat);
String percentageStr = "";
if (toonStat != null) {
float percentage = 100 * (value.floatValue() / toonStat.floatValue());
percentageStr = String.format("%.1f%%", Float.valueOf(percentage));
}
JLabel percentageLabel = GuiFactory.buildLabel(percentageStr);
c = new GridBagConstraints(2, rowIndex, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0);
panel.add(percentageLabel, c);
rowIndex++;
}
}
}
}
use of delta.games.lotro.utils.FixedDecimalsInteger in project lotro-companion by dmorcellet.
the class StatValuesPanelController method getStatValue.
private FixedDecimalsInteger getStatValue(SingleStatCurveConfiguration config, int level, FixedDecimalsInteger baseStatValue) {
RatingCurve curve = config.getCurve();
double value = (baseStatValue != null) ? baseStatValue.doubleValue() : 0.0;
Double result = curve.getPercentage(value, level);
FixedDecimalsInteger ret = (result != null) ? new FixedDecimalsInteger(result.floatValue()) : null;
return ret;
}
use of delta.games.lotro.utils.FixedDecimalsInteger 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.utils.FixedDecimalsInteger in project lotro-tools by dmorcellet.
the class LotroPlanTable method loadStats.
/**
* Load stats from fields.
* @param fields Fields to read.
* @return An item stats provider or <code>null</code>.
*/
public ItemStatsProvider loadStats(String[] fields) {
SlicesBasedItemStatsProvider provider = new SlicesBasedItemStatsProvider();
int nbStats = _stats.length;
for (int index = 0; index < nbStats; index++) {
STAT stat = _stats[index];
if (stat == null)
continue;
if (index >= fields.length)
continue;
String valueStr = fields[index];
if (valueStr.contains("CALCSLICE")) {
ItemStatSliceData slice = SliceFormulaParser.parse(valueStr);
if (slice != null) {
provider.addSlice(slice);
}
} else {
FixedDecimalsInteger value = StatValueParser.parseStatValue(valueStr);
if (value != null) {
provider.setStat(stat, value);
}
}
}
return provider;
}
use of delta.games.lotro.utils.FixedDecimalsInteger in project lotro-tools by dmorcellet.
the class ItemNormalization method normalizeJewels.
private Item normalizeJewels(Item item) {
Item ret = item;
// int id=item.getIdentifier();
String categoryProp = item.getProperty(ItemPropertyNames.TULKAS_CATEGORY);
String subCategory = item.getSubCategory();
if (("49".equals(categoryProp)) || ("49".equals(subCategory))) {
String previousSubCategory = ret.getSubCategory();
// Pocket=103, Wrist=211, Ear=211, Neck=170, Finger=198
if ("Pocket".equals(previousSubCategory)) {
ret.setEquipmentLocation(EquipmentLocation.POCKET);
ret.setSubCategory(null);
} else if ("Wrist".equals(previousSubCategory)) {
ret.setEquipmentLocation(EquipmentLocation.WRIST);
ret.setSubCategory(null);
} else if ("Ear".equals(previousSubCategory)) {
ret.setEquipmentLocation(EquipmentLocation.EAR);
ret.setSubCategory(null);
} else if ("Neck".equals(previousSubCategory)) {
ret.setEquipmentLocation(EquipmentLocation.NECK);
ret.setSubCategory(null);
} else if ("Finger".equals(previousSubCategory)) {
ret.setEquipmentLocation(EquipmentLocation.FINGER);
ret.setSubCategory(null);
} else {
EquipmentLocation loc = ret.getEquipmentLocation();
if (loc != null) {
ret.setSubCategory(null);
} else {
ret.setSubCategory("Jewelry");
normalizeJewelByName(ret, "Token", EquipmentLocation.POCKET);
normalizeJewelByName(ret, "Earring", EquipmentLocation.EAR);
normalizeJewelByName(ret, "Bauble", EquipmentLocation.POCKET);
normalizeJewelByName(ret, "Necklace", EquipmentLocation.NECK);
normalizeJewelByName(ret, "Ring", EquipmentLocation.FINGER);
normalizeJewelByName(ret, "Bracelet", EquipmentLocation.WRIST);
normalizeJewelByName(ret, "Cuff", EquipmentLocation.WRIST);
normalizeJewelByName(ret, "Ear Cuff", EquipmentLocation.EAR);
normalizeJewelByName(ret, "Barrow-brie", EquipmentLocation.POCKET);
normalizeJewelByName(ret, "Stone", EquipmentLocation.POCKET);
normalizeJewelByName(ret, "Pendant", EquipmentLocation.NECK);
normalizeJewelByName(ret, "Choker", EquipmentLocation.NECK);
normalizeJewelByName(ret, "Band ", EquipmentLocation.FINGER);
normalizeJewelByName(ret, "Armlet", EquipmentLocation.WRIST);
// normalizeJewelByName(ret,"Bangle of Deep Waters",EquipmentLocation.WRIST);
normalizeJewelByName(ret, "Mountain-stone", EquipmentLocation.POCKET);
normalizeJewelByName(ret, "Scroll", EquipmentLocation.POCKET);
normalizeJewelByName(ret, "Phial", EquipmentLocation.POCKET);
normalizeJewelByName(ret, "Pocket-square", EquipmentLocation.POCKET);
normalizeJewelByName(ret, "Locket", EquipmentLocation.POCKET);
// Specific names for pocket items
normalizeJewelByName(ret, "Carved Jewellery Box", EquipmentLocation.POCKET);
String name = ret.getName();
if ("Plains Walker's Symbol".equals(name)) {
ret.setRequiredClass(CharacterClass.BEORNING);
ret.setEquipmentLocation(EquipmentLocation.POCKET);
ret.setSubCategory(null);
} else if ("Talisman of the Tundra Cub".equals(name)) {
ret.setRequiredClass(CharacterClass.LORE_MASTER);
ret.setEquipmentLocation(null);
ret.setSubCategory(CharacterClass.LORE_MASTER.getLabel() + ":Talisman");
}
}
}
EquipmentLocation slot = ret.getEquipmentLocation();
if (slot == null) {
String name = ret.getName();
System.out.println("Slot not found for jewel: " + name);
}
ret.removeProperty(ItemPropertyNames.TULKAS_CATEGORY);
ret.removeProperty(ItemPropertyNames.LEGACY_CATEGORY);
if (ret instanceof Armour) {
Armour armour = (Armour) ret;
int armourValue = armour.getArmourValue();
// Transmutate to item so that further filtering works good
Item newItem = new Item();
newItem.copyFrom(ret);
newItem.getStats().setStat(STAT.ARMOUR, new FixedDecimalsInteger(armourValue));
ret = newItem;
}
}
return ret;
}
Aggregations