Search in sources :

Example 1 with QuestDescription

use of delta.games.lotro.lore.quests.QuestDescription in project lotro-companion by dmorcellet.

the class QuestsCompletionStats method loadQuestIdentifiers.

private void loadQuestIdentifiers() {
    QuestsManager qm = QuestsManager.getInstance();
    QuestsIndex index = qm.getIndex();
    if (index != null) {
        QuestCategory category = index.getCategory(_category);
        if (category != null) {
            QuestSummary[] summaries = category.getQuests();
            for (QuestSummary summary : summaries) {
                int id = summary.getIdentifier();
                QuestDescription q = qm.getQuest(id);
                if (q != null) {
                    boolean useIt = true;
                    if (USE_CLASS_RESTRICTIONS) {
                        List<String> classes = q.getRequiredClasses();
                        if ((classes != null) && (classes.size() > 0)) {
                            CharacterClass cClass = _character.getCharacterClass();
                            String className = cClass.getKey();
                            if (classes.contains(className)) {
                                useIt = true;
                            } else {
                                String key = q.getKey();
                                if (_logger.isInfoEnabled()) {
                                    _logger.info("Ignored quest [" + key + "]. Class=" + className + ", Required:" + classes);
                                }
                                useIt = false;
                            }
                        }
                    }
                    if (USE_RACE_RESTRICTIONS) {
                        List<String> races = q.getRequiredRaces();
                        if ((races != null) && (races.size() > 0)) {
                            Race cRace = _character.getRace();
                            String raceName = cRace.getLabel();
                            if (races.contains(raceName)) {
                                useIt = true;
                            } else {
                                String key = q.getKey();
                                if (_logger.isInfoEnabled()) {
                                    _logger.info("Ignored quest [" + key + "]. Race=" + raceName + ", Required:" + races);
                                }
                                useIt = false;
                            }
                        }
                    }
                    if (!USE_INSTANCES) {
                        boolean instanced = q.isInstanced();
                        if (instanced) {
                            useIt = false;
                        }
                    }
                    if (useIt) {
                        _expectedIds.add(Integer.valueOf(id));
                    }
                }
            }
            _nbExpectedQuests = _expectedIds.size();
        }
    }
}
Also used : QuestDescription(delta.games.lotro.lore.quests.QuestDescription) QuestsManager(delta.games.lotro.lore.quests.QuestsManager) Race(delta.games.lotro.common.Race) QuestsIndex(delta.games.lotro.lore.quests.index.QuestsIndex) QuestCategory(delta.games.lotro.lore.quests.index.QuestCategory) QuestSummary(delta.games.lotro.lore.quests.index.QuestSummary) CharacterClass(delta.games.lotro.common.CharacterClass)

Example 2 with QuestDescription

use of delta.games.lotro.lore.quests.QuestDescription in project lotro-companion by dmorcellet.

the class VirtuesStats method parseQuestItems.

private void parseQuestItems(List<CharacterLogItem> items) {
    QuestsManager qm = QuestsManager.getInstance();
    for (CharacterLogItem item : items) {
        Integer id = item.getResourceIdentifier();
        if (id != null) {
            QuestDescription quest = qm.getQuest(id.intValue());
            if (quest != null) {
                Rewards rewards = quest.getQuestRewards();
                handleRewards("Quest:" + id, rewards);
            }
        }
    }
}
Also used : QuestDescription(delta.games.lotro.lore.quests.QuestDescription) QuestsManager(delta.games.lotro.lore.quests.QuestsManager) Rewards(delta.games.lotro.common.Rewards) CharacterLogItem(delta.games.lotro.character.log.CharacterLogItem)

Example 3 with QuestDescription

use of delta.games.lotro.lore.quests.QuestDescription 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 4 with QuestDescription

use of delta.games.lotro.lore.quests.QuestDescription in project lotro-tools by dmorcellet.

the class QuestsItemsLoader method doIt.

