Search in sources :

Example 1 with Rewards

use of delta.games.lotro.common.Rewards in project lotro-companion by dmorcellet.

the class MainTestVirtuesStats method main.

/**
 * Basic main method for test.
 * @param args Not used.
 */
public static void main(String[] args) {
    LotroTestUtils utils = new LotroTestUtils();
    CharacterFile mainToon = utils.getMainToon();
    // CharacterFile mainToon=utils.getToonByName("Feroce");
    CharacterLog log = mainToon.getLastCharacterLog();
    VirtuesStats stats = null;
    if (log != null) {
        stats = new VirtuesStats(log);
        stats.dump(System.out, true);
    }
    HashMap<VirtueId, List<String>> virtuesMap = new HashMap<VirtueId, List<String>>();
    {
        DeedsManager dm = DeedsManager.getInstance();
        List<DeedDescription> deeds = dm.getAll();
        for (DeedDescription deed : deeds) {
            String name = deed.getName();
            Rewards rewards = deed.getRewards();
            Virtue[] virtues = rewards.getVirtues();
            if (virtues != null) {
                for (Virtue virtue : virtues) {
                    VirtueId virtueId = virtue.getIdentifier();
                    List<String> items = virtuesMap.get(virtueId);
                    if (items == null) {
                        items = new ArrayList<String>();
                        virtuesMap.put(virtueId, items);
                    }
                    items.add("Deed:" + name);
                }
            }
        }
    }
    List<String> toShow = new ArrayList<String>();
    toShow.add("Valour");
    toShow.add("Loyalty");
    toShow.add("Justice");
    toShow.add("Honour");
    toShow.add("Innocence");
    toShow.add("Zeal");
    List<VirtueId> virtueIds = new ArrayList<VirtueId>(virtuesMap.keySet());
    Collections.sort(virtueIds);
    for (VirtueId virtueId : virtueIds) {
        if (toShow.contains(virtueId)) {
            List<String> deeds = virtuesMap.get(virtueId);
            System.out.println(virtueId + " (" + deeds.size() + "): " + deeds);
            String[] got = stats.getIDsForAVirtue(virtueId);
            if (got != null) {
                System.out.println("GOT:" + virtueId + " (" + got.length + "): " + Arrays.toString(got));
                for (String id : got) deeds.remove(id);
            }
            System.out.println("MISSING: " + virtueId + " (" + deeds.size() + "): " + deeds);
        }
    }
}
Also used : DeedDescription(delta.games.lotro.lore.deeds.DeedDescription) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CharacterFile(delta.games.lotro.character.CharacterFile) DeedsManager(delta.games.lotro.lore.deeds.DeedsManager) LotroTestUtils(delta.games.lotro.character.log.LotroTestUtils) VirtueId(delta.games.lotro.common.VirtueId) Rewards(delta.games.lotro.common.Rewards) Virtue(delta.games.lotro.common.Virtue) ArrayList(java.util.ArrayList) List(java.util.List) CharacterLog(delta.games.lotro.character.log.CharacterLog)

Example 2 with Rewards

use of delta.games.lotro.common.Rewards in project lotro-companion by dmorcellet.

the class VirtuesStats method parseDeedItems.

private void parseDeedItems(List<CharacterLogItem> items) {
    DeedsManager dm = DeedsManager.getInstance();
    for (CharacterLogItem item : items) {
        Integer id = item.getResourceIdentifier();
        if (id != null) {
            DeedDescription deed = dm.getDeed(id.intValue());
            if (deed != null) {
                Rewards rewards = deed.getRewards();
                String name = deed.getName();
                handleRewards("Deed:" + name, rewards);
            }
        }
    }
}
Also used : DeedsManager(delta.games.lotro.lore.deeds.DeedsManager) DeedDescription(delta.games.lotro.lore.deeds.DeedDescription) Rewards(delta.games.lotro.common.Rewards) CharacterLogItem(delta.games.lotro.character.log.CharacterLogItem)

Example 3 with Rewards

use of delta.games.lotro.common.Rewards 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);
            }
        }
    }
}
Also used : QuestDescription(delta.games.lotro.lore.quests.QuestDescription) QuestsManager(delta.games.lotro.lore.quests.QuestsManager) Rewards(delta.games.lotro.common.Rewards) CharacterLogItem(delta.games.lotro.character.log.CharacterLogItem)

Example 4 with Rewards

use of delta.games.lotro.common.Rewards 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 5 with Rewards

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

the class LotroWikiDeedPageParser method parseDeed.

