Search in sources :

Example 16 with ChoiceColor

use of mage.choices.ChoiceColor in project mage by magefree.

the class DynamicManaEffect method produceMana.

@Override
public Mana produceMana(Game game, Ability source) {
    Mana computedMana = new Mana();
    if (game == null) {
        return computedMana;
    }
    int count = amount.calculate(game, source, this);
    if (baseMana.getBlack() > 0) {
        computedMana.setBlack(count);
    } else if (baseMana.getBlue() > 0) {
        computedMana.setBlue(count);
    } else if (baseMana.getGreen() > 0) {
        computedMana.setGreen(count);
    } else if (baseMana.getRed() > 0) {
        computedMana.setRed(count);
    } else if (baseMana.getWhite() > 0) {
        computedMana.setWhite(count);
    } else if (baseMana.getColorless() > 0) {
        computedMana.setColorless(count);
    } else if (baseMana.getAny() > 0) {
        Player controller = game.getPlayer(source.getControllerId());
        if (controller != null && count > 0) {
            if (oneChoice || count == 1) {
                ChoiceColor choice = new ChoiceColor(true);
                controller.choose(outcome, choice, game);
                if (choice.getChoice() == null) {
                    return computedMana;
                }
                computedMana.add(choice.getMana(count));
            } else {
                List<String> manaStrings = new ArrayList<>(5);
                manaStrings.add("W");
                manaStrings.add("U");
                manaStrings.add("B");
                manaStrings.add("R");
                manaStrings.add("G");
                List<Integer> choices = controller.getMultiAmount(this.outcome, manaStrings, 0, count, MultiAmountType.MANA, game);
                computedMana.add(new Mana(choices.get(0), choices.get(1), choices.get(2), choices.get(3), choices.get(4), 0, 0, 0));
            }
        }
    } else {
        computedMana.setGeneric(count);
    }
    return computedMana;
}
Also used : Player(mage.players.Player) Mana(mage.Mana) ArrayList(java.util.ArrayList) ChoiceColor(mage.choices.ChoiceColor)

Example 17 with ChoiceColor

use of mage.choices.ChoiceColor in project mage by magefree.

the class CrosisThePurgerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    ChoiceColor choice = new ChoiceColor();
    player.choose(outcome, choice, game);
    if (!choice.isChosen()) {
        return false;
    }
    game.informPlayers(player.getLogName() + " chooses " + choice.getColor());
    Player damagedPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
    if (damagedPlayer == null) {
        return false;
    }
    damagedPlayer.revealCards("hand of " + damagedPlayer.getName(), damagedPlayer.getHand(), game);
    Cards cards = new CardsImpl(damagedPlayer.getHand().getCards(game).stream().filter(card -> card.getColor(game).shares(choice.getColor())).collect(Collectors.toSet()));
    damagedPlayer.discard(cards, false, source, game);
    return true;
}
Also used : Player(mage.players.Player) ChoiceColor(mage.choices.ChoiceColor) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 18 with ChoiceColor

use of mage.choices.ChoiceColor in project mage by magefree.

the class ChromeMoxManaEffect method produceMana.

@Override
public Mana produceMana(Game game, Ability source) {
    Mana mana = new Mana();
    if (game == null) {
        return mana;
    }
    Permanent permanent = game.getPermanent(source.getSourceId());
    Player player = game.getPlayer(source.getControllerId());
    if (permanent != null && player != null) {
        List<UUID> imprinted = permanent.getImprinted();
        if (imprinted != null && !imprinted.isEmpty()) {
            Card imprintedCard = game.getCard(imprinted.get(0));
            if (imprintedCard != null) {
                Choice choice = new ChoiceColor(true);
                choice.getChoices().clear();
                choice.setMessage("Pick a mana color");
                ObjectColor color = imprintedCard.getColor(game);
                if (color.isBlack()) {
                    choice.getChoices().add("Black");
                }
                if (color.isRed()) {
                    choice.getChoices().add("Red");
                }
                if (color.isBlue()) {
                    choice.getChoices().add("Blue");
                }
                if (color.isGreen()) {
                    choice.getChoices().add("Green");
                }
                if (color.isWhite()) {
                    choice.getChoices().add("White");
                }
                if (!choice.getChoices().isEmpty()) {
                    if (choice.getChoices().size() == 1) {
                        choice.setChoice(choice.getChoices().iterator().next());
                    } else {
                        if (!player.choose(outcome, choice, game)) {
                            return mana;
                        }
                    }
                    switch(choice.getChoice()) {
                        case "Black":
                            // player.getManaPool().addMana(Mana.BlackMana(1), game, source);
                            mana.add(Mana.BlackMana(1));
                            break;
                        case "Blue":
                            // player.getManaPool().addMana(Mana.BlueMana(1), game, source);
                            mana.add(Mana.BlueMana(1));
                            break;
                        case "Red":
                            // player.getManaPool().addMana(Mana.RedMana(1), game, source);
                            mana.add(Mana.RedMana(1));
                            break;
                        case "Green":
                            // player.getManaPool().addMana(Mana.GreenMana(1), game, source);
                            mana.add(Mana.GreenMana(1));
                            break;
                        case "White":
                            // player.getManaPool().addMana(Mana.WhiteMana(1), game, source);
                            mana.add(Mana.WhiteMana(1));
                            break;
                        default:
                            break;
                    }
                }
            }
        }
    }
    return mana;
}
Also used : Player(mage.players.Player) Mana(mage.Mana) Choice(mage.choices.Choice) Permanent(mage.game.permanent.Permanent) ObjectColor(mage.ObjectColor) UUID(java.util.UUID) ChoiceColor(mage.choices.ChoiceColor) TargetCard(mage.target.TargetCard) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard)

