Search in sources :

Example 16 with DrawCardSourceControllerEffect

use of mage.abilities.effects.common.DrawCardSourceControllerEffect in project mage by magefree.

the class VoiceOfManyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    int myCount = game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), game).size();
    int toDraw = game.getOpponents(source.getControllerId()).stream().mapToInt(uuid -> game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, uuid, game).size() < myCount ? 1 : 0).sum();
    if (toDraw == 0) {
        return true;
    }
    return new DrawCardSourceControllerEffect(toDraw).apply(game, source);
}
Also used : StaticFilters(mage.filter.StaticFilters) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) EntersBattlefieldTriggeredAbility(mage.abilities.common.EntersBattlefieldTriggeredAbility) Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) UUID(java.util.UUID) MageInt(mage.MageInt) SubType(mage.constants.SubType) CardSetInfo(mage.cards.CardSetInfo) Game(mage.game.Game) CardImpl(mage.cards.CardImpl) CardType(mage.constants.CardType) Ability(mage.abilities.Ability) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect)

Example 17 with DrawCardSourceControllerEffect

use of mage.abilities.effects.common.DrawCardSourceControllerEffect in project mage by magefree.

the class LatNamsLegacyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && !controller.getHand().isEmpty()) {
        TargetCard target = new TargetCard(Zone.HAND, new FilterCard("card to shuffle into your library"));
        controller.choose(Outcome.Detriment, controller.getHand(), target, game);
        Card card = controller.getHand().get(target.getFirstTarget(), game);
        if (card != null) {
            boolean successful = controller.moveCards(card, Zone.LIBRARY, source, game);
            controller.shuffleLibrary(source, game);
            if (successful) {
                new CreateDelayedTriggeredAbilityEffect(new AtTheBeginOfNextUpkeepDelayedTriggeredAbility(new DrawCardSourceControllerEffect(2)), false).apply(game, source);
            }
        }
        return true;
    }
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) AtTheBeginOfNextUpkeepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextUpkeepDelayedTriggeredAbility) CreateDelayedTriggeredAbilityEffect(mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) TargetCard(mage.target.TargetCard) FilterCard(mage.filter.FilterCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 18 with DrawCardSourceControllerEffect

use of mage.abilities.effects.common.DrawCardSourceControllerEffect in project mage by magefree.

the class RielleTheEverwiseWatcher method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    RielleTheEverwiseWatcher watcher = game.getState().getWatcher(RielleTheEverwiseWatcher.class);
    if (watcher == null || !watcher.checkDiscarded(event.getPlayerId()) || !event.getPlayerId().equals(getControllerId()) || event.getAmount() == 0) {
        return false;
    }
    this.getEffects().clear();
    this.addEffect(new DrawCardSourceControllerEffect(event.getAmount()));
    return true;
}
Also used : DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect)

Example 19 with DrawCardSourceControllerEffect

use of mage.abilities.effects.common.DrawCardSourceControllerEffect in project mage by magefree.

the class TheftOfDreamsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player opponent = game.getPlayer(this.getTargetPointer().getFirst(game, source));
    if (opponent != null) {
        FilterCreaturePermanent filter = new FilterCreaturePermanent();
        filter.add(TappedPredicate.TAPPED);
        filter.add(new ControllerIdPredicate(opponent.getId()));
        return new DrawCardSourceControllerEffect(game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game)).apply(game, source);
    }
    return false;
}
Also used : Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate)

Example 20 with DrawCardSourceControllerEffect

use of mage.abilities.effects.common.DrawCardSourceControllerEffect in project mage by magefree.

the class VarinaLichQueenTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    int attackingZombies = 0;
    for (UUID attacker : game.getCombat().getAttackers()) {
        Permanent creature = game.getPermanent(attacker);
        if (creature != null && creature.getControllerId() != null && creature.isControlledBy(this.getControllerId()) && creature.hasSubtype(SubType.ZOMBIE, game)) {
            attackingZombies++;
        }
    }
    if (attackingZombies > 0) {
        this.getEffects().clear();
        addEffect(new DrawCardSourceControllerEffect(attackingZombies));
        addEffect(new DiscardControllerEffect(attackingZombies, false));
        addEffect(new GainLifeEffect(attackingZombies));
        return true;
    }
    return false;
}
Also used : Permanent(mage.game.permanent.Permanent) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) UUID(java.util.UUID) DiscardControllerEffect(mage.abilities.effects.common.discard.DiscardControllerEffect) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect)

Aggregations

DrawCardSourceControllerEffect (mage.abilities.effects.common.DrawCardSourceControllerEffect)21 Player (mage.players.Player)10 Permanent (mage.game.permanent.Permanent)9 UUID (java.util.UUID)4 Card (mage.cards.Card)4 CardsImpl (mage.cards.CardsImpl)4 Ability (mage.abilities.Ability)2 OneShotEffect (mage.abilities.effects.OneShotEffect)2 CardImpl (mage.cards.CardImpl)2 CardSetInfo (mage.cards.CardSetInfo)2 CardType (mage.constants.CardType)2 Outcome (mage.constants.Outcome)2 Zone (mage.constants.Zone)2 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)2 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)2 Game (mage.game.Game)2 DamagedEvent (mage.game.events.DamagedEvent)2 Objects (java.util.Objects)1 MageInt (mage.MageInt)1 MageObjectReference (mage.MageObjectReference)1