Search in sources :

Example 11 with DrawCardSourceControllerEffect

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

the class DistantMelodyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
    if (controller != null && controller.choose(Outcome.BoostCreature, typeChoice, game)) {
        FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
        filter.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
        return new DrawCardSourceControllerEffect(new PermanentsOnBattlefieldCount(filter)).apply(game, source);
    }
    return false;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) ChoiceCreatureType(mage.choices.ChoiceCreatureType) PermanentsOnBattlefieldCount(mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount)

Example 12 with DrawCardSourceControllerEffect

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

the class FblthpTheLostTargetedTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!super.checkTrigger(event, game)) {
        return false;
    }
    EntersTheBattlefieldEvent entersEvent = (EntersTheBattlefieldEvent) event;
    if (entersEvent.getFromZone() == Zone.LIBRARY) {
        this.getEffects().clear();
        this.addEffect(new DrawCardSourceControllerEffect(2));
        return true;
    }
    FblthpTheLostWatcher watcher = game.getState().getWatcher(FblthpTheLostWatcher.class);
    int zcc = entersEvent.getTarget().getZoneChangeCounter(game) - 1;
    MageObjectReference mor = new MageObjectReference(entersEvent.getTargetId(), zcc, game);
    if (watcher != null && watcher.spellWasCastFromLibrary(mor)) {
        this.getEffects().clear();
        this.addEffect(new DrawCardSourceControllerEffect(2));
        return true;
    }
    this.getEffects().clear();
    this.addEffect(new DrawCardSourceControllerEffect(1));
    return true;
}
Also used : EntersTheBattlefieldEvent(mage.game.events.EntersTheBattlefieldEvent) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) MageObjectReference(mage.MageObjectReference)

Example 13 with DrawCardSourceControllerEffect

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

the class IgnorantBlissEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    Cards hand = new CardsImpl(controller.getHand());
    controller.moveCardsToExile(hand.getCards(game), source, game, false, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
    hand.getCards(game).stream().filter(Objects::nonNull).filter(card -> game.getState().getZone(card.getId()) == Zone.EXILED).forEach(card -> card.setFaceDown(true, game));
    DelayedTriggeredAbility ability = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnFromExileEffect(Zone.HAND));
    ability.addEffect(new DrawCardSourceControllerEffect(1));
    game.addDelayedTriggeredAbility(ability, source);
    return true;
}
Also used : ReturnFromExileEffect(mage.abilities.effects.common.ReturnFromExileEffect) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) Zone(mage.constants.Zone) Cards(mage.cards.Cards) Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) CardUtil(mage.util.CardUtil) UUID(java.util.UUID) CardsImpl(mage.cards.CardsImpl) Player(mage.players.Player) CardSetInfo(mage.cards.CardSetInfo) Objects(java.util.Objects) Game(mage.game.Game) CardImpl(mage.cards.CardImpl) CardType(mage.constants.CardType) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) Ability(mage.abilities.Ability) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) ReturnFromExileEffect(mage.abilities.effects.common.ReturnFromExileEffect) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) Objects(java.util.Objects) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 14 with DrawCardSourceControllerEffect

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

the class ToppleTheStatueEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent == null) {
        return false;
    }
    permanent.tap(source, game);
    if (permanent.isArtifact(game)) {
        permanent.destroy(source, game, false);
    }
    return new DrawCardSourceControllerEffect(1).apply(game, source);
}
Also used : Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect)

Example 15 with DrawCardSourceControllerEffect

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

the class TradeSecretsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    String message = "Do you want to draw two cards and allow the spellcaster to draw up to four cards again?";
    String message2 = "How many cards do you want to draw?";
    Player controller = game.getPlayer(source.getControllerId());
    Player targetOpponent = game.getPlayer(source.getFirstTarget());
    if (controller != null && targetOpponent != null) {
        // The drawcard method would not work immediately
        new DrawCardTargetEffect(2).apply(game, source);
        int amountOfCardsToDraw = controller.getAmount(0, 4, message2, game);
        new DrawCardSourceControllerEffect(amountOfCardsToDraw).apply(game, source);
        while (targetOpponent.chooseUse(Outcome.AIDontUseIt, message, source, game)) {
            new DrawCardTargetEffect(2).apply(game, source);
            amountOfCardsToDraw = controller.getAmount(0, 4, message2, game);
            new DrawCardSourceControllerEffect(amountOfCardsToDraw).apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) DrawCardTargetEffect(mage.abilities.effects.common.DrawCardTargetEffect) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect)

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