use of delta.games.lotro.lore.items.Item in project lotro-tools by dmorcellet.
the class ItemsAndIconsManager method loadItems.
private void loadItems(String key) {
System.out.println("Loading item [" + key + "]");
File itemsDir = LotroCoreConfig.getInstance().getItemsDir();
if (!itemsDir.exists()) {
itemsDir.mkdirs();
}
key = Escapes.escapeIdentifier(key);
String url = "http://lorebook.lotro.com/wiki/" + key;
ItemPageParser parser = new ItemPageParser();
List<Item> items = parser.parseItemPage(url);
if ((items != null) && (items.size() > 0)) {
ItemsManager itemsManager = ItemsManager.getInstance();
for (Item item : items) {
System.out.println(item.dump());
int id = item.getIdentifier();
if (id != 0) {
itemsManager.writeItemFile(item);
} else {
_logger.warn("Item [" + key + "]: identifier=0!");
}
}
} else {
_logger.error("Cannot parse item [" + key + "] at URL [" + url + "]!");
}
}
use of delta.games.lotro.lore.items.Item 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.games.lotro.lore.items.Item in project lotro-tools by dmorcellet.
the class IconsDbBuilder method doIt.
private void doIt() {
_iconsDbDir.mkdirs();
File toFile = new File("items.xml").getAbsoluteFile();
HashMap<Integer, Item> items = loadItemsFile(toFile);
System.out.println(items.size());
for (Integer id : items.keySet()) {
Item item = items.get(id);
String iconId = item.getProperty(ItemPropertyNames.ICON_ID);
_iconsIds.add(iconId);
String backgroundIconId = item.getProperty(ItemPropertyNames.BACKGROUND_ICON_ID);
_backgroundIconsIds.add(backgroundIconId);
String key = iconId + "-" + backgroundIconId;
List<Integer> list = _iconIds2Ids.get(key);
if (list == null) {
list = new ArrayList<Integer>();
_iconIds2Ids.put(key, list);
}
list.add(id);
}
System.out.println(_iconIds2Ids.size());
System.out.println(_iconsIds.size());
System.out.println(_backgroundIconsIds.size());
for (Map.Entry<String, List<Integer>> entry : _iconIds2Ids.entrySet()) {
handleIconList(items, entry.getKey(), entry.getValue());
/*
int size=entry.getValue().size();
if (size > 10)
{
System.out.println(entry.getKey() + " -> " + size);
}
*/
}
System.out.println("Nb items with icon: " + _nbItemsWithIcon);
System.out.println("Nb items with no icon: " + _nbItemsWithNoIcon);
System.out.println("Nb icons missing: " + _nbDifferentIconsMissing);
// System.out.println(_iconIds2Ids);
}
use of delta.games.lotro.lore.items.Item in project lotro-tools by dmorcellet.
the class ScalableItemsSamplesLoader method loadTable.
/**
* Load items from a table.
* @param filename Name of file to read.
* @return A list of items.
*/
public List<Item> loadTable(String filename) {
URL url = URLTools.getFromClassPath(filename, ScalableItemsSamplesLoader.class.getPackage());
TextFileReader reader = new TextFileReader(url, EncodingNames.UTF_8);
List<String> lines = TextUtils.readAsLines(reader);
List<Item> items = new ArrayList<Item>();
lines.remove(0);
for (String line : lines) {
Item item = buildItemFromLine(line);
if (item != null) {
items.add(item);
}
}
return items;
}
use of delta.games.lotro.lore.items.Item in project lotro-tools by dmorcellet.
the class LotroPlanItemsDbLoader method doIt.
/**
* Do the job.
*/
public void doIt() {
_merger = new ItemsMerger();
List<Item> items = loadTable("itemsdb.txt");
_merger.registerItems(items);
for (String tableName : NAMES) {
handleAdditionalTable(tableName);
}
File toFile = new File("data/items/tmp/itemsdb.xml").getAbsoluteFile();
items = _merger.getItems();
setScalingRules(items);
ItemXMLWriter.writeItemsFile(toFile, items);
// List<Integer> ids=new ArrayList<Integer>(_failedItems.keySet());
// new BuildItemsDbForIcons().buildDb(_failedItems,ids);
}
Aggregations