Search in sources :

Example 41 with ChoiceColor

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

the class SungoldSentinelEffect 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(true);
    player.choose(outcome, choice, game);
    Ability ability = HexproofBaseAbility.getFirstFromColor(choice.getColor());
    game.addEffect(new GainAbilitySourceEffect(ability, Duration.EndOfTurn), source);
    FilterCreaturePermanent filter = new FilterCreaturePermanent();
    filter.add(new ColorPredicate(choice.getColor()));
    game.addEffect(new CantBeBlockedByAllSourceEffect(filter, Duration.EndOfTurn), source);
    return true;
}
Also used : EntersBattlefieldOrAttacksSourceTriggeredAbility(mage.abilities.common.EntersBattlefieldOrAttacksSourceTriggeredAbility) ConditionalActivatedAbility(mage.abilities.decorator.ConditionalActivatedAbility) HexproofBaseAbility(mage.abilities.keyword.HexproofBaseAbility) Ability(mage.abilities.Ability) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) CantBeBlockedByAllSourceEffect(mage.abilities.effects.common.combat.CantBeBlockedByAllSourceEffect) GainAbilitySourceEffect(mage.abilities.effects.common.continuous.GainAbilitySourceEffect) ChoiceColor(mage.choices.ChoiceColor)

Example 42 with ChoiceColor

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

the class SuddenDemiseDamageEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    ChoiceColor choice = new ChoiceColor();
    if (controller != null && controller.choose(outcome, choice, game)) {
        final int damage = source.getManaCostsToPay().getX();
        FilterPermanent filter = new FilterCreaturePermanent();
        filter.add(new ColorPredicate(choice.getColor()));
        for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
            permanent.damage(damage, source.getSourceId(), source, game, false, true);
        }
        return true;
    }
    return false;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ChoiceColor(mage.choices.ChoiceColor)

Example 43 with ChoiceColor

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

the class WashOutEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Set<Card> cardsToReturn = new LinkedHashSet<>();
    ChoiceColor choice = new ChoiceColor();
    if (controller != null && controller.choose(Outcome.ReturnToHand, choice, game)) {
        ObjectColor color = choice.getColor();
        FilterPermanent filter = new FilterPermanent();
        filter.add(new ColorPredicate(color));
        for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
            cardsToReturn.add((Card) permanent);
        }
        return controller.moveCards(cardsToReturn, Zone.HAND, source, game);
    }
    return false;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) ObjectColor(mage.ObjectColor) ChoiceColor(mage.choices.ChoiceColor) Card(mage.cards.Card)

Example 44 with ChoiceColor

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

the class AddConditionalManaOfAnyColorEffect method produceMana.

@Override
public Mana produceMana(Game game, Ability source) {
    if (game != null) {
        Player controller = game.getPlayer(source.getControllerId());
        if (controller != null) {
            int value = amount.calculate(game, source, this);
            if (value > 0) {
                if (oneChoice || value == 1) {
                    ChoiceColor choice = new ChoiceColor(true);
                    controller.choose(outcome, choice, game);
                    if (choice.getChoice() == null) {
                        return null;
                    }
                    return new ConditionalMana(manaBuilder.setMana(choice.getMana(value), source, game).build());
                }
                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, value, MultiAmountType.MANA, game);
                Mana mana = new Mana(choices.get(0), choices.get(1), choices.get(2), choices.get(3), choices.get(4), 0, 0, 0);
                return new ConditionalMana(manaBuilder.setMana(mana, source, game).build());
            }
        }
    }
    return new Mana();
}
Also used : Player(mage.players.Player) ConditionalMana(mage.ConditionalMana) Mana(mage.Mana) ConditionalMana(mage.ConditionalMana) ArrayList(java.util.ArrayList) ChoiceColor(mage.choices.ChoiceColor)

Example 45 with ChoiceColor

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

the class SasayasEssenceManaEffect method produceMana.

/**
 * RULINGS 6/1/2005 If Sasaya’s Essence’s controller has four Forests and
 * taps one of them for Green, the Essence will add GreenGreenGreen to that
 * player’s mana pool for a total of GreenGreenGreenGreen.
 *
 * 6/1/2005 If Sasaya’s Essence’s controller has four Mossfire Valley and
 * taps one of them for RedGreen, the Essence will add three mana (one for
 * each other Mossfire Valley) of any combination of Red and/or Green to
 * that player’s mana pool.
 *
 * 6/1/2005 If Sasaya’s Essence’s controller has two Brushlands and taps one
 * of them for White, Sasaya’s Essence adds another White to that player’s
 * mana pool. It won’t produce Green or Colorless unless the land was tapped
 * for Green or Colorless instead.
 */
@Override
public Mana produceMana(Game game, Ability source) {
    Mana newMana = new Mana();
    if (game == null) {
        return newMana;
    }
    Player controller = game.getPlayer(source.getControllerId());
    Mana mana = (Mana) this.getValue("mana");
    Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
    if (controller != null && mana != null && permanent != null) {
        FilterPermanent filter = new FilterLandPermanent();
        filter.add(Predicates.not(new PermanentIdPredicate(permanent.getId())));
        filter.add(new NamePredicate(permanent.getName()));
        int count = game.getBattlefield().countAll(filter, controller.getId(), game);
        if (count > 0) {
            Choice choice = new ChoiceColor(true);
            choice.getChoices().clear();
            choice.setMessage("Pick the type of mana to produce");
            if (mana.getBlack() > 0) {
                choice.getChoices().add("Black");
            }
            if (mana.getRed() > 0) {
                choice.getChoices().add("Red");
            }
            if (mana.getBlue() > 0) {
                choice.getChoices().add("Blue");
            }
            if (mana.getGreen() > 0) {
                choice.getChoices().add("Green");
            }
            if (mana.getWhite() > 0) {
                choice.getChoices().add("White");
            }
            if (mana.getColorless() > 0) {
                choice.getChoices().add("Colorless");
            }
            if (!choice.getChoices().isEmpty()) {
                for (int i = 0; i < count; i++) {
                    choice.clearChoice();
                    if (choice.getChoices().size() == 1) {
                        choice.setChoice(choice.getChoices().iterator().next());
                    } else {
                        if (!controller.choose(outcome, choice, game)) {
                            return newMana;
                        }
                    }
                    switch(choice.getChoice()) {
                        case "Black":
                            newMana.increaseBlack();
                            break;
                        case "Blue":
                            newMana.increaseBlue();
                            break;
                        case "Red":
                            newMana.increaseRed();
                            break;
                        case "Green":
                            newMana.increaseGreen();
                            break;
                        case "White":
                            newMana.increaseWhite();
                            break;
                        case "Colorless":
                            newMana.increaseColorless();
                            break;
                    }
                }
            }
        }
    }
    return newMana;
}
Also used : PermanentIdPredicate(mage.filter.predicate.permanent.PermanentIdPredicate) Player(mage.players.Player) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) Mana(mage.Mana) FilterPermanent(mage.filter.FilterPermanent) FilterLandPermanent(mage.filter.common.FilterLandPermanent) Choice(mage.choices.Choice) FilterPermanent(mage.filter.FilterPermanent) FilterLandPermanent(mage.filter.common.FilterLandPermanent) Permanent(mage.game.permanent.Permanent) FilterControlledLandPermanent(mage.filter.common.FilterControlledLandPermanent) 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