Search in sources :

Example 6 with DrawCardSourceControllerEffect

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

the class AscendantSpiritAngelEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = source.getSourcePermanentIfItStillExists(game);
    if (permanent == null || !permanent.hasSubtype(SubType.ANGEL, game)) {
        return false;
    }
    permanent.addCounters(CounterType.P1P1.createInstance(2), source.getControllerId(), source, game);
    game.addEffect(new GainAbilitySourceEffect(new DealsCombatDamageToAPlayerTriggeredAbility(new DrawCardSourceControllerEffect(1), false), Duration.Custom), source);
    return true;
}
Also used : DealsCombatDamageToAPlayerTriggeredAbility(mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility) Permanent(mage.game.permanent.Permanent) GainAbilitySourceEffect(mage.abilities.effects.common.continuous.GainAbilitySourceEffect) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect)

Example 7 with DrawCardSourceControllerEffect

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

the class KeranosGodOfStormsTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!event.getPlayerId().equals(this.getControllerId())) {
        return false;
    }
    if (!game.isActivePlayer(this.getControllerId())) {
        return false;
    }
    CardsAmountDrawnThisTurnWatcher watcher = game.getState().getWatcher(CardsAmountDrawnThisTurnWatcher.class);
    if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) != 1) {
        return false;
    }
    Card card = game.getCard(event.getTargetId());
    Player controller = game.getPlayer(this.getControllerId());
    Permanent sourcePermanent = (Permanent) getSourceObject(game);
    if (card == null || controller == null || sourcePermanent == null) {
        return false;
    }
    controller.revealCards(sourcePermanent.getIdName(), new CardsImpl(card), game);
    this.getTargets().clear();
    this.getEffects().clear();
    if (card.isLand(game)) {
        this.addEffect(new DrawCardSourceControllerEffect(1));
    } else {
        this.addEffect(new DamageTargetEffect(3));
        this.addTarget(new TargetAnyTarget());
    }
    return true;
}
Also used : CardsAmountDrawnThisTurnWatcher(mage.watchers.common.CardsAmountDrawnThisTurnWatcher) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card) TargetAnyTarget(mage.target.common.TargetAnyTarget)

Example 8 with DrawCardSourceControllerEffect

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

the class TheUrDragonTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    int attackingDragons = 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.DRAGON, game)) {
            attackingDragons++;
        }
    }
    if (attackingDragons > 0) {
        this.getEffects().clear();
        addEffect(new DrawCardSourceControllerEffect(attackingDragons));
        addEffect(new PutCardFromHandOntoBattlefieldEffect());
        return true;
    }
    return false;
}
Also used : Permanent(mage.game.permanent.Permanent) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) PutCardFromHandOntoBattlefieldEffect(mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect) UUID(java.util.UUID)

Example 9 with DrawCardSourceControllerEffect

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

the class RowenAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (event.getPlayerId().equals(this.getControllerId())) {
        if (game.isActivePlayer(this.getControllerId()) && this.lastTriggeredTurn != game.getTurnNum()) {
            Card card = game.getCard(event.getTargetId());
            Player controller = game.getPlayer(this.getControllerId());
            Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(this.getSourceId());
            if (card != null && controller != null && sourcePermanent != null) {
                lastTriggeredTurn = game.getTurnNum();
                controller.revealCards(sourcePermanent.getName(), new CardsImpl(card), game);
                this.getEffects().clear();
                if (card.isLand(game) && card.isBasic()) {
                    this.addEffect(new DrawCardSourceControllerEffect(1));
                }
                return true;
            }
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 10 with DrawCardSourceControllerEffect

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

the class SixthSenseTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (((DamagedEvent) event).isCombatDamage()) {
        if (event.getSourceId().equals(getSourceId())) {
            this.getEffects().clear();
            this.addEffect(new DrawCardSourceControllerEffect(1));
            return true;
        }
    }
    return false;
}
Also used : DamagedEvent(mage.game.events.DamagedEvent) 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