Search in sources :

Example 1 with SelectionActions

use of org.magic.game.actions.cards.SelectionActions in project MtgDesktopCompanion by nicho92.

the class DisplayableCard method initActions.

public void initActions() {
    if (rightActions) {
        menu.removeAll();
        menu.add(new JMenuItem(new SelectionActions(this)));
        menu.add(new JMenuItem(new TapActions(this)));
        if (magicCard.getFullType().toLowerCase().contains("creature")) {
            JMenu mnuModifier = new JMenu("P/T");
            mnuModifier.add(new BonusCounterActions(this, new BonusCounter(1, 0)));
            mnuModifier.add(new BonusCounterActions(this, new BonusCounter(-1, 0)));
            mnuModifier.add(new BonusCounterActions(this, new BonusCounter(0, 1)));
            mnuModifier.add(new BonusCounterActions(this, new BonusCounter(0, -1)));
            mnuModifier.add(new BonusCounterActions(this, new BonusCounter(1, 1)));
            mnuModifier.add(new BonusCounterActions(this, new BonusCounter(-1, -1)));
            mnuModifier.add(new FixCreaturePowerActions(this));
            menu.add(mnuModifier);
        }
        JMenu mnuCounter = new JMenu("Counter");
        mnuCounter.add(new ItemCounterActions(this, new ItemCounter("Yellow", Color.YELLOW)));
        mnuCounter.add(new ItemCounterActions(this, new ItemCounter("Green", Color.GREEN)));
        mnuCounter.add(new ItemCounterActions(this, new ItemCounter("Orange", Color.ORANGE)));
        menu.add(mnuCounter);
        if (magicCard.getFullType().contains("Planeswalker")) {
            JMenu mnuModifier = new JMenu("Loyalty");
            for (LoyaltyCounter count : listLoyalty()) mnuModifier.add(new LoyaltyActions(this, count));
            menu.add(mnuModifier);
        }
        if (magicCard.getSubtypes().contains("Aura") || magicCard.getSubtypes().contains("Equipment")) {
            menu.add(new JMenuItem(new AttachActions(this)));
        }
        Set<MTGKeyWord> l = MTGControler.getInstance().getKeyWordManager().getKeywordsFrom(magicCard);
        JMenu abilities = new JMenu("Actions");
        if (magicCard.getLayout().equalsIgnoreCase("aftermath"))
            l.add(MTGControler.getInstance().getKeyWordManager().generateFromString("Aftermath"));
        if (!l.isEmpty()) {
            for (final MTGKeyWord k : l) {
                JMenuItem it;
                try {
                    it = new JMenuItem(generateActionFrom(k));
                } catch (Exception e) {
                    it = new JMenuItem(k.getKeyword());
                    it.setToolTipText(k.getDescription());
                }
                abilities.add(it);
            }
            menu.add(abilities);
        }
        if (!counters.isEmpty()) {
            JMenu mnuModifier = new JMenu("Remove Counter");
            for (final AbstractCounter count : counters) mnuModifier.add(new JMenuItem(new RemoveCounterActions(this, count)));
            menu.add(mnuModifier);
        }
        if (magicCard.getText() != null && magicCard.getText().contains("copy of"))
            menu.add(new CopyFromActions(this));
        menu.add(sep);
        if (GamePanelGUI.getInstance().getTokenGenerator().isTokenizer(magicCard)) {
            menu.add(new JMenuItem(new CreateActions(this)));
        }
        if (GamePanelGUI.getInstance().getTokenGenerator().isEmblemizer(magicCard))
            menu.add(new JMenuItem(new EmblemActions(this)));
        setComponentPopupMenu(menu);
    }
}
Also used : ItemCounter(org.magic.game.model.counters.ItemCounter) CreateActions(org.magic.game.actions.cards.CreateActions) AbstractCounter(org.magic.game.model.counters.AbstractCounter) SelectionActions(org.magic.game.actions.cards.SelectionActions) FixCreaturePowerActions(org.magic.game.actions.cards.FixCreaturePowerActions) InvocationTargetException(java.lang.reflect.InvocationTargetException) RemoveCounterActions(org.magic.game.actions.cards.RemoveCounterActions) LoyaltyCounter(org.magic.game.model.counters.LoyaltyCounter) ItemCounterActions(org.magic.game.actions.cards.ItemCounterActions) EmblemActions(org.magic.game.actions.cards.EmblemActions) MTGKeyWord(org.magic.api.beans.MTGKeyWord) TapActions(org.magic.game.actions.cards.TapActions) AttachActions(org.magic.game.actions.cards.AttachActions) JMenuItem(javax.swing.JMenuItem) LoyaltyActions(org.magic.game.actions.cards.LoyaltyActions) BonusCounterActions(org.magic.game.actions.cards.BonusCounterActions) CopyFromActions(org.magic.game.actions.cards.CopyFromActions) JMenu(javax.swing.JMenu) BonusCounter(org.magic.game.model.counters.BonusCounter)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 JMenu (javax.swing.JMenu)1 JMenuItem (javax.swing.JMenuItem)1 MTGKeyWord (org.magic.api.beans.MTGKeyWord)1 AttachActions (org.magic.game.actions.cards.AttachActions)1 BonusCounterActions (org.magic.game.actions.cards.BonusCounterActions)1 CopyFromActions (org.magic.game.actions.cards.CopyFromActions)1 CreateActions (org.magic.game.actions.cards.CreateActions)1 EmblemActions (org.magic.game.actions.cards.EmblemActions)1 FixCreaturePowerActions (org.magic.game.actions.cards.FixCreaturePowerActions)1 ItemCounterActions (org.magic.game.actions.cards.ItemCounterActions)1 LoyaltyActions (org.magic.game.actions.cards.LoyaltyActions)1 RemoveCounterActions (org.magic.game.actions.cards.RemoveCounterActions)1 SelectionActions (org.magic.game.actions.cards.SelectionActions)1 TapActions (org.magic.game.actions.cards.TapActions)1 AbstractCounter (org.magic.game.model.counters.AbstractCounter)1 BonusCounter (org.magic.game.model.counters.BonusCounter)1 ItemCounter (org.magic.game.model.counters.ItemCounter)1 LoyaltyCounter (org.magic.game.model.counters.LoyaltyCounter)1