Example 19 with ChoiceColor

use of mage.choices.ChoiceColor in project mage by magefree.

the class DromarTheBanisherEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        ChoiceColor choice = new ChoiceColor();
        if (player.choose(outcome, choice, game)) {
            game.informPlayers(player.getLogName() + " chooses " + choice.getChoice());
            FilterCreaturePermanent filter = new FilterCreaturePermanent();
            filter.add(new ColorPredicate(choice.getColor()));
            new ReturnToHandFromBattlefieldAllEffect(filter).apply(game, source);
            return true;
        }
    }
    return false;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ReturnToHandFromBattlefieldAllEffect(mage.abilities.effects.common.ReturnToHandFromBattlefieldAllEffect) ChoiceColor(mage.choices.ChoiceColor)

Example 20 with ChoiceColor

use of mage.choices.ChoiceColor in project mage by magefree.

the class EmpoweredAutogeneratorManaEffect method produceMana.

@Override
public Mana produceMana(Game game, Ability source) {
    Mana mana = new Mana();
    if (game == null) {
        return mana;
    }
    game.getState().processAction(game);
    Permanent sourcePermanent = game.getPermanent(source.getSourceId());
    if (sourcePermanent == null) {
        return mana;
    }
    sourcePermanent.addCounters(CounterType.CHARGE.createInstance(), source.getControllerId(), source, game);
    int counters = sourcePermanent.getCounters(game).getCount(CounterType.CHARGE);
    if (counters == 0) {
        return mana;
    }
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return mana;
    }
    ChoiceColor choice = new ChoiceColor();
    choice.setMessage("Choose a color to add mana of that color");
    if (!controller.choose(outcome, choice, game)) {
        return mana;
    }
    if (choice.getChoice() == null) {
        return mana;
    }
    String color = choice.getChoice();
    switch(color) {
        case "Red":
            mana.setRed(counters);
            break;
        case "Blue":
            mana.setBlue(counters);
            break;
        case "White":
            mana.setWhite(counters);
            break;
        case "Black":
            mana.setBlack(counters);
            break;
        case "Green":
            mana.setGreen(counters);
            break;
    }
    return mana;
}
Also used : Player(mage.players.Player) Mana(mage.Mana) Permanent(mage.game.permanent.Permanent) ChoiceColor(mage.choices.ChoiceColor)

Aggregations

ChoiceColor (mage.choices.ChoiceColor)54 Player (mage.players.Player)52 Mana (mage.Mana)22 Permanent (mage.game.permanent.Permanent)17 ColorPredicate (mage.filter.predicate.mageobject.ColorPredicate)14 Choice (mage.choices.Choice)10 ObjectColor (mage.ObjectColor)8 FilterCard (mage.filter.FilterCard)7 MageObject (mage.MageObject)5 FilterPermanent (mage.filter.FilterPermanent)5 FixedTarget (mage.target.targetpointer.FixedTarget)5 ConditionalMana (mage.ConditionalMana)4 ContinuousEffect (mage.abilities.effects.ContinuousEffect)4 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)4 Ability (mage.abilities.Ability)3 ProtectionAbility (mage.abilities.keyword.ProtectionAbility)3 Card (mage.cards.Card)3 TargetPlayer (mage.target.TargetPlayer)3 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)3 ArrayList (java.util.ArrayList)2