private DeedDescription parseDeed(int startIndex, String[] lines, String deedName) {
    DeedDescription deed = new DeedDescription();
    deed.setName(deedName);
    deed.setType(null);
    Rewards rewards = deed.getRewards();
    // Reputation
    Faction faction = null;
    Integer reputation = null;
    // Virtues
    VirtueId virtueId = null;
    Integer virtueCount = null;
    // Item rewards
    String[] itemRewards = null;
    Integer[] itemRewardCounts = null;
    // Categories
    String deedType = null;
    String deedSubtype = null;
    String regionalSub = null;
    // Deeds chain
    List<String> deedsChain = new ArrayList<String>();
    for (int index = startIndex + 1; index < lines.length; index++) {
        String line = lines[index].trim();
        if (line.contains("{{Deed"))
            break;
        String lineKey = fetchLineKey(line);
        // System.out.println(line);
        if ("name".equals(lineKey)) {
        // String name=getLineValue(line);
        // deed.setName(name);
        } else if ("Lore-text".equals(lineKey)) {
            String description = getLineValue(line);
            description = normalize(description);
            deed.setDescription(description);
        } else if ("Objective".equals(lineKey)) {
            StringBuilder sb = new StringBuilder();
            String firstLine = getLineValue(line);
            sb.append(firstLine);
            while (true) {
                String nextLine = lines[index + 1].trim();
                if (nextLine.startsWith("|")) {
                    break;
                }
                sb.append('\n').append(nextLine);
                index++;
            }
            String objectives = sb.toString().trim();
            objectives = normalize(objectives);
            deed.setObjectives(objectives);
        } else if ("Faction".equals(lineKey)) {
            faction = extractFaction(line);
        } else if ("Reputation".equals(lineKey)) {
            String repValue = getLineValue(line).replace(",", "");
            reputation = NumericTools.parseInteger(repValue);
        } else if ("Title".equals(lineKey)) {
            Title title = extractTitle(line);
            if (title != null) {
                rewards.addTitle(title);
            }
        } else if ("Virtue".equals(lineKey)) {
            virtueId = extractVirtue(line);
        } else if ("Virtue-value".equals(lineKey)) {
            virtueCount = NumericTools.parseInteger(getLineValue(line));
        } else if ("TP-reward".equals(lineKey)) {
            String tpStr = getLineValue(line);
            if ((!tpStr.isEmpty()) && (!"???".equals(tpStr))) {
                Integer tp = NumericTools.parseInteger(tpStr, false);
                if (tp != null) {
                    rewards.setLotroPoints(tp.intValue());
                } else {
                    _logger.warn("Bad LOTRO points value in file " + _currentFile + ": [" + tpStr + "]");
                }
            }
        } else if ("SM-reward".equals(lineKey)) {
            String smStr = getLineValue(line);
            if (!smStr.isEmpty()) {
                Integer marks = NumericTools.parseInteger(smStr, false);
                if (marks != null) {
                    ObjectsSet objects = deed.getRewards().getObjects();
                    ObjectItem item = new ObjectItem("Mark");
                    item.setItemId(1879224343);
                    objects.addObject(item, marks.intValue());
                } else {
                    _logger.warn("Bad SM value in file " + _currentFile + ": [" + smStr + "]");
                }
            }
        } else if ("CTP-reward".equals(lineKey)) {
            String value = getLineValue(line);
            if ("Y".equals(value)) {
            // TODO Class Trait Point
            }
        } else if ("Trait-reward".equals(lineKey)) {
            String traitStr = getLineValue(line);
            if (!traitStr.isEmpty()) {
                handleTraitReward(rewards, traitStr);
            }
        } else if ("Emote-reward".equals(lineKey)) {
            String emoteStr = getLineValue(line);
            if (!emoteStr.isEmpty()) {
                handleEmoteReward(rewards, emoteStr);
            }
        } else if ("Skill-reward".equals(lineKey)) {
            String skillStr = getLineValue(line);
            if (!skillStr.isEmpty()) {
                handleSkillReward(rewards, skillStr);
            }
        } else if ("Level".equals(lineKey)) {
            String levelStr = getLineValue(line);
            if ("?".equals(levelStr))
                levelStr = "";
            if ("???".equals(levelStr))
                levelStr = "";
            if (!levelStr.isEmpty()) {
                levelStr = levelStr.replace("&lt;", "<");
                if (levelStr.startsWith("<="))
                    levelStr = levelStr.substring(2);
                if (levelStr.equals("{{Level Cap}}"))
                    levelStr = "1000";
                if (levelStr.endsWith("+"))
                    levelStr = levelStr.substring(0, levelStr.length() - 1);
                levelStr = removeXmlComments(levelStr);
                Integer level = NumericTools.parseInteger(levelStr, false);
                if (level != null) {
                    deed.setMinLevel(level);
                } else {
                    _logger.warn("Bad level value in file " + _currentFile + ": [" + levelStr + "]");
                }
            }
        } else if ("Deed-type".equals(lineKey)) {
            deedType = getLineValue(line);
        } else if ("Deed-subtype".equals(lineKey)) {
            deedSubtype = getLineValue(line);
        } else if ("Regional-sub".equals(lineKey)) {
            regionalSub = getLineValue(line);
        } else if ((lineKey != null) && (lineKey.startsWith(DEED_CHAIN_SEED))) {
            Integer deedIndex = NumericTools.parseInteger(lineKey.substring(DEED_CHAIN_SEED.length()));
            if (deedIndex != null) {
                // Add missing entries
                int nbMissingEntries = deedIndex.intValue() - deedsChain.size();
                for (int i = 0; i < nbMissingEntries; i++) {
                    deedsChain.add(null);
                }
                // Set deed name in chain
                String deedNameInChain = getLineValue(line);
                deedsChain.set(deedIndex.intValue() - 1, deedNameInChain);
            }
        } else if ("Parent-deed".equals(lineKey)) {
            String parentDeed = getLineValue(line);
            if (!parentDeed.isEmpty()) {
                if (useParentDeedInfo(parentDeed, deedName)) {
                    parentDeed = fixParentDeedInfo(parentDeed, deedName);
                    DeedProxy parentProxy = new DeedProxy();
                    parentProxy.setName(parentDeed);
                    deed.getParentDeedProxies().add(parentProxy);
                }
            }
        }
        for (int i = 1; i <= 3; i++) {
            String suffix = (i != 1) ? String.valueOf(i) : "";
            if (("Item-reward" + suffix).equals(lineKey)) {
                String itemName = getLineValue(line);
                if (!itemName.isEmpty()) {
                    if (itemRewards == null) {
                        itemRewards = new String[3];
                    }
                    itemRewards[i - 1] = itemName;
                }
            }
            if (("Item-amount" + suffix).equals(lineKey)) {
                String itemCountStr = getLineValue(line);
                if (!itemCountStr.isEmpty()) {
                    if (itemRewardCounts == null) {
                        itemRewardCounts = new Integer[3];
                    }
                    itemRewardCounts[i - 1] = NumericTools.parseInteger(itemCountStr);
                }
            }
        }
    /*
| DP-reward    = 
| Hidden       = 
| Meta-deed     = 
| Extra         = 
       */
    }
    if ((faction != null) && (reputation != null)) {
        ReputationItem item = new ReputationItem(faction);
        item.setAmount(reputation.intValue());
        rewards.getReputation().add(item);
    }
    if (virtueId != null) {
        int count = (virtueCount != null) ? virtueCount.intValue() : 1;
        Virtue virtue = new Virtue(virtueId, count);
        rewards.addVirtue(virtue);
    }
    if (itemRewards != null) {
        handleItemRewards(deed, itemRewards, itemRewardCounts);
    }
    // Categories
    handleCategories(deed, deedType, deedSubtype, regionalSub);
    // Deeds chain
    handleDeedsChain(deed, deedsChain);
    return deed;
}
Also used : DeedDescription(delta.games.lotro.lore.deeds.DeedDescription) ArrayList(java.util.ArrayList) Title(delta.games.lotro.common.Title) ReputationItem(delta.games.lotro.common.ReputationItem) ObjectItem(delta.games.lotro.common.objects.ObjectItem) VirtueId(delta.games.lotro.common.VirtueId) DeedProxy(delta.games.lotro.lore.deeds.DeedProxy) Rewards(delta.games.lotro.common.Rewards) ObjectsSet(delta.games.lotro.common.objects.ObjectsSet) Virtue(delta.games.lotro.common.Virtue) Faction(delta.games.lotro.lore.reputation.Faction)

