Search in sources :

Example 6 with VirtueId

use of delta.games.lotro.common.VirtueId 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)

Example 7 with VirtueId

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

the class VirtuesDisplayPanelController method setVirtues.

/**
 * Set virtues to show.
 * @param virtues Virtues to show.
 */
public void setVirtues(VirtuesSet virtues) {
    for (int i = 0; i < MAX_VIRTUES; i++) {
        VirtueId virtueId = virtues.getSelectedVirtue(i);
        int tier = virtues.getVirtueRank(virtueId);
        setVirtue(i, virtueId, tier);
    }
}
Also used : VirtueId(delta.games.lotro.common.VirtueId)

Example 8 with VirtueId

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

the class VirtuesDisplayPanelController method getSelectedVirtues.

/**
 * Get the selected virtues.
 * @param virtues Storage for results.
 */
public void getSelectedVirtues(VirtuesSet virtues) {
    for (int i = 0; i < MAX_VIRTUES; i++) {
        VirtueIconController virtueController = _virtues[i];
        VirtueId virtue = virtueController.getVirtue();
        virtues.setSelectedVirtue(virtue, i);
    }
}
Also used : VirtueId(delta.games.lotro.common.VirtueId)

Example 9 with VirtueId

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

the class VirtuesEditionPanelController method build.

private JPanel build() {
    JPanel panel = GuiFactory.buildBackgroundPanel(null);
    // All virtues
    {
        int index = 0;
        for (VirtueId virtueId : VirtueId.values()) {
            VirtueEditionUiController ui = new VirtueEditionUiController(virtueId, panel);
            ui.setListener(this);
            int[] position = getPosition(index);
            ui.setLocation(position[0], position[1]);
            _virtues.put(virtueId, ui);
            index++;
        }
    }
    // Selected virtues
    {
        _selectedVirtues = new VirtuesDisplayPanelController();
        JPanel selectedVirtuesPanel = _selectedVirtues.getPanel();
        for (int i = 0; i < VirtuesDisplayPanelController.MAX_VIRTUES; i++) {
            VirtueIconController iconController = _selectedVirtues.getVirtue(i);
            JLabel label = iconController.getLabel();
            TransferHandler handler = new DropTransferHandler();
            label.setTransferHandler(handler);
        }
        panel.add(selectedVirtuesPanel);
        layoutSelectedVirtues();
    }
    // Max all button
    _maxAll = GuiFactory.buildButton("Max all");
    ActionListener al = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            maxAll();
        }
    };
    _maxAll.addActionListener(al);
    panel.add(_maxAll);
    _maxAll.setSize(_maxAll.getPreferredSize());
    int x = CENTER_X - (_maxAll.getWidth() / 2);
    int y = CENTER_Y + 10 + (_selectedVirtues.getPanel().getHeight() + _maxAll.getHeight() / 2);
    _maxAll.setLocation(x, y);
    panel.setPreferredSize(new Dimension(634, 348));
    return panel;
}
Also used : JPanel(javax.swing.JPanel) ActionListener(java.awt.event.ActionListener) VirtueId(delta.games.lotro.common.VirtueId) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) TransferHandler(javax.swing.TransferHandler) Dimension(java.awt.Dimension)

Example 10 with VirtueId

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

the class VirtuesEditionPanelController method maxAll.

private void maxAll() {
    for (Map.Entry<VirtueId, VirtueEditionUiController> entry : _virtues.entrySet()) {
        VirtueEditionUiController controller = entry.getValue();
        int tier = VirtuesSet.MAX_TIER;
        controller.setTier(tier);
        VirtueId virtueId = entry.getKey();
        _selectedVirtues.updateVirtue(virtueId, tier);
    }
}
Also used : VirtueId(delta.games.lotro.common.VirtueId) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

VirtueId (delta.games.lotro.common.VirtueId)17 Virtue (delta.games.lotro.common.Virtue)6 ArrayList (java.util.ArrayList)3 Rewards (delta.games.lotro.common.Rewards)2 VirtueRewardFilter (delta.games.lotro.common.rewards.filters.VirtueRewardFilter)2 DeedDescription (delta.games.lotro.lore.deeds.DeedDescription)2 Faction (delta.games.lotro.lore.reputation.Faction)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ComboBoxController (delta.common.ui.swing.combobox.ComboBoxController)1 ItemSelectionListener (delta.common.ui.swing.combobox.ItemSelectionListener)1 CharacterFile (delta.games.lotro.character.CharacterFile)1 CharacterLog (delta.games.lotro.character.log.CharacterLog)1 LotroTestUtils (delta.games.lotro.character.log.LotroTestUtils)1 VirtuesSet (delta.games.lotro.character.stats.virtues.VirtuesSet)1 CharacterClass (delta.games.lotro.common.CharacterClass)1 Race (delta.games.lotro.common.Race)1 ReputationItem (delta.games.lotro.common.ReputationItem)1 Title (delta.games.lotro.common.Title)1 Trait (delta.games.lotro.common.Trait)1