private void doIt() {
    List<QuestDescription> storage = new ArrayList<QuestDescription>();
    QuestsManager qm = QuestsManager.getInstance();
    QuestsIndex index = qm.getIndex();
    if (index != null) {
        String[] categories = index.getCategories();
        System.out.println(Arrays.deepToString(categories));
        for (String category : categories) {
            QuestCategory c = index.getCategory(category);
            QuestSummary[] quests = c.getQuests();
            int indexQ = 0;
            for (QuestSummary questSum : quests) {
                int id = questSum.getIdentifier();
                QuestDescription q = qm.getQuest(id);
                handleQuest(indexQ, q);
                storage.add(q);
                indexQ++;
            }
        }
        System.out.println("Resolved: " + _resolved + ", missed: " + _missed);
        writeQuestsDatabase(storage);
    } else {
        _logger.error("Cannot gets quests index file!");
    }
}
Also used : QuestDescription(delta.games.lotro.lore.quests.QuestDescription) QuestsManager(delta.games.lotro.lore.quests.QuestsManager) ArrayList(java.util.ArrayList) QuestsIndex(delta.games.lotro.lore.quests.index.QuestsIndex) QuestCategory(delta.games.lotro.lore.quests.index.QuestCategory) QuestSummary(delta.games.lotro.lore.quests.index.QuestSummary)

Example 5 with QuestDescription

use of delta.games.lotro.lore.quests.QuestDescription in project lotro-tools by dmorcellet.

the class QuestsLoader method loadQuestsDefinition.

/**
 * Load quest definitions.
 * @param key Quest key.
 * @return Number of loaded quests.
 */
private int loadQuestsDefinition(String key) {
    int nbQuests = 0;
    QuestPageParser parser = new QuestPageParser();
    String url = urlFromIdentifier(key);
    List<QuestDescription> quests = parser.parseQuestPage(url);
    if ((quests != null) && (quests.size() > 0)) {
        QuestXMLWriter writer = new QuestXMLWriter();
        for (QuestDescription quest : quests) {
            int id = quest.getIdentifier();
            String fileName = String.valueOf(id) + ".xml";
            File questFile = new File(_questsDir, fileName);
            if (!questFile.getParentFile().exists()) {
                questFile.getParentFile().mkdirs();
            }
            boolean ok = writer.write(questFile, quest, EncodingNames.UTF_8);
            if (ok) {
                nbQuests++;
            } else {
                String title = quest.getTitle();
                _logger.error("Write failed for quest [" + title + "]!");
            }
        }
    } else {
        _logger.error("Cannot parse quests [" + key + "] at URL [" + url + "]!");
    }
    return nbQuests;
}
Also used : QuestDescription(delta.games.lotro.lore.quests.QuestDescription) QuestXMLWriter(delta.games.lotro.lore.quests.io.xml.QuestXMLWriter) File(java.io.File)

Aggregations

QuestDescription (delta.games.lotro.lore.quests.QuestDescription)10 QuestsManager (delta.games.lotro.lore.quests.QuestsManager)4 QuestsIndex (delta.games.lotro.lore.quests.index.QuestsIndex)3 File (java.io.File)3 QuestCategory (delta.games.lotro.lore.quests.index.QuestCategory)2 QuestSummary (delta.games.lotro.lore.quests.index.QuestSummary)2 QuestXMLWriter (delta.games.lotro.lore.quests.io.xml.QuestXMLWriter)2 Element (net.htmlparser.jericho.Element)2 ExtensionPredicate (delta.common.utils.files.filter.ExtensionPredicate)1 CharacterLogItem (delta.games.lotro.character.log.CharacterLogItem)1 CharacterClass (delta.games.lotro.common.CharacterClass)1 Race (delta.games.lotro.common.Race)1 Rewards (delta.games.lotro.common.Rewards)1 QuestsIndexWriter (delta.games.lotro.lore.quests.index.io.xml.QuestsIndexWriter)1 QuestXMLParser (delta.games.lotro.lore.quests.io.xml.QuestXMLParser)1 DownloadService (delta.games.lotro.utils.DownloadService)1 ArrayList (java.util.ArrayList)1 Source (net.htmlparser.jericho.Source)1 InputSource (org.xml.sax.InputSource)1