use of delta.common.utils.misc.IntegerHolder in project lotro-tools by dmorcellet.
the class ItemsDbLoader method main.
/**
* Main method.
* @param args Not used.
*/
public static void main(String[] args) {
LotroDataSource ds = LotroDataSource.getInstance("lotro");
ObjectsManager<Item> itemsSource = ds.getManager(Item.class);
ItemsManager mgr = ItemsManager.getInstance();
File itemsDir = LotroCoreConfig.getInstance().getItemsDir();
FileFilter fileFilter = new ExtensionPredicate("xml");
File[] itemFiles = itemsDir.listFiles(fileFilter);
if (itemFiles != null) {
HashMap<String, IntegerHolder> other = new HashMap<String, IntegerHolder>();
// HashMap<String,List<String>> itemsByCategory=new HashMap<String,List<String>>();
for (File itemFile : itemFiles) {
// if (nb==10000) break;
String idStr = itemFile.getName();
idStr = idStr.substring(0, idStr.length() - 4);
int id = NumericTools.parseInt(idStr, -1);
if (id != -1) {
System.out.println(id);
Item item = mgr.getItem(Integer.valueOf(id));
// System.out.println(item.dump());
BonusManager bonusMgr = item.getBonusManager();
if (bonusMgr != null) {
// System.out.println(bonusMgr.dump());
int nbBonus = bonusMgr.getNumberOfBonus();
for (int i = 0; i < nbBonus; i++) {
Bonus bonus = bonusMgr.getBonusAt(i);
if (bonus.getBonusType() == BonusType.OTHER) {
String value = (String) bonus.getValue();
IntegerHolder holder = other.get(value);
if (holder == null) {
holder = new IntegerHolder();
other.put(value, holder);
}
holder.setInt(holder.getInt() + 1);
}
}
}
itemsSource.create(item);
}
// nb++;
}
List<String> others = new ArrayList<String>(other.keySet());
Collections.sort(others);
for (String value : others) {
IntegerHolder counter = other.get(value);
System.out.println(value + " -> " + counter);
}
/*
for(Map.Entry<String,IntegerHolder> entry : other.entrySet())
{
System.out.println(entry.getKey()+" -> "+entry.getValue());
}
*/
}
}
use of delta.common.utils.misc.IntegerHolder in project lotro-tools by dmorcellet.
the class ItemStatistics method showStatistics.
private void showStatistics() {
// Items
System.out.println("Items: " + _itemsCount);
// - qualities
System.out.println("- by quality:");
List<ItemQuality> itemQualities = new ArrayList<ItemQuality>(_itemsByQuality.keySet());
Collections.sort(itemQualities, new ItemQualityComparator());
for (ItemQuality itemQuality : itemQualities) {
IntegerHolder count = _itemsByQuality.get(itemQuality);
System.out.println("\t" + itemQuality + ": " + count);
}
// - sub-categories
System.out.println("- by sub-category:");
List<String> itemSubCategories = new ArrayList<String>(_itemsBySubCategory.keySet());
Collections.sort(itemSubCategories);
for (String itemSubCategory : itemSubCategories) {
IntegerHolder count = _itemsBySubCategory.get(itemSubCategory);
System.out.println("\t" + itemSubCategory + ": " + count);
}
// - slot
System.out.println("- by slot:");
List<EquipmentLocation> locations = new ArrayList<EquipmentLocation>(_itemsBySlot.keySet());
Collections.sort(locations, new EquipmentLocationComparator());
for (EquipmentLocation location : locations) {
IntegerHolder count = _itemsBySlot.get(location);
System.out.println("\t" + location + ": " + count);
List<String> names = _itemNamesBySlot.get(location);
if (location != null) {
Collections.sort(names);
for (String name : names) {
System.out.println("\t\t" + name);
}
}
}
// - scaling rules
System.out.println("- by scaling rules:");
List<String> scalingRules = new ArrayList<String>(_scalingRules.keySet());
Collections.sort(scalingRules);
for (String scalingRule : scalingRules) {
List<String> names = _scalingRules.get(scalingRule);
System.out.println("\t" + scalingRule + ": " + names.size());
if (names.size() < 300) {
Collections.sort(names);
for (String name : names) {
System.out.println("\t\t" + name);
}
}
}
// Armours
System.out.println("Armours: " + _armoursCount);
List<ArmourType> armourTypes = new ArrayList<ArmourType>(_armoursByType.keySet());
Collections.sort(armourTypes, new ArmourTypeComparator());
for (ArmourType armourType : armourTypes) {
IntegerHolder count = _armoursByType.get(armourType);
System.out.println("\t" + armourType + ": " + count);
}
// Weapons
System.out.println("Weapons: " + _weaponsCount);
List<WeaponType> weaponTypes = new ArrayList<WeaponType>(_weaponsByType.keySet());
Collections.sort(weaponTypes, new WeaponTypeComparator());
for (WeaponType weaponType : weaponTypes) {
IntegerHolder count = _weaponsByType.get(weaponType);
System.out.println("\t" + weaponType + ": " + count);
}
}
use of delta.common.utils.misc.IntegerHolder in project lotro-tools by dmorcellet.
the class MainMapsCleaner method cleanEmptyCategories.
private void cleanEmptyCategories(MapsManager mapsManager) {
HashMap<Integer, IntegerHolder> markersByCategory = new HashMap<Integer, IntegerHolder>();
List<MapBundle> mapBundles = mapsManager.getMaps();
for (MapBundle mapBundle : mapBundles) {
MarkersManager markersManager = mapBundle.getData();
List<Marker> markers = markersManager.getAllMarkers();
for (Marker marker : markers) {
Category category = marker.getCategory();
if (category != null) {
Integer code = Integer.valueOf(category.getCode());
IntegerHolder counter = markersByCategory.get(code);
if (counter == null) {
counter = new IntegerHolder();
markersByCategory.put(code, counter);
}
counter.increment();
}
}
}
CategoriesManager categoriesManager = mapsManager.getCategories();
List<Integer> sortedCodes = new ArrayList<Integer>(markersByCategory.keySet());
Collections.sort(sortedCodes);
int total = 0;
for (Integer code : sortedCodes) {
IntegerHolder counter = markersByCategory.get(code);
Category category = categoriesManager.getByCode(code.intValue());
System.out.println(category.getLabel() + ": " + counter);
total += counter.getInt();
}
System.out.println("Total: " + total);
// Prepare cleanup
HashSet<Integer> codes2Remove = new HashSet<Integer>();
List<Category> categories = categoriesManager.getAllSortedByCode();
for (Category category : categories) {
Integer key = Integer.valueOf(category.getCode());
if (!sortedCodes.contains(key)) {
codes2Remove.add(key);
}
}
// Perform cleanup
for (Integer code : codes2Remove) {
System.out.println("Removing category: " + categoriesManager.getByCode(code.intValue()).getLabel());
categoriesManager.removeCategory(code.intValue());
}
mapsManager.saveCategories();
}
Aggregations