use of delta.games.lotro.lore.deeds.DeedDescription in project lotro-tools by dmorcellet.
the class LorebookDeedsDatabaseNormalization method doIt.
private void doIt() {
File loreDir = LotroCoreConfig.getInstance().getLoreDir();
File in = new File(loreDir, "deeds.xml");
DeedXMLParser parser = new DeedXMLParser();
List<DeedDescription> deeds = parser.parseXML(in);
for (DeedDescription deed : deeds) {
normalizeDeed(deed);
}
File out = new File(loreDir, "deeds_by_name.xml");
DeedsContainer.writeSortedDeeds(deeds, out);
}
use of delta.games.lotro.lore.deeds.DeedDescription in project lotro-tools by dmorcellet.
the class LotroWikiDeedPageParser method parseDeeds.
/**
* Parse the lotro wiki deed page for the given deed ID.
* @param from Source page.
* @param deedId Deed ID.
* @return A deed or <code>null</code> if an error occurred.
*/
public List<DeedDescription> parseDeeds(File from, String deedId) {
_currentFile = from;
List<DeedDescription> deeds = null;
try {
FileInputStream inputStream = new FileInputStream(from);
Source source = new Source(inputStream);
String name = null;
Element backElement = JerichoHtmlUtils.findElementByTagNameAndAttributeValue(source, HTMLElementName.DIV, "id", "contentSub");
if (backElement != null) {
Element a = JerichoHtmlUtils.findElementByTagName(backElement, HTMLElementName.A);
if (a != null) {
name = a.getAttributeValue("title");
}
}
Element deedSource = JerichoHtmlUtils.findElementByTagNameAndAttributeValue(source, HTMLElementName.TEXTAREA, "id", "wpTextbox1");
if (deedSource != null) {
Segment content = deedSource.getContent();
String text = content.toString();
deeds = buildDeeds(text, name);
}
if (deeds != null) {
// Fixes
for (DeedDescription deed : deeds) {
handleFixes(deed);
}
}
} catch (Exception e) {
_logger.error("Cannot parse deed page [" + from + "]", e);
}
return deeds;
}
use of delta.games.lotro.lore.deeds.DeedDescription in project lotro-tools by dmorcellet.
the class LotroWikiDeedPageParser method buildDeeds.
private List<DeedDescription> buildDeeds(String rawData, String deedName) {
String[] lines = rawData.split("\n");
// Checks
if (lines == null)
return null;
List<DeedDescription> ret = new ArrayList<DeedDescription>();
int startIndex = 0;
while (true) {
Integer deedLineIndex = findDeedStartLine(lines, startIndex);
if (deedLineIndex == null) {
break;
}
startIndex = deedLineIndex.intValue() + 1;
DeedDescription deed = parseDeed(deedLineIndex.intValue(), lines, deedName);
if (deed != null) {
ret.add(deed);
}
}
return ret;
}
use of delta.games.lotro.lore.deeds.DeedDescription in project lotro-tools by dmorcellet.
the class MainLotroWikiDeedsLoader method writeResultFile.
private void writeResultFile() {
List<DeedDescription> deeds = new ArrayList<DeedDescription>();
DeedXMLParser parser = new DeedXMLParser();
File currentDir = new File(".");
for (File deedFile : currentDir.listFiles()) {
if (deedFile.getName().endsWith(".xml")) {
List<DeedDescription> newDeeds = parser.parseXML(deedFile);
deeds.addAll(newDeeds);
}
}
// Resolve deed links
new DeedLinksResolver(deeds).doIt();
int nbDeeds = deeds.size();
System.out.println("Found " + nbDeeds + " deeds.");
new CheckItemRewardsInDeeds().doIt(deeds);
new NormalizeDeedsText().doIt(deeds);
new CheckDeedLinks().doIt(deeds);
File out = new File("../lotro-companion/data/lore/deeds.xml");
DeedsContainer.writeSortedDeeds(deeds, out);
}
use of delta.games.lotro.lore.deeds.DeedDescription in project lotro-tools by dmorcellet.
the class LotroCompendiumDeedsLoader method resolveProxies.
private void resolveProxies(List<DeedDescription> deeds) {
for (DeedProxy proxy : _proxies) {
int idToSearch = proxy.getId();
for (DeedDescription deed : deeds) {
if (deed.getIdentifier() == idToSearch) {
proxy.setDeed(deed);
proxy.setKey(deed.getKey());
proxy.setName(deed.getName());
break;
}
}
if (proxy.getDeed() == null) {
System.out.println("Unresolved deed: id=" + idToSearch);
}
}
}
Aggregations