Search in sources :

Example 1 with ExtensionPredicate

use of delta.common.utils.files.filter.ExtensionPredicate in project lotro-tools by dmorcellet.

the class QuestsIndexBuilder method doIt.

/**
 * Do build quests index.
 * @return <code>true</code> if it was done, <code>false</code> otherwise.
 */
public boolean doIt() {
    boolean ret = false;
    if (_questsDir.exists()) {
        QuestsIndex index = new QuestsIndex();
        ExtensionPredicate extFilter = new ExtensionPredicate(".xml");
        File[] questFiles = _questsDir.listFiles(extFilter);
        if (questFiles != null) {
            QuestXMLParser parser = new QuestXMLParser();
            for (File questFile : questFiles) {
                QuestDescription q = parser.parseXML(questFile);
                String category = q.getCategory();
                String key = q.getKey();
                String title = q.getTitle();
                int id = q.getIdentifier();
                index.addQuest(category, id, key, title);
            }
            QuestsIndexWriter writer = new QuestsIndexWriter();
            ret = writer.write(_indexFile, index, EncodingNames.UTF_8);
        }
    }
    return ret;
}
Also used : QuestDescription(delta.games.lotro.lore.quests.QuestDescription) QuestXMLParser(delta.games.lotro.lore.quests.io.xml.QuestXMLParser) ExtensionPredicate(delta.common.utils.files.filter.ExtensionPredicate) QuestsIndex(delta.games.lotro.lore.quests.index.QuestsIndex) File(java.io.File) QuestsIndexWriter(delta.games.lotro.lore.quests.index.io.xml.QuestsIndexWriter)

Example 2 with ExtensionPredicate

use of delta.common.utils.files.filter.ExtensionPredicate in project lotro-tools by dmorcellet.

the class RecipesIndexBuilder method doIt.

/**
 * Do build recipes index.
 * @return <code>true</code> if it was done, <code>false</code> otherwise.
 */
public boolean doIt() {
    boolean ret = false;
    if (_recipesDir.exists()) {
        RecipesIndex index = new RecipesIndex();
        ExtensionPredicate extFilter = new ExtensionPredicate(".xml");
        File[] recipeFiles = _recipesDir.listFiles(extFilter);
        if (recipeFiles != null) {
            RecipeXMLParser parser = new RecipeXMLParser();
            for (File recipeFile : recipeFiles) {
                Recipe recipe = parser.parseXML(recipeFile);
                String profession = recipe.getProfession();
                String key = recipe.getKey();
                String name = recipe.getName();
                // int id=recipe.getIdentifier();
                int tier = recipe.getTier();
                index.addRecipe(key, name, profession, tier);
            }
            RecipesIndexXMLWriter writer = new RecipesIndexXMLWriter();
            ret = writer.write(_indexFile, index, EncodingNames.UTF_8);
        }
    }
    return ret;
}
Also used : RecipesIndexXMLWriter(delta.games.lotro.lore.crafting.recipes.index.io.xml.RecipesIndexXMLWriter) RecipesIndex(delta.games.lotro.lore.crafting.recipes.index.RecipesIndex) Recipe(delta.games.lotro.lore.crafting.recipes.Recipe) ExtensionPredicate(delta.common.utils.files.filter.ExtensionPredicate) RecipeXMLParser(delta.games.lotro.lore.crafting.recipes.io.xml.RecipeXMLParser) File(java.io.File)

Example 3 with ExtensionPredicate

use of delta.common.utils.files.filter.ExtensionPredicate in project lotro-tools by dmorcellet.

the class UpdateItemDefinitions method main.

/**
 * @param args
 */
public static void main(String[] args) {
    ItemsManager mgr = ItemsManager.getInstance();
    File itemsDir = LotroCoreConfig.getInstance().getItemsDir();
    FileFilter fileFilter = new ExtensionPredicate("xml");
    File[] itemFiles = itemsDir.listFiles(fileFilter);
    if (itemFiles != null) {
        for (File itemFile : itemFiles) {
            String name = itemFile.getName();
            name = name.substring(0, name.length() - 4);
            int id = NumericTools.parseInt(name, -1);
            if (id != -1) {
                itemFile.delete();
                mgr.getItem(Integer.valueOf(id));
            }
        }
    }
}
Also used : ItemsManager(delta.games.lotro.lore.items.ItemsManager) ExtensionPredicate(delta.common.utils.files.filter.ExtensionPredicate) FileFilter(java.io.FileFilter) File(java.io.File)

