use of delta.games.lotro.common.Reputation in project lotro-tools by dmorcellet.
the class LotroCompendiumDeedsLoader method handleReputation.
@SuppressWarnings("unchecked")
private void handleReputation(Rewards rewards, List<Object> reputationItems) {
// reputation={{val="+700 with Iron Garrison Guards"}}
if (reputationItems == null) {
return;
}
FactionsRegistry registry = FactionsRegistry.getInstance();
Reputation reputation = rewards.getReputation();
for (Object reputationItem : reputationItems) {
Map<String, Object> reputationMap = (Map<String, Object>) reputationItem;
String reputationStr = (String) reputationMap.get("val");
int spaceIndex = reputationStr.indexOf(" ");
Integer value = NumericTools.parseInteger(reputationStr.substring(0, spaceIndex));
String factionStr = reputationStr.substring(spaceIndex + 1).trim();
if (factionStr.startsWith("with "))
factionStr = factionStr.substring(5);
Faction faction = registry.getByName(factionStr);
if ((faction != null) && (value != null)) {
ReputationItem repItem = new ReputationItem(faction);
repItem.setAmount(value.intValue());
reputation.add(repItem);
} else {
System.out.println("Not handled [" + reputationStr + "]");
}
}
}
use of delta.games.lotro.common.Reputation in project lotro-tools by dmorcellet.
the class RewardsHTMLParser method parseReward.
private void parseReward(Element rewardDiv, Rewards rewards) {
List<Element> strongs = rewardDiv.getAllElements(HTMLElementName.STRONG);
if ((strongs != null) && (strongs.size() >= 1)) {
Element strong = strongs.get(0);
String key = CharacterReference.decodeCollapseWhiteSpace(strong.getContent());
key = cleanupFieldName(key);
if ("Money".equals(key)) {
Money m = parseMoneyReward(rewardDiv);
rewards.getMoney().add(m);
} else if ("Reputation".equals(key)) {
Reputation r = parseReputationReward(rewardDiv);
rewards.getReputation().add(r);
} else if ((RECEIVE_KEY.equals(key)) || (SELECT_ONE_OF_KEY.equals(key))) {
parseItemReward(rewardDiv, rewards);
} else if ("IXP".equals(key)) {
boolean itemXP = parseItemXPReward(rewardDiv);
rewards.setHasItemXP(itemXP);
} else if ("Traits".equals(key)) {
parseTraitReward(rewardDiv, rewards);
} else if ("Titles".equals(key)) {
parseTitleReward(rewardDiv, rewards);
} else if ("Virtues".equals(key)) {
parseVirtuesReward(rewardDiv, rewards);
} else if ("Emotes".equals(key)) {
parseEmoteReward(rewardDiv, rewards);
} else if ("Destiny Points".equals(key)) {
int nb = parseDestinyPoints(rewardDiv);
rewards.setDestinyPoints(nb);
} else {
_logger.error(_objectId + ": unknown reward type: " + key);
}
}
}
use of delta.games.lotro.common.Reputation in project lotro-tools by dmorcellet.
the class RewardsHTMLParser method parseReputationReward.
private Reputation parseReputationReward(Element rewardDiv) {
// System.out.println("Reputation reward!");
Reputation r = new Reputation();
List<Element> elements = rewardDiv.getChildElements();
if ((elements != null) && (elements.size() == 2)) {
Element reputationNode = elements.get(1);
List<Segment> nodes = JerichoHtmlUtils.getChildNodes(reputationNode);
int nbNodes = nodes.size();
int nbItems = nbNodes / 4;
for (int i = 0; i < nbItems; i++) {
Segment valueNode = nodes.get(i * 4 + 1);
Segment factionNode = nodes.get(i * 4 + 3);
if ((valueNode.getClass() == Segment.class) && (factionNode.getClass() == Segment.class)) {
String valueStr = valueNode.toString();
valueStr = valueStr.replace("with", "").trim();
valueStr = valueStr.replace("+", "").trim();
int reputation = NumericTools.parseInt(valueStr, 0);
String factionName = factionNode.toString().trim();
Faction faction = FactionsRegistry.getInstance().getByName(factionName);
if (faction != null) {
ReputationItem item = new ReputationItem(faction);
item.setAmount(reputation);
r.add(item);
} else {
_logger.error("Cannot get faction [" + factionName + "]!");
}
}
}
}
return r;
/*
<div class="questReward">
<div>
<strong>Reputation:</strong>
</div>
<div>
<img class="icon" src="http://content.turbine.com/sites/lorebook.lotro.com/images/icons/reputation_increase.gif">
+700 with
<a href="/wiki/Faction:Malledhrim">Malledhrim</a>
</div>
</div>
*/
}
Aggregations