use of delta.games.lotro.lore.crafting.recipes.CraftingResult in project lotro-tools by dmorcellet.
the class ResolveItemLinksInRecipes method handleRecipes.
private void handleRecipes(ItemsResolver resolver) {
// Load recipes
RecipesManager rMgr = RecipesManager.getInstance();
File recipesDir = LotroCoreConfig.getInstance().getRecipesDir();
FileFilter fileFilter = new ExtensionPredicate("xml");
File[] recipeFiles = recipesDir.listFiles(fileFilter);
if (recipeFiles != null) {
Set<String> missingKeys = new HashSet<String>();
for (File recipeFile : recipeFiles) {
String idStr = recipeFile.getName();
idStr = idStr.substring(0, idStr.length() - 4);
int id = NumericTools.parseInt(idStr, -1);
if (id != -1) {
Recipe recipe = rMgr.getRecipe(Integer.valueOf(id));
List<Ingredient> ingredients = recipe.getIngredients();
for (Ingredient ingredient : ingredients) {
ItemReference itemRef = ingredient.getItem();
handleItemRef(resolver, missingKeys, itemRef);
}
/*
ItemReference scroll=recipe.getRecipeScroll();
if (scroll!=null)
{
handleItemRef(ids,missingKeys,scroll);
}
*/
List<RecipeVersion> versions = recipe.getVersions();
for (RecipeVersion version : versions) {
CraftingResult regular = version.getRegular();
if (regular != null) {
ItemReference ref = regular.getItem();
handleItemRef(resolver, missingKeys, ref);
}
CraftingResult critical = version.getCritical();
if (critical != null) {
ItemReference ref = critical.getItem();
handleItemRef(resolver, missingKeys, ref);
}
}
}
}
List<String> sortedKeys = new ArrayList<String>(missingKeys);
Collections.sort(sortedKeys);
for (String missingKey : sortedKeys) {
System.out.println("Missing : " + missingKey);
}
System.out.println("Missing : " + sortedKeys.size());
}
}
use of delta.games.lotro.lore.crafting.recipes.CraftingResult in project lotro-tools by dmorcellet.
the class RecipePageParser method parseResultItem.
private CraftingResult parseResultItem(Element resultRow, boolean critical) {
CraftingResult result = new CraftingResult();
result.setCriticalResult(critical);
ItemReference itemRef = new ItemReference();
result.setItem(itemRef);
Element ingredientIcon = JerichoHtmlUtils.findElementByTagNameAndAttributeValue(resultRow, HTMLElementName.TD, "class", "resicon");
if (ingredientIcon != null) {
Element img = JerichoHtmlUtils.findElementByTagName(ingredientIcon, HTMLElementName.IMG);
if (img != null) {
String itemIcon = img.getAttributeValue("src");
// System.out.println("Icon: "+itemIcon);
itemRef.setIcon(itemIcon);
}
}
Element ingredientQuantity = JerichoHtmlUtils.findElementByTagNameAndAttributeValue(resultRow, HTMLElementName.TD, "class", "resquan");
if (ingredientQuantity != null) {
String quantityStr = CharacterReference.decodeCollapseWhiteSpace(ingredientQuantity.getContent());
int quantity = parseQuantityString(quantityStr);
// System.out.println("Quantity: "+quantity);
result.setQuantity(quantity);
}
Element ingredientName = JerichoHtmlUtils.findElementByTagNameAndAttributeValue(resultRow, HTMLElementName.TD, "class", "resname");
if (ingredientName != null) {
Element a = JerichoHtmlUtils.findElementByTagName(ingredientName, HTMLElementName.A);
String itemURL = a.getAttributeValue("href");
String itemId = extractItemIdentifier(itemURL);
itemRef.setItemKey(itemId);
String itemName = CharacterReference.decodeCollapseWhiteSpace(a.getContent());
itemRef.setName(itemName);
}
// System.out.println(critical?"Critical result":"Regular result");
return result;
}
use of delta.games.lotro.lore.crafting.recipes.CraftingResult in project lotro-tools by dmorcellet.
the class RecipePageParser method parseResults.
private List<RecipeVersion> parseResults(Element resultsSection) {
/*
<tr class="resultrow"> // or "resultrow critical"
<td class="resicon"><a href="/wiki/Tool:Ancient_Steel_Scholar's_Glass"><img class="icon" rel="" src="http://content.turbine.com/sites/lorebook.lotro.com/images/icons/item/tool/eq_craft_tool_rare_scholars_glass_tier5.png"></img></a></td>
<td class="restype">regular success</td> // or critical success
<td class="resquan">x1</td>
<td class="resname"><a href="/wiki/Tool:Ancient_Steel_Scholar's_Glass"></a></td></tr>
*/
List<RecipeVersion> versions = new ArrayList<RecipeVersion>();
RecipeVersion version = new RecipeVersion();
versions.add(version);
List<Element> rows = resultsSection.getAllElements(HTMLElementName.TR);
for (Element row : rows) {
StartTag tag = row.getStartTag();
String value = tag.getAttributeValue("class");
if ("resultrow".equals(value)) {
Element header = JerichoHtmlUtils.findElementByTagName(row, HTMLElementName.TH);
if (header != null) {
version = new RecipeVersion();
versions.add(version);
// System.out.println("OR");
} else {
CraftingResult regular = parseResultItem(row, false);
version.setRegular(regular);
}
} else if ("resultrow critical".equals(value)) {
CraftingResult critical = parseResultItem(row, true);
version.setCritical(critical);
}
}
return versions;
}
Aggregations