use of delta.games.lotro.character.stats.BasicStatsSet in project lotro-tools by dmorcellet.
the class ScalingParametersFinder method findScalingParameters.
private void findScalingParameters(Item item) {
BasicStatsSet stats = item.getStats();
if (stats.getStatsCount() == 0) {
System.err.println("Cannot manage item: " + item + ": no stats");
return;
}
Integer itemLevel = item.getItemLevel();
if (itemLevel == null) {
System.err.println("Cannot manage item: " + item + ": no item level");
return;
}
SliceCountFinder converter = _converters.get(itemLevel);
if (converter == null) {
converter = new SliceCountFinder(itemLevel.intValue());
_converters.put(itemLevel, converter);
}
if (item instanceof Armour) {
Armour armour = (Armour) item;
int armourValue = armour.getArmourValue();
stats.setStat(STAT.ARMOUR, new FixedDecimalsInteger(armourValue));
}
SlicesBasedItemStatsProvider provider = new SlicesBasedItemStatsProvider();
for (STAT stat : stats.getStats()) {
FixedDecimalsInteger value = stats.getStat(stat);
int statValue = value.getInternalValue();
ItemStatSliceData slice = null;
// Specific case for armour
if (stat == STAT.ARMOUR) {
ArmourDescriptionFinder armourConverter = _armourConverters.get(itemLevel);
if (armourConverter == null) {
armourConverter = new ArmourDescriptionFinder(itemLevel.intValue(), false);
_armourConverters.put(itemLevel, armourConverter);
}
ArmourType armourType = ((Armour) item).getArmourType();
EquipmentLocation location = item.getEquipmentLocation();
ItemQuality quality = item.getQuality();
String label = armourConverter.getArmourDescription(statValue, armourType, location, quality);
if (label != null) {
slice = new ItemStatSliceData(stat, null, label);
} else {
System.err.println("Armour not found: " + statValue + " for item " + item + ", quality=" + item.getQuality() + ", slot=" + item.getEquipmentLocation() + ", type=" + armourType);
}
} else if ((stat == STAT.PARRY_PERCENTAGE) || (stat == STAT.RANGED_DEFENCE_PERCENTAGE)) {
// Skip... will be put as raw stats
} else // Other stats
{
Float sliceCount = converter.getSliceCount(stat, statValue);
if (sliceCount != null) {
slice = new ItemStatSliceData(stat, sliceCount, null);
} else {
System.err.println("Stat not found: " + stat + "=" + statValue + " for item " + item + ", quality=" + item.getQuality() + ", slot=" + item.getEquipmentLocation());
}
}
if (slice != null) {
provider.addSlice(slice);
} else {
provider.setStat(stat, value);
}
}
stats.removeStat(STAT.ARMOUR);
String slices = provider.toPersistableString();
item.setProperty(ItemPropertyNames.FORMULAS, slices);
item.setProperty(ItemPropertyNames.SCALING, _scalingId);
}
use of delta.games.lotro.character.stats.BasicStatsSet in project lotro-companion by dmorcellet.
the class EssencesSummary method update.
/**
* Update counts.
*/
public void update() {
_count.clear();
_essencesCount = 0;
_slotsCount = 0;
_stats.clear();
CharacterEquipment equipment = _toon.getEquipment();
for (EQUIMENT_SLOT slot : EQUIMENT_SLOT.values()) {
Item item = equipment.getItemForSlot(slot);
if (item != null) {
EssencesSet essences = item.getEssences();
int nbSlots = item.getEssenceSlots();
int nbEssences = (essences != null) ? essences.getSize() : 0;
int slotsCount = Math.max(nbSlots, nbEssences);
// Increment total essence slot count
_slotsCount += slotsCount;
if (essences != null) {
for (int i = 0; i < nbEssences; i++) {
Item essence = essences.getEssence(i);
if (essence != null) {
// Increment by-essence count
Integer essenceId = Integer.valueOf(essence.getIdentifier());
EssenceCount count = _count.get(essenceId);
if (count == null) {
count = new EssenceCount(essence);
_count.put(essenceId, count);
}
count.increment();
// Increment essences count
_essencesCount++;
BasicStatsSet essenceStats = essence.getStats();
_stats.addStats(essenceStats);
}
}
}
}
}
}
use of delta.games.lotro.character.stats.BasicStatsSet in project lotro-companion by dmorcellet.
the class CharacterDataWindowController method eventOccurred.
/**
* Handle character events.
* @param event Source event.
*/
@Override
public void eventOccurred(CharacterEvent event) {
CharacterEventType type = event.getType();
if (type == CharacterEventType.CHARACTER_DATA_UPDATED) {
CharacterData data = event.getToonData();
if (data == _data) {
// Compute new stats
CharacterStatsComputer computer = new CharacterStatsComputer();
BasicStatsSet stats = computer.getStats(data);
BasicStatsSet toonStats = _data.getStats();
toonStats.clear();
toonStats.setStats(stats);
// Update stats display
_statsController.update();
// Update buffs display
_buffsController.update();
}
}
if (type == CharacterEventType.CHARACTER_SUMMARY_UPDATED) {
CharacterFile toonFile = event.getToonFile();
if (toonFile == _toonFile) {
// Update sex
_attrsController.updateSexDisplay();
}
}
}
use of delta.games.lotro.character.stats.BasicStatsSet in project lotro-companion by dmorcellet.
the class CharacterStatsSummaryPanelController method doDetails.
private void doDetails() {
DetailedCharacterStatsWindowController detailsStatsController = getDetailsController();
if (detailsStatsController == null) {
detailsStatsController = new DetailedCharacterStatsWindowController(_parent, _toon);
_childControllers.registerWindow(detailsStatsController);
BasicStatsSet referenceStats = new BasicStatsSet(_toon.getStats());
detailsStatsController.setStats(referenceStats, _toon.getStats());
detailsStatsController.getWindow().setLocationRelativeTo(_parent.getWindow());
}
detailsStatsController.bringToFront();
}
use of delta.games.lotro.character.stats.BasicStatsSet in project lotro-companion by dmorcellet.
the class StatValuesPanelController method update.
/**
* Update this panel with new stats.
* @param values Stats to display.
*/
public void update(BasicStatsSet values) {
_values = new BasicStatsSet(values);
_deltaValues.clear();
update();
}
Aggregations