use of delta.games.lotro.character.log.CharacterLogItem 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);
}
}
}
}
use of delta.games.lotro.character.log.CharacterLogItem in project lotro-tools by dmorcellet.
the class CharacterLogPageParser method parseLogPage.
private boolean parseLogPage(CharacterLog log, String rootURL, int pageNumber, int retryNumber) {
if (_logger.isInfoEnabled()) {
_logger.info("Page #" + pageNumber + ((retryNumber > 0) ? " try #" + retryNumber : ""));
}
boolean ret;
String url = rootURL + "=" + String.valueOf(pageNumber);
try {
DownloadService downloader = DownloadService.getInstance();
String page = downloader.getPage(url);
Source source = new Source(page);
// <table class="gradient_table activitylog">
Element logTable = JerichoHtmlUtils.findElementByTagNameAndAttributeValue(source, HTMLElementName.TABLE, "class", "gradient_table activitylog");
if (logTable != null) {
List<Element> trs = logTable.getAllElements(HTMLElementName.TR);
if ((trs != null) && (trs.size() >= 1)) {
// ignore first (table headers)
trs.remove(0);
for (Element tr : trs) {
CharacterLogItem item = parseLogItem(tr);
if (item != null) {
boolean addIt = true;
long date = item.getDate();
if (_stopDate != null) {
if (date < _stopDate.longValue()) {
addIt = false;
_stop = true;
break;
}
}
if (addIt) {
log.addLogItem(item);
}
}
}
}
}
ret = true;
} catch (Exception e) {
_logger.warn("Cannot parse character page [" + url + "]", e);
ret = false;
}
return ret;
}
use of delta.games.lotro.character.log.CharacterLogItem in project lotro-tools by dmorcellet.
the class CharacterLogRepair method getDatesToUpdate.
private List<Long> getDatesToUpdate(CharacterLog log) {
List<Long> ret = new ArrayList<Long>();
List<Long> dates = log.getDates();
for (Long date : dates) {
boolean useIt = false;
List<CharacterLogItem> items = log.getItemsOfDay(date.longValue());
for (CharacterLogItem item : items) {
String label = item.getLabel();
if (("Completed a deed".equals(label)) || ("Completed a quest".equals(label))) {
useIt = true;
break;
}
}
if (useIt) {
ret.add(date);
}
}
return ret;
}
use of delta.games.lotro.character.log.CharacterLogItem in project lotro-companion by dmorcellet.
the class WarbandsStats method getWarbandItems.
private List<CharacterLogItem> getWarbandItems(CharacterLog log) {
List<CharacterLogItem> ret = new ArrayList<CharacterLogItem>();
int nb = log.getNbItems();
for (int i = 0; i < nb; i++) {
CharacterLogItem item = log.getLogItem(i);
if (item != null) {
LogItemType type = item.getLogItemType();
if (type == LogItemType.QUEST) {
String label = item.getLabel();
if (label.startsWith(WARBAND_SEED)) {
ret.add(item);
}
}
}
}
Collections.reverse(ret);
return ret;
}
use of delta.games.lotro.character.log.CharacterLogItem in project lotro-tools by dmorcellet.
the class CharacterLogPageParser method parseLogItem.
private CharacterLogItem parseLogItem(Element tr) {
/*
<td class="char">
<a href="/home/character/2427907/146366987891794854">Glumlug</a>
</td>
<td class="date">2011/11/24</td>
<td class="details">
<img src="http://content.turbine.com/sites/playerportal/modules/lotro-base/images/icons/log/icon_levelup.png">
Reached level 70
</td>
*/
/*
<td class="char">
<a href="/home/character/2427907/146366987891794854">Glumlug</a>
</td>
<td class="date">2011/11/24</td>
<td class="details">
<a href="http://lorebook.lotro.com/wiki/Special:LotroResource?id=1879208735">
<img src="http://content.turbine.com/sites/playerportal/modules/lotro-base/images/icons/log/icon_quest.png">
Completed 'The Practiced Arm'
</a>
</td>
*/
CharacterLogItem ret = null;
List<Element> tds = tr.getAllElements(HTMLElementName.TD);
if ((tds != null) && (tds.size() == 3)) {
if (_characterName == null) {
Element charName = tds.get(0);
_characterName = JerichoHtmlUtils.getTagContents(charName, HTMLElementName.A);
}
Element tdDate = tds.get(1);
String dateStr = CharacterReference.decodeCollapseWhiteSpace(tdDate.getContent());
LogItemType type = null;
Element tdDetails = tds.get(2);
List<Element> imgs = tdDetails.getAllElements(HTMLElementName.IMG);
Element img = null;
if ((imgs != null) && (imgs.size() == 1)) {
img = imgs.get(0);
String imgSrc = img.getAttributeValue("src");
type = findType(imgSrc);
}
String url = null;
Element a = tdDetails.getFirstElement(HTMLElementName.A);
if (a != null) {
url = a.getAttributeValue("href");
}
TextExtractor extractor = tdDetails.getTextExtractor();
if (img != null)
extractor.excludeElement(img.getStartTag());
if (a != null)
extractor.excludeElement(a.getStartTag());
String label = extractor.toString().trim();
if ((dateStr != null) && (type != null) && (label != null)) {
try {
Calendar c = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT"));
String[] items = dateStr.split("/");
int year = Integer.parseInt(items[0]);
int month = Integer.parseInt(items[1]);
int day = Integer.parseInt(items[2]);
label = tuneLabel(label);
if (url != null) {
url = url.trim();
}
c.setTimeInMillis(0);
c.set(year, month - 1, day);
long date = c.getTimeInMillis();
ret = new CharacterLogItem(date, type, label, url);
} catch (Exception e) {
_logger.error("Cannot parse LOTRO character log item!", e);
}
}
}
return ret;
}
Aggregations