use of delta.games.lotro.lore.crafting.recipes.RecipeVersion 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.RecipeVersion in project lotro-tools by dmorcellet.
the class RecipePageParser method parseRecipeSection.
private Recipe parseRecipeSection(Element recipeSection) {
Recipe ret = null;
try {
_recipe = new Recipe();
// Element mainIconElement=JerichoHtmlUtils.findElementByTagNameAndAttributeValue(recipeSection,HTMLElementName.DIV,"class","mainicon");
List<Element> officialSections = JerichoHtmlUtils.findElementsByTagNameAndAttributeValue(recipeSection, HTMLElementName.DIV, "class", "officialsection");
// 1 - summary
// 2 - ingredients
// 3 - results
int nbSections = officialSections.size();
if (nbSections != 3) {
System.out.println("Warning: found " + nbSections + " sections!");
}
Element summarySection = officialSections.get(0);
parseRecipeSummary(summarySection);
// System.out.println("Ingredients:");
Element ingredientsSection = officialSections.get(1);
List<Ingredient> ingredients = parseIngredients(ingredientsSection);
_recipe.setIngredients(ingredients);
// System.out.println("Results:");
Element resultsSection = officialSections.get(2);
List<RecipeVersion> results = parseResults(resultsSection);
_recipe.setVersions(results);
ret = _recipe;
_recipe = null;
} catch (Exception e) {
ret = null;
_logger.error("Recipe [" + _key + "]. Cannot parse recipe section!", e);
}
return ret;
}
use of delta.games.lotro.lore.crafting.recipes.RecipeVersion 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