Search in sources :

Example 1 with DeedProxy

use of delta.games.lotro.lore.deeds.DeedProxy in project lotro-companion by dmorcellet.

the class DeedLinksDisplayPanelController method buildLinks.

private void buildLinks() {
    buildController("Parent:", _deed.getParentDeedProxy());
    buildController("Previous:", _deed.getPreviousDeedProxy());
    buildController("Next:", _deed.getNextDeedProxy());
    List<DeedProxy> children = _deed.getChildDeeds();
    for (DeedProxy child : children) {
        buildController("Child:", child);
    }
}
Also used : DeedProxy(delta.games.lotro.lore.deeds.DeedProxy)

Example 2 with DeedProxy

use of delta.games.lotro.lore.deeds.DeedProxy 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 3 with DeedProxy

use of delta.games.lotro.lore.deeds.DeedProxy in project lotro-tools by dmorcellet.

the class MergeDeedsDatabases method mergeLorebook2LotroCompendium.

private void mergeLorebook2LotroCompendium() {
    List<DeedDescription> matchingLotroCompendiumDeeds = findMatchingDeeds(_lorebook, _lotroCompendium);
    List<DeedDescription> lorebookDeeds = _lorebook.getAll();
    int nbDeeds = lorebookDeeds.size();
    for (int i = 0; i < nbDeeds; i++) {
        DeedDescription lorebookDeed = lorebookDeeds.get(i);
        DeedDescription lotroCompendiumDeed = matchingLotroCompendiumDeeds.get(i);
        if (lotroCompendiumDeed != null) {
            // Categories
            String category = lotroCompendiumDeed.getCategory();
            lorebookDeed.setCategory(category);
            // IDs
            lotroCompendiumDeed.setIdentifier(lorebookDeed.getIdentifier());
            // Objectives
            String lorebookObjectives = lorebookDeed.getObjectives();
            if ((lorebookObjectives == null) || (lorebookObjectives.isEmpty())) {
                lorebookDeed.setObjectives(lotroCompendiumDeed.getObjectives());
            }
            // Item XP
            lotroCompendiumDeed.getRewards().setHasItemXP(lorebookDeed.getRewards().hasItemXP());
        } else {
            _lotroCompendium.addDeed(lorebookDeed);
        }
    }
    // Afterwards, merge proxy info (previous/next)
    for (int i = 0; i < nbDeeds; i++) {
        DeedDescription lorebookDeed = lorebookDeeds.get(i);
        DeedDescription lotroCompendiumDeed = matchingLotroCompendiumDeeds.get(i);
        if (lotroCompendiumDeed != null) {
            // Previous
            DeedProxy previousProxy = lotroCompendiumDeed.getPreviousDeedProxy();
            if (previousProxy != null) {
                int previousId = previousProxy.getId();
                if (previousId > 10000) {
                    DeedProxy lorebookPreviousProxy = new DeedProxy();
                    lorebookPreviousProxy.setId(previousId);
                    lorebookDeed.setPreviousDeedProxy(lorebookPreviousProxy);
                } else {
                    System.out.println("Warn: unresolved previous id=" + previousId);
                }
            }
            // Next
            DeedProxy nextProxy = lotroCompendiumDeed.getNextDeedProxy();
            if (nextProxy != null) {
                int nextId = nextProxy.getId();
                if (nextId > 10000) {
                    DeedProxy lorebookNextProxy = new DeedProxy();
                    lorebookNextProxy.setId(nextId);
                    lorebookDeed.setNextDeedProxy(lorebookNextProxy);
                } else {
                    System.out.println("Warn: unresolved next id=" + nextId);
                }
            }
        }
    }
}
Also used : DeedDescription(delta.games.lotro.lore.deeds.DeedDescription) DeedProxy(delta.games.lotro.lore.deeds.DeedProxy)

Example 4 with DeedProxy

use of delta.games.lotro.lore.deeds.DeedProxy in project lotro-tools by dmorcellet.

the class CheckDeedLinks method loadPreviousDeedsOfChildren.

private Set<String> loadPreviousDeedsOfChildren(DeedDescription deed) {
    Set<String> previousDeeds = new HashSet<String>();
    List<DeedProxy> childProxies = deed.getChildDeedProxies().getDeedProxies();
    for (DeedProxy childProxy : childProxies) {
        DeedDescription childDeed = childProxy.getDeed();
        previousDeeds.addAll(loadPreviousDeeds(childDeed));
    }
    return previousDeeds;
}
Also used : DeedDescription(delta.games.lotro.lore.deeds.DeedDescription) DeedProxy(delta.games.lotro.lore.deeds.DeedProxy) HashSet(java.util.HashSet)

Example 5 with DeedProxy

use of delta.games.lotro.lore.deeds.DeedProxy in project lotro-tools by dmorcellet.

the class CheckDeedLinks method cleanChildDeeds.

private void cleanChildDeeds(DeedDescription deed) {
    Set<String> previousDeedsOfChildren = loadPreviousDeedsOfChildren(deed);
    List<DeedProxy> childrenToRemove = new ArrayList<DeedProxy>();
    List<DeedProxy> childProxies = deed.getChildDeedProxies().getDeedProxies();
    for (DeedProxy childProxy : childProxies) {
        String childKey = childProxy.getKey();
        if (previousDeedsOfChildren.contains(childKey)) {
            childrenToRemove.add(childProxy);
        }
    }
    for (DeedProxy childToRemove : childrenToRemove) {
        childProxies.remove(childToRemove);
    }
}
Also used : DeedProxy(delta.games.lotro.lore.deeds.DeedProxy) ArrayList(java.util.ArrayList)

Aggregations

DeedProxy (delta.games.lotro.lore.deeds.DeedProxy)19 DeedDescription (delta.games.lotro.lore.deeds.DeedDescription)13 ArrayList (java.util.ArrayList)4 Rewards (delta.games.lotro.common.Rewards)2 Title (delta.games.lotro.common.Title)2 ObjectItem (delta.games.lotro.common.objects.ObjectItem)2 DeedProxies (delta.games.lotro.lore.deeds.DeedProxies)2 HashSet (java.util.HashSet)2 Emote (delta.games.lotro.common.Emote)1 ReputationItem (delta.games.lotro.common.ReputationItem)1 Trait (delta.games.lotro.common.Trait)1 Virtue (delta.games.lotro.common.Virtue)1 VirtueId (delta.games.lotro.common.VirtueId)1 ObjectsSet (delta.games.lotro.common.objects.ObjectsSet)1 Faction (delta.games.lotro.lore.reputation.Faction)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1