Search in sources :

Example 6 with TwoChoiceVote

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

the class BiteOfTheBlackRoseEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    // Outcome.Detriment - AI will discard a card all the time (Psychosis choice)
    // TODO: add AI hint logic in the choice method, see Tyrant's Choice as example
    TwoChoiceVote vote = new TwoChoiceVote("Sickness (-2/-2)", "Psychosis (discard cards)", Outcome.Detriment);
    vote.doVotes(source, game);
    int sicknessCount = vote.getVoteCount(true);
    int psychosisCount = vote.getVoteCount(false);
    if (sicknessCount > psychosisCount) {
        // sickness
        game.addEffect(new BoostOpponentsEffect(-2, -2, Duration.EndOfTurn), source);
    } else {
        // psychosis or tied
        new DiscardEachPlayerEffect(StaticValue.get(2), false, TargetController.OPPONENT).apply(game, source);
    }
    return true;
}
Also used : Player(mage.players.Player) BoostOpponentsEffect(mage.abilities.effects.common.continuous.BoostOpponentsEffect) DiscardEachPlayerEffect(mage.abilities.effects.common.discard.DiscardEachPlayerEffect) TwoChoiceVote(mage.choices.TwoChoiceVote)

Example 7 with TwoChoiceVote

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

the class MagisterOfWorthEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    // Outcome.Benefit - AI will return from graveyard all the time (Grace choice)
    // TODO: add AI hint logic in the choice method, see Tyrant's Choice as example
    TwoChoiceVote vote = new TwoChoiceVote("Grace (return from graveyard)", "Condemnation (destroy all)", Outcome.Benefit);
    vote.doVotes(source, game);
    int graceCount = vote.getVoteCount(true);
    int condemnationCount = vote.getVoteCount(false);
    if (condemnationCount >= graceCount) {
        return new DestroyAllEffect(filter).apply(game, source);
    }
    // grace win - each player returns each creature card from their graveyard to the battlefield
    Cards cards = new CardsImpl();
    game.getState().getPlayersInRange(source.getControllerId(), game).stream().map(game::getPlayer).filter(Objects::nonNull).map(Player::getGraveyard).map(g -> g.getCards(game)).flatMap(Collection::stream).filter(Objects::nonNull).filter(card -> card.isCreature(game)).forEach(cards::add);
    return controller.moveCards(cards.getCards(game), Zone.BATTLEFIELD, source, game, false, false, true, null);
}
Also used : Zone(mage.constants.Zone) EntersBattlefieldTriggeredAbility(mage.abilities.common.EntersBattlefieldTriggeredAbility) Collection(java.util.Collection) Cards(mage.cards.Cards) Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) UUID(java.util.UUID) MageInt(mage.MageInt) CardsImpl(mage.cards.CardsImpl) SubType(mage.constants.SubType) FilterPermanent(mage.filter.FilterPermanent) Player(mage.players.Player) CardSetInfo(mage.cards.CardSetInfo) Objects(java.util.Objects) TwoChoiceVote(mage.choices.TwoChoiceVote) Game(mage.game.Game) CardImpl(mage.cards.CardImpl) CardType(mage.constants.CardType) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) FlyingAbility(mage.abilities.keyword.FlyingAbility) AnotherPredicate(mage.filter.predicate.mageobject.AnotherPredicate) Ability(mage.abilities.Ability) DestroyAllEffect(mage.abilities.effects.common.DestroyAllEffect) Player(mage.players.Player) Objects(java.util.Objects) TwoChoiceVote(mage.choices.TwoChoiceVote) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) DestroyAllEffect(mage.abilities.effects.common.DestroyAllEffect)

Example 8 with TwoChoiceVote

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

the class MessengerJaysEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    // Outcome.Benefit - AI will boost all the time (Feather choice)
    // TODO: add AI hint logic in the choice method, see Tyrant's Choice as example
    TwoChoiceVote vote = new TwoChoiceVote("Feather (+1/+1 counter)", "Quill (draw a card)", Outcome.Benefit);
    vote.doVotes(source, game);
    int featherCount = vote.getVoteCount(true);
    int quillCount = vote.getVoteCount(false);
    Permanent permanent = source.getSourcePermanentIfItStillExists(game);
    if (featherCount > 0 && permanent != null) {
        permanent.addCounters(CounterType.P1P1.createInstance(featherCount), source.getControllerId(), source, game);
    }
    Player player = game.getPlayer(source.getControllerId());
    if (quillCount > 0 && player != null) {
        int drawn = player.drawCards(quillCount, source, game);
        player.discard(drawn, false, false, source, game);
    }
    return featherCount + quillCount > 0;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TwoChoiceVote(mage.choices.TwoChoiceVote)

Example 9 with TwoChoiceVote

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

the class OrchardElementalEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    // Outcome.Benefit - AI will boost all the time (Sprout choice)
    // TODO: add AI hint logic in the choice method, see Tyrant's Choice as example
    TwoChoiceVote vote = new TwoChoiceVote("Sprout (two +1/+1 counters)", "Harvest (3 life)", Outcome.Benefit);
    vote.doVotes(source, game);
    int sproutCount = vote.getVoteCount(true);
    int harvestCount = vote.getVoteCount(false);
    Permanent permanent = source.getSourcePermanentIfItStillExists(game);
    if (sproutCount > 0 && permanent != null) {
        permanent.addCounters(CounterType.P1P1.createInstance(2 * sproutCount), source.getControllerId(), source, game);
    }
    Player player = game.getPlayer(source.getControllerId());
    if (harvestCount > 0 && player != null) {
        player.gainLife(3 * harvestCount, game, source);
    }
    return sproutCount + harvestCount > 0;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TwoChoiceVote(mage.choices.TwoChoiceVote)

Example 10 with TwoChoiceVote

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

the class PleaForPowerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    // Outcome.Detriment - AI will draw cards all the time (Knowledge choice)
    // TODO: add AI hint logic in the choice method, see Tyrant's Choice as example
    TwoChoiceVote vote = new TwoChoiceVote("Time (extra turn)", "Knowledge (draw 3 cards)", Outcome.Detriment);
    vote.doVotes(source, game);
    int timeCount = vote.getVoteCount(true);
    int knowledgeCount = vote.getVoteCount(false);
    if (timeCount > knowledgeCount) {
        return new AddExtraTurnControllerEffect().apply(game, source);
    } else {
        return controller.drawCards(3, source, game) > 0;
    }
}
Also used : Player(mage.players.Player) AddExtraTurnControllerEffect(mage.abilities.effects.common.turn.AddExtraTurnControllerEffect) TwoChoiceVote(mage.choices.TwoChoiceVote)

Aggregations

TwoChoiceVote (mage.choices.TwoChoiceVote)12 Player (mage.players.Player)8 Permanent (mage.game.permanent.Permanent)5 Objects (java.util.Objects)2 UUID (java.util.UUID)2 Ability (mage.abilities.Ability)2 OneShotEffect (mage.abilities.effects.OneShotEffect)2 DestroyAllEffect (mage.abilities.effects.common.DestroyAllEffect)2 SacrificeOpponentsEffect (mage.abilities.effects.common.SacrificeOpponentsEffect)2 DiscardEachPlayerEffect (mage.abilities.effects.common.discard.DiscardEachPlayerEffect)2 CardImpl (mage.cards.CardImpl)2 CardSetInfo (mage.cards.CardSetInfo)2 CardType (mage.constants.CardType)2 Outcome (mage.constants.Outcome)2 FilterPermanent (mage.filter.FilterPermanent)2 Game (mage.game.Game)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 List (java.util.List)1 MageInt (mage.MageInt)1