Search in sources :

Example 1 with Emote

use of delta.games.lotro.common.Emote 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;
}
Also used : DeedDescription(delta.games.lotro.lore.deeds.DeedDescription) Emote(delta.games.lotro.common.Emote) Title(delta.games.lotro.common.Title) DeedProxy(delta.games.lotro.lore.deeds.DeedProxy) Rewards(delta.games.lotro.common.Rewards) ArrayList(java.util.ArrayList) List(java.util.List) Trait(delta.games.lotro.common.Trait) Map(java.util.Map)

Example 2 with Emote

use of delta.games.lotro.common.Emote 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>
     */
}
Also used : Skill(delta.games.lotro.common.Skill) Element(net.htmlparser.jericho.Element) Emote(delta.games.lotro.common.Emote) Trait(delta.games.lotro.common.Trait)

Example 3 with Emote

use of delta.games.lotro.common.Emote in project lotro-tools by dmorcellet.

the class LotroWikiDeedPageParser method handleEmoteReward.

private void handleEmoteReward(Rewards rewards, String emoteStr) {
    Emote emote = new Emote(emoteStr);
    rewards.addEmote(emote);
}
Also used : Emote(delta.games.lotro.common.Emote)

Aggregations

Emote (delta.games.lotro.common.Emote)3 Trait (delta.games.lotro.common.Trait)2 Rewards (delta.games.lotro.common.Rewards)1 Skill (delta.games.lotro.common.Skill)1 Title (delta.games.lotro.common.Title)1 DeedDescription (delta.games.lotro.lore.deeds.DeedDescription)1 DeedProxy (delta.games.lotro.lore.deeds.DeedProxy)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Element (net.htmlparser.jericho.Element)1