Example 4 with ExtensionPredicate

use of delta.common.utils.files.filter.ExtensionPredicate 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());
      }
      */
    }
}
Also used : ItemsManager(delta.games.lotro.lore.items.ItemsManager) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ExtensionPredicate(delta.common.utils.files.filter.ExtensionPredicate) Bonus(delta.games.lotro.lore.items.bonus.Bonus) LotroDataSource(delta.games.lotro.lore.sql.LotroDataSource) Item(delta.games.lotro.lore.items.Item) IntegerHolder(delta.common.utils.misc.IntegerHolder) BonusManager(delta.games.lotro.lore.items.bonus.BonusManager) FileFilter(java.io.FileFilter) File(java.io.File)

Example 5 with ExtensionPredicate

use of delta.common.utils.files.filter.ExtensionPredicate in project lotro-tools by dmorcellet.

the class ItemsConcat method main.

/**
 * Main method.
 * @param args Not used.
 */
public static void main(String[] args) {
    System.out.println("Concatenation of legacy items into one file...");
    File itemsDir = new File("d:\\dam\\tmp\\items");
    FileFilter fileFilter = new ExtensionPredicate("xml");
    File[] itemFiles = itemsDir.listFiles(fileFilter);
    if (itemFiles != null) {
        // BonusConverter converter=new BonusConverter();
        ItemXMLParser parser = new ItemXMLParser();
        List<Item> itemsList = new ArrayList<Item>();
        for (File itemFile : itemFiles) {
            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 = parser.parseXML(itemFile);
                /*
          List<String> bonuses=item.getBonus();
          if (bonuses.size()>0)
          {
            RawBonusParser bonusParser=new RawBonusParser();
            BonusManager bonusMgr=bonusParser.build(bonuses);
            if (bonusParser.hasWarn())
            {
              String name=item.getName();
              System.out.println("Item: "+id+", name="+name);
              for(String bonus : bonuses)
              {
                System.out.println("\t"+bonus);
              }
            }
            if (bonusMgr!=null)
            {
              BasicStatsSet stats=converter.getStats(bonusMgr);
              item.getStats().setStats(stats);
            }
          }
          */
                item.setIdentifier(id);
                itemsList.add(item);
            }
        }
        File toFile = new File("itemsLegacy.xml").getAbsoluteFile();
        ItemXMLWriter.writeItemsFile(toFile, itemsList);
    }
}
Also used : Item(delta.games.lotro.lore.items.Item) ItemXMLParser(delta.games.lotro.lore.items.io.xml.ItemXMLParser) ArrayList(java.util.ArrayList) ExtensionPredicate(delta.common.utils.files.filter.ExtensionPredicate) FileFilter(java.io.FileFilter) File(java.io.File)

Aggregations

ExtensionPredicate (delta.common.utils.files.filter.ExtensionPredicate)6 File (java.io.File)6 FileFilter (java.io.FileFilter)4 ArrayList (java.util.ArrayList)3 Recipe (delta.games.lotro.lore.crafting.recipes.Recipe)2 Item (delta.games.lotro.lore.items.Item)2 ItemsManager (delta.games.lotro.lore.items.ItemsManager)2 IntegerHolder (delta.common.utils.misc.IntegerHolder)1 CraftingResult (delta.games.lotro.lore.crafting.recipes.CraftingResult)1 Ingredient (delta.games.lotro.lore.crafting.recipes.Ingredient)1 ItemReference (delta.games.lotro.lore.crafting.recipes.ItemReference)1 RecipeVersion (delta.games.lotro.lore.crafting.recipes.RecipeVersion)1 RecipesManager (delta.games.lotro.lore.crafting.recipes.RecipesManager)1 RecipesIndex (delta.games.lotro.lore.crafting.recipes.index.RecipesIndex)1 RecipesIndexXMLWriter (delta.games.lotro.lore.crafting.recipes.index.io.xml.RecipesIndexXMLWriter)1 RecipeXMLParser (delta.games.lotro.lore.crafting.recipes.io.xml.RecipeXMLParser)1 Bonus (delta.games.lotro.lore.items.bonus.Bonus)1 BonusManager (delta.games.lotro.lore.items.bonus.BonusManager)1 ItemXMLParser (delta.games.lotro.lore.items.io.xml.ItemXMLParser)1 QuestDescription (delta.games.lotro.lore.quests.QuestDescription)1