use of delta.games.lotro.lore.items.Item in project lotro-tools by dmorcellet.
the class EssenceStatsInjector method findEssences.
private List<Item> findEssences(String[] fields, boolean hasId, HashMap<Integer, Item> essences) {
List<Item> ret = new ArrayList<Item>();
Integer id = null;
if (hasId) {
id = NumericTools.parseInteger(fields[0]);
}
int nameIndex = NAME_INDEX + (hasId ? 1 : 0);
String name = fields[nameIndex];
if (name.startsWith("-")) {
name = name.substring(1).trim();
}
for (Item essence : essences.values()) {
if (id != null) {
if (id.intValue() == essence.getIdentifier()) {
ret.add(essence);
return ret;
}
}
if (name.equals(essence.getName())) {
ret.add(essence);
}
}
return ret;
}
use of delta.games.lotro.lore.items.Item in project lotro-tools by dmorcellet.
the class EssenceStatsInjector method sortByTier.
private HashMap<Integer, HashMap<Integer, Item>> sortByTier(List<Item> essences) {
List<Integer> tiers = loadTiers();
HashMap<Integer, HashMap<Integer, Item>> essencesByTier = new HashMap<Integer, HashMap<Integer, Item>>();
int nbEssences = essences.size();
int nbTierSpecifications = tiers.size();
if (nbEssences != nbTierSpecifications) {
System.err.println("Warning! Bad tier specifications: nbEssences=" + nbEssences + "!=nbTierSpecifications" + nbTierSpecifications);
}
for (int i = 0; i < nbEssences; i++) {
Item item = essences.get(i);
Integer tier = (i < nbTierSpecifications) ? tiers.get(i) : null;
// System.out.println(item.getName()+" => "+tier);
if (tier != null) {
String category = "Essence:Tier" + tier;
item.setSubCategory(category);
} else {
// Unspecified
tier = Integer.valueOf(-1);
}
HashMap<Integer, Item> essencesOfTier = essencesByTier.get(tier);
if (essencesOfTier == null) {
essencesOfTier = new HashMap<Integer, Item>();
essencesByTier.put(tier, essencesOfTier);
}
essencesOfTier.put(Integer.valueOf(item.getIdentifier()), item);
}
return essencesByTier;
}
use of delta.games.lotro.lore.items.Item in project lotro-tools by dmorcellet.
the class EssenceStatsInjector method handleTier.
private void handleTier(int tier, HashMap<Integer, Item> essences) {
URL url = URLTools.getFromClassPath("tier" + tier + ".txt", EssenceStatsInjector.class.getPackage());
if (url != null) {
TextFileReader reader = new TextFileReader(url, EncodingNames.UTF_8);
List<String> lines = TextUtils.readAsLines(reader);
boolean hasId = lines.get(0).startsWith("ID");
lines.remove(0);
HashSet<Integer> unmanaged = new HashSet<Integer>();
unmanaged.addAll(essences.keySet());
LotroPlanTable table = new LotroPlanTable(STATS);
for (String line : lines) {
String[] fields = StringSplitter.split(line, '\t');
if (fields.length > 2) {
List<Item> items = findEssences(fields, hasId, essences);
for (Item item : items) {
if (hasId) {
String[] newFields = new String[fields.length - 1];
for (int i = 1; i < fields.length; i++) {
newFields[i - 1] = fields[i];
if (newFields[i - 1].equals(CELLS[i])) {
newFields[i - 1] = "";
}
}
fields = newFields;
}
unmanaged.remove(Integer.valueOf(item.getIdentifier()));
// Item level
int itemLevel = NumericTools.parseInt(fields[ITEM_LEVEL_INDEX], -1);
if (itemLevel != -1) {
item.setItemLevel(Integer.valueOf(itemLevel));
}
// Notes
if (fields.length > NOTES_INDEX) {
String notes = fields[NOTES_INDEX].trim();
if (notes.length() > 0) {
item.getBonus().add(notes);
}
}
// Tier
item.setSubCategory("Essence:Tier" + tier);
// Stats
ItemStatsProvider provider = table.loadStats(fields);
BasicStatsSet stats = item.getStats();
stats.setStats(provider.getStats(itemLevel));
}
if (items.size() == 0) {
System.out.println("Essence not found: " + fields[0]);
}
} else {
if (!line.startsWith("#")) {
System.err.println("Bad fields count: " + line);
}
}
}
if (unmanaged.size() > 0) {
System.out.println(unmanaged + " unmanaged essences:");
for (Integer id : unmanaged) {
Item essence = essences.get(id);
System.out.println("\t" + essence);
}
}
}
}
use of delta.games.lotro.lore.items.Item in project lotro-tools by dmorcellet.
the class MainItemStatsSheetTemplateGenerator method getEssences.
private List<Item> getEssences(List<Item> items, int tier) {
List<Item> ret = new ArrayList<Item>();
String expectedCategory = "Essence:Tier" + tier;
for (Item item : items) {
String category = item.getSubCategory();
if (expectedCategory.equals(category)) {
ret.add(item);
}
}
return ret;
}
use of delta.games.lotro.lore.items.Item in project lotro-tools by dmorcellet.
the class MainItemStatsSheetTemplateGenerator method doIt.
private void doIt() {
File newFile = new File("data\\items\\items_filtered.xml").getAbsoluteFile();
List<Item> newItems = ItemSaxParser.parseItemsFile(newFile);
List<Item> essences = getEssences(newItems, 10);
buildTemplate(essences);
}
Aggregations