Aggregations

Rewards (delta.games.lotro.common.Rewards)11 ObjectsSet (delta.games.lotro.common.objects.ObjectsSet)6 DeedDescription (delta.games.lotro.lore.deeds.DeedDescription)5 ObjectItem (delta.games.lotro.common.objects.ObjectItem)4 DeedsManager (delta.games.lotro.lore.deeds.DeedsManager)3 ArrayList (java.util.ArrayList)3 CharacterLogItem (delta.games.lotro.character.log.CharacterLogItem)2 Title (delta.games.lotro.common.Title)2 Virtue (delta.games.lotro.common.Virtue)2 VirtueId (delta.games.lotro.common.VirtueId)2 DeedProxy (delta.games.lotro.lore.deeds.DeedProxy)2 Item (delta.games.lotro.lore.items.Item)2 List (java.util.List)2 CharacterFile (delta.games.lotro.character.CharacterFile)1 CharacterLog (delta.games.lotro.character.log.CharacterLog)1 LotroTestUtils (delta.games.lotro.character.log.LotroTestUtils)1 Emote (delta.games.lotro.common.Emote)1 ReputationItem (delta.games.lotro.common.ReputationItem)1 Trait (delta.games.lotro.common.Trait)1 QuestDescription (delta.games.lotro.lore.quests.QuestDescription)1