Search in sources :

Example 1 with DrawCardSourceControllerEffect

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

the class UrzasTomeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    new DrawCardSourceControllerEffect(1).apply(game, source);
    if (controller != null && controller.chooseUse(Outcome.Exile, "Exile a historic card from your graveyard?", source, game)) {
        Cost cost = new ExileFromGraveCost(new TargetCardInYourGraveyard(new FilterHistoricCard()));
        if (cost.canPay(source, source, controller.getId(), game)) {
            if (cost.pay(source, game, source, controller.getId(), false, null)) {
                return true;
            }
        }
    }
    if (controller != null) {
        controller.discard(1, false, false, source, game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) ExileFromGraveCost(mage.abilities.costs.common.ExileFromGraveCost) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) FilterHistoricCard(mage.filter.common.FilterHistoricCard) Cost(mage.abilities.costs.Cost) TapSourceCost(mage.abilities.costs.common.TapSourceCost) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) ExileFromGraveCost(mage.abilities.costs.common.ExileFromGraveCost)

Example 2 with DrawCardSourceControllerEffect

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

the class GainAbilitiesTest method test_AttachmentUnique.

@Test
public void test_AttachmentUnique() {
    // {R}
    // Enchanted creature has "{R}, {T}, Discard a card: Draw a card."
    addCard(Zone.HAND, playerA, "Epiphany Storm@attach", 2);
    addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
    // 
    // 2/2
    addCard(Zone.BATTLEFIELD, playerA, "Balduvian Bears@bear", 1);
    // attach all
    castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "@attach.1", "@bear");
    castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "@attach.2", "@bear");
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
    // checkAbility("after", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "@bear", VigilanceAbility.class, true);
    setStrictChooseMode(true);
    setStopAt(1, PhaseStep.BEGIN_COMBAT);
    execute();
    assertAllCommandsUsed();
    Permanent permanent = getPermanent("Balduvian Bears");
    Assert.assertEquals("must have 2 dynamic ability instances from two attachments", 2, permanent.getAbilities(currentGame).stream().filter(a -> a.getEffects().stream().anyMatch(e -> e instanceof DrawCardSourceControllerEffect)).count());
}
Also used : CardTestPlayerBase(org.mage.test.serverside.base.CardTestPlayerBase) VigilanceAbility(mage.abilities.keyword.VigilanceAbility) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) Zone(mage.constants.Zone) Permanent(mage.game.permanent.Permanent) PhaseStep(mage.constants.PhaseStep) Test(org.junit.Test) Assert(org.junit.Assert) Permanent(mage.game.permanent.Permanent) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) Test(org.junit.Test)

Example 3 with DrawCardSourceControllerEffect

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

the class PrimitiveEtchingsAbility 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.isCreature(game)) {
                    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 4 with DrawCardSourceControllerEffect

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

the class VilisBrokerOfBloodTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (event.getPlayerId().equals(this.getControllerId())) {
        this.getEffects().clear();
        this.addEffect(new DrawCardSourceControllerEffect(event.getAmount()));
        return true;
    }
    return false;
}
Also used : DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect)

Example 5 with DrawCardSourceControllerEffect

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

the class HuntersInsightTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!mor.refersTo(event.getSourceId(), game) || !((DamagedEvent) event).isCombatDamage()) {
        return false;
    }
    Permanent permanent = game.getPermanent(event.getTargetId());
    if (permanent != null && !permanent.isPlaneswalker(game)) {
        return false;
    }
    this.getEffects().clear();
    this.addEffect(new DrawCardSourceControllerEffect(event.getAmount()));
    return true;
}
Also used : DamagedEvent(mage.game.events.DamagedEvent) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) 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