Search in sources :

Example 86 with Choice

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

the class MindblazeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(targetPointer.getFirst(game, source));
    Player playerControls = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (player == null || playerControls == null || sourceObject == null) {
        return false;
    }
    Choice numberChoice = new ChoiceImpl();
    numberChoice.setMessage("Choose a number greater than 0");
    Set<String> numbers = new HashSet<>();
    for (int i = 1; i <= 4; i++) {
        numbers.add(Integer.toString(i));
    }
    numberChoice.setChoices(numbers);
    String cardName = ChooseACardNameEffect.TypeOfName.NON_LAND_NAME.getChoice(playerControls, game, source, false);
    playerControls.choose(Outcome.Neutral, numberChoice, game);
    game.informPlayers(sourceObject.getIdName() + " - Chosen number: [" + numberChoice.getChoice() + ']');
    Cards cards = new CardsImpl();
    cards.addAll(player.getLibrary().getCards(game));
    playerControls.revealCards("Library", cards, game);
    FilterCard filter = new FilterCard();
    filter.add(new NamePredicate(cardName));
    int count = Integer.parseInt(numberChoice.getChoice());
    if (player.getLibrary().count(filter, game) == count) {
        player.damage(8, source.getSourceId(), source, game);
    }
    player.shuffleLibrary(source, game);
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) Choice(mage.choices.Choice) MageObject(mage.MageObject) ChoiceImpl(mage.choices.ChoiceImpl) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) HashSet(java.util.HashSet)

Example 87 with Choice

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

the class PacksDisdainEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
    if (player != null && player.choose(Outcome.UnboostCreature, typeChoice, game)) {
        FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
        filter.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
        DynamicValue negativePermanentsCount = new PermanentsOnBattlefieldCount(filter, -1);
        ContinuousEffect effect = new BoostTargetEffect(negativePermanentsCount, negativePermanentsCount, Duration.EndOfTurn, true);
        effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
        game.addEffect(effect, source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Choice(mage.choices.Choice) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) ChoiceCreatureType(mage.choices.ChoiceCreatureType) PermanentsOnBattlefieldCount(mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount) ContinuousEffect(mage.abilities.effects.ContinuousEffect) DynamicValue(mage.abilities.dynamicvalue.DynamicValue)

Example 88 with Choice

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

the class RiptideShapeshifterEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (controller != null && sourceObject != null) {
        Choice choice = new ChoiceCreatureType(sourceObject);
        if (!controller.choose(Outcome.BoostCreature, choice, game)) {
            return false;
        }
        Cards revealedCards = new CardsImpl();
        for (Card card : controller.getLibrary().getCards(game)) {
            if (card.isCreature(game) && card.hasSubtype(SubType.byDescription(choice.getChoice()), game)) {
                controller.moveCards(card, Zone.BATTLEFIELD, source, game);
                break;
            }
            revealedCards.add(card);
        }
        controller.revealCards(sourceObject.getIdName(), revealedCards, game);
        controller.moveCards(revealedCards, Zone.LIBRARY, source, game);
        controller.shuffleLibrary(source, game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) MageObject(mage.MageObject) ChoiceCreatureType(mage.choices.ChoiceCreatureType)

Example 89 with Choice

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

the class RiptideChronologistEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (player != null && sourceObject != null) {
        Choice typeChoice = new ChoiceCreatureType(sourceObject);
        if (player.choose(outcome, typeChoice, game)) {
            game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
            FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent();
            filterCreaturePermanent.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
            for (Permanent creature : game.getBattlefield().getActivePermanents(filterCreaturePermanent, source.getSourceId(), game)) {
                creature.untap(game);
            }
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) MageObject(mage.MageObject) ChoiceCreatureType(mage.choices.ChoiceCreatureType)

Example 90 with Choice

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

the class SquanderedResourcesEffect method produceMana.

@Override
public Mana produceMana(Game game, Ability source) {
    Mana mana = new Mana();
    if (game == null) {
        return mana;
    }
    Choice choice = ManaType.getChoiceOfManaTypes(getManaTypesFromSacrificedPermanent(game, source), false);
    if (!choice.getChoices().isEmpty()) {
        Player player = game.getPlayer(source.getControllerId());
        if (player == null) {
            return mana;
        }
        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":
                mana.setBlack(1);
                break;
            case "Blue":
                mana.setBlue(1);
                break;
            case "Red":
                mana.setRed(1);
                break;
            case "Green":
                mana.setGreen(1);
                break;
            case "White":
                mana.setWhite(1);
                break;
            case "Colorless":
                mana.setColorless(1);
                break;
        }
    }
    return mana;
}
Also used : Player(mage.players.Player) Mana(mage.Mana) Choice(mage.choices.Choice)

Aggregations

Choice (mage.choices.Choice)117 Player (mage.players.Player)114 ChoiceImpl (mage.choices.ChoiceImpl)67 Permanent (mage.game.permanent.Permanent)51 ChoiceCreatureType (mage.choices.ChoiceCreatureType)28 MageObject (mage.MageObject)27 Mana (mage.Mana)22 HashSet (java.util.HashSet)21 Card (mage.cards.Card)17 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)16 UUID (java.util.UUID)15 ContinuousEffect (mage.abilities.effects.ContinuousEffect)13 FilterPermanent (mage.filter.FilterPermanent)12 Ability (mage.abilities.Ability)10 ChoiceColor (mage.choices.ChoiceColor)10 Counter (mage.counters.Counter)10 TargetPermanent (mage.target.TargetPermanent)10 FilterCard (mage.filter.FilterCard)8 FixedTarget (mage.target.targetpointer.FixedTarget)8 CardType (mage.constants.CardType)7