use of delta.games.lotro.lore.items.stats.ScalingRule in project lotro-companion by dmorcellet.
the class ItemEditionPanelController method configureScaling.
private void configureScaling(Item item) {
ScalingRule rule = Scaling.getScalingRule(item);
if (rule != null) {
// Min level
List<Integer> minLevels = rule.getRequiredLevels();
for (Integer minLevel : minLevels) {
_minLevel.addItem(minLevel, minLevel.toString());
}
ItemSelectionListener<Integer> listenerRequiredLevel = new ItemSelectionListener<Integer>() {
@Override
public void itemSelected(Integer requiredLevel) {
selectRequiredLevel(requiredLevel);
}
};
_minLevel.addListener(listenerRequiredLevel);
// Item level
List<Integer> itemLevels = rule.getItemLevels();
for (Integer itemLevel : itemLevels) {
_itemLevel.addItem(itemLevel, itemLevel.toString());
}
ItemSelectionListener<Integer> listener = new ItemSelectionListener<Integer>() {
@Override
public void itemSelected(Integer itemLevel) {
selectItemLevel(itemLevel);
}
};
_itemLevel.addListener(listener);
} else {
// Min level
_minLevel.addEmptyItem("");
Integer minLevel = item.getMinLevel();
if (minLevel != null) {
_minLevel.addItem(minLevel, minLevel.toString());
}
// Item level
_itemLevel.addEmptyItem("");
Integer itemLevel = item.getItemLevel();
if (itemLevel != null) {
_itemLevel.addItem(itemLevel, itemLevel.toString());
}
}
}
use of delta.games.lotro.lore.items.stats.ScalingRule 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);
}
}
}
}
Aggregations