use of delta.games.lotro.common.Trait in project lotro-tools by dmorcellet.
the class LotroCompendiumDeedsLoader method buildDeedFromRawData.
@SuppressWarnings("unchecked")
private DeedDescription buildDeedFromRawData(Object data) {
if (!(data instanceof Map)) {
return null;
}
Map<String, Object> map = (Map<String, Object>) data;
DeedDescription deed = new DeedDescription();
// [d, c, next, pois, o, virtues, prev, id, mobs, t, level, emotes, name, reputation, titles, traits, receive, zone]
// [mobs]
// ID
Double id = (Double) map.get("id");
deed.setIdentifier(id.intValue());
// Name
String name = (String) map.get("name");
deed.setName(name);
// Description
String description = (String) map.get("d");
if (description != null) {
description = description.replace(" ", " ");
}
deed.setDescription(description);
/*
// c=Comments?
List<String> comments=(List<String>)map.get("c");
// TODO
*/
// Previous
List<Double> prevIds = (List<Double>) map.get("prev");
if (prevIds != null) {
if (prevIds.size() > 1) {
System.out.println("Multiple previous deeds for id=" + deed.getIdentifier() + ": " + prevIds);
}
for (Double prevId : prevIds) {
DeedProxy previousDeedProxy = new DeedProxy();
previousDeedProxy.setId(prevId.intValue());
deed.setPreviousDeedProxy(previousDeedProxy);
_proxies.add(previousDeedProxy);
}
}
// Next
List<Double> nextIds = (List<Double>) map.get("next");
if (nextIds != null) {
if (nextIds.size() > 1) {
System.out.println("Multiple next deeds for id=" + deed.getIdentifier() + ": " + nextIds);
}
for (Double nextId : nextIds) {
DeedProxy nextDeedProxy = new DeedProxy();
nextDeedProxy.setId(nextId.intValue());
deed.setNextDeedProxy(nextDeedProxy);
_proxies.add(nextDeedProxy);
}
}
/*
// pois
// TODO
// mobs
// TODO
List<Object> mobs=(List<Object>)map.get("mobs");
*/
// Type
String type = (String) map.get("t");
handleType(deed, type);
// Zone
String zone = (String) map.get("zone");
zone = normalizeZone(zone);
deed.setCategory(zone);
// Objectives
String objectives = (String) map.get("o");
if (objectives != null) {
objectives = objectives.replace(" ", " ");
objectives = objectives.replace("Find\n", "");
objectives = objectives.replace("Find ", "");
}
deed.setObjectives(objectives);
// Level
Double level = (Double) map.get("level");
if (level != null) {
deed.setMinLevel(Integer.valueOf(level.intValue()));
}
// Rewards
Rewards rewards = deed.getRewards();
// - titles
{
List<Object> titles = (List<Object>) map.get("titles");
if (titles != null) {
for (Object title : titles) {
Map<String, Object> titleMap = (Map<String, Object>) title;
String titleLabel = (String) titleMap.get("val");
Title titleRewards = new Title(titleLabel, titleLabel);
rewards.addTitle(titleRewards);
}
}
}
// - traits
{
List<Object> traits = (List<Object>) map.get("traits");
if (traits != null) {
for (Object trait : traits) {
Map<String, Object> traitMap = (Map<String, Object>) trait;
String traitLabel = (String) traitMap.get("val");
Trait traitRewards = new Trait(traitLabel);
rewards.addTrait(traitRewards);
}
}
}
// - emotes
{
List<Object> emotes = (List<Object>) map.get("emotes");
if (emotes != null) {
for (Object emote : emotes) {
Map<String, Object> emoteMap = (Map<String, Object>) emote;
String emoteCommand = (String) emoteMap.get("val");
if (emoteCommand.startsWith("/")) {
emoteCommand = emoteCommand.substring(1);
}
Emote emoteRewards = new Emote(emoteCommand);
rewards.addEmote(emoteRewards);
}
}
}
// - items
// receive={{id="70018CBD",q="(x2)",val="Yule Festival Token"}}
{
List<Object> items = (List<Object>) map.get("receive");
if (items != null) {
for (Object item : items) {
Map<String, Object> itemMap = (Map<String, Object>) item;
handleItem(rewards, itemMap);
}
}
}
// - virtues
List<Object> virtueItems = (List<Object>) map.get("virtues");
handleVirtues(rewards, virtueItems);
// - reputation
List<Object> reputationItems = (List<Object>) map.get("reputation");
handleReputation(rewards, reputationItems);
return deed;
}
use of delta.games.lotro.common.Trait in project lotro-tools by dmorcellet.
the class RewardsHTMLParser method parseTraitReward.
private void parseTraitReward(Element rewardDiv, Rewards rewards) {
List<Element> as = rewardDiv.getAllElements(HTMLElementName.A);
int size = (as != null) ? as.size() : 0;
if (size == 2) {
Element secondA = as.get(1);
String name = CharacterReference.decodeCollapseWhiteSpace(secondA.getContent());
// String iconURL=null;
Element firstA = as.get(0);
String url = firstA.getAttributeValue("href");
if ((url != null) && (url.startsWith(URL_SEED))) {
String qualifiedIdentifier = url.substring(URL_SEED.length()).trim();
if (qualifiedIdentifier.startsWith(TRAIT_URL_SEED)) {
String identifier = qualifiedIdentifier.substring(TRAIT_URL_SEED.length()).trim();
if ((identifier.startsWith(EMOTE_SEED)) && (name.startsWith(EMOTE_SEED))) {
// identifier=identifier.substring(EMOTE_SEED.length()).trim();
name = name.substring(EMOTE_SEED.length()).trim();
Emote emote = new Emote(/*identifier,*/
name);
rewards.addEmote(emote);
// System.out.println(emote.dump());
} else {
Trait trait = new Trait(/*identifier,*/
name);
rewards.addTrait(trait);
// System.out.println(trait.dump());
}
} else if (qualifiedIdentifier.startsWith(PASSIVE_SKILL_URL_SEED)) {
// String identifier=qualifiedIdentifier.substring(PASSIVE_SKILL_URL_SEED.length()).trim();
Skill skill = new Skill(/*SkillType.PASSIVE,identifier,*/
name);
rewards.addSkill(skill);
// System.out.println(skill.dump());
} else {
_logger.warn(_objectId + ": unmanaged trait/skill identifier [" + qualifiedIdentifier + "]");
}
/*
List<Element> imgs=firstA.getAllElements(HTMLElementName.IMG);
if ((imgs!=null) && (imgs.size()>=1))
{
Element img=imgs.get(0);
iconURL=img.getAttributeValue("src");
}
*/
} else {
_logger.warn(_objectId + ": malformed URL [" + url + "]");
}
} else {
_logger.warn(_objectId + ": trait reward with " + size + " anchor tags!");
}
/*
<div class="questReward">
<div>
<strong>Traits:</strong>
</div>
<div>
<a href="/wiki/Trait:Expert_Woodworker_Proficiency">
<img class="icon" src="http://content.turbine.com/sites/lorebook.lotro.com/images/icons/trait/trait_c_craft_woodworker_complete_proficiency_3.png">
</a>
<a href="/wiki/Trait:Expert_Woodworker_Proficiency">Expert Woodworker Proficiency</a>
</div>
</div>
*/
}
use of delta.games.lotro.common.Trait in project lotro-tools by dmorcellet.
the class LotroWikiDeedPageParser method handleTraitReward.
private void handleTraitReward(Rewards rewards, String traitStr) {
// Sometimes, a trait is in fact... a virtue!
VirtueId virtueId = null;
try {
virtueId = VirtueId.valueOf(traitStr.toUpperCase());
} catch (Exception e) {
// Ignored
}
if (virtueId != null) {
Virtue virtue = new Virtue(virtueId, 1);
rewards.addVirtue(virtue);
} else {
if (traitStr.toLowerCase().endsWith(" (trait)"))
traitStr = traitStr.substring(0, traitStr.length() - 8);
if (traitStr.toLowerCase().endsWith(" (beorning trait)"))
traitStr = traitStr.substring(0, traitStr.length() - 17);
Trait trait = new Trait(traitStr);
rewards.addTrait(trait);
}
}
Aggregations