Search in sources :

Example 11 with PlayFromNotOwnHandZoneTargetEffect

use of mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect in project mage by magefree.

the class SpelljackEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        UUID targetId = targetPointer.getFirst(game, source);
        StackObject stackObject = game.getStack().getStackObject(targetId);
        if (stackObject != null && game.getStack().counter(targetId, source, game, Zone.EXILED, false, ZoneDetail.NONE)) {
            Card card = ((Spell) stackObject).getCard();
            if (card != null) {
                ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, TargetController.YOU, Duration.Custom, true);
                effect.setTargetPointer(new FixedTarget(card.getId(), game.getState().getZoneChangeCounter(card.getId())));
                game.addEffect(effect, source);
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) PlayFromNotOwnHandZoneTargetEffect(mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect) StackObject(mage.game.stack.StackObject) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID) Spell(mage.game.stack.Spell) TargetSpell(mage.target.TargetSpell) Card(mage.cards.Card)

Example 12 with PlayFromNotOwnHandZoneTargetEffect

use of mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect in project mage by magefree.

the class RobberOfTheRichEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player damagedPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
    if (controller == null || damagedPlayer == null) {
        return false;
    }
    Card card = damagedPlayer.getLibrary().getFromTop(game);
    if (card == null) {
        return false;
    }
    // move card to exile
    controller.moveCardsToExile(card, source, game, true, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
    // don't worry about land
    if (card.getSpellAbility() != null) {
        // the exiled card is independent and requires a new ability in case the Robber leaves the battlefield
        // the exiled card can be cast throughout the entire game as long as the controller attacked with a rogue that turn
        Ability copiedAbility = source.copy();
        copiedAbility.newId();
        copiedAbility.setSourceId(card.getId());
        copiedAbility.setControllerId(source.getControllerId());
        PlayFromNotOwnHandZoneTargetEffect playFromExile = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, Duration.EndOfGame);
        YouMaySpendManaAsAnyColorToCastTargetEffect spendAnyMana = new YouMaySpendManaAsAnyColorToCastTargetEffect(Duration.EndOfGame);
        ConditionalAsThoughEffect castOnlyIfARogueAttackedThisTurn = new ConditionalAsThoughEffect(playFromExile, new RogueAttackedThisTurnCondition(copiedAbility));
        playFromExile.setTargetPointer(new FixedTarget(card, game));
        spendAnyMana.setTargetPointer(new FixedTarget(card, game));
        castOnlyIfARogueAttackedThisTurn.setTargetPointer(new FixedTarget(card, game));
        game.addEffect(castOnlyIfARogueAttackedThisTurn, copiedAbility);
        game.addEffect(spendAnyMana, copiedAbility);
        return true;
    }
    return false;
}
Also used : AttacksTriggeredAbility(mage.abilities.common.AttacksTriggeredAbility) HasteAbility(mage.abilities.keyword.HasteAbility) ReachAbility(mage.abilities.keyword.ReachAbility) ConditionalInterveningIfTriggeredAbility(mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility) Ability(mage.abilities.Ability) FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) PlayFromNotOwnHandZoneTargetEffect(mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect) ConditionalAsThoughEffect(mage.abilities.decorator.ConditionalAsThoughEffect) YouMaySpendManaAsAnyColorToCastTargetEffect(mage.abilities.effects.common.asthought.YouMaySpendManaAsAnyColorToCastTargetEffect) Card(mage.cards.Card)

Example 13 with PlayFromNotOwnHandZoneTargetEffect

use of mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect in project mage by magefree.

the class ExpressiveIterationEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (player == null || sourceObject == null) {
        return false;
    }
    Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 3));
    if (cards.size() < 1) {
        return false;
    }
    TargetCard target = new TargetCardInLibrary(cards.size() == 3 ? 1 : 0, 1, StaticFilters.FILTER_CARD);
    target.withChooseHint("To put into your hand");
    player.choose(outcome, cards, target, game);
    Card card = game.getCard(target.getFirstTarget());
    if (card != null) {
        player.moveCards(card, Zone.HAND, source, game);
        cards.remove(card);
    }
    if (cards.isEmpty()) {
        return true;
    }
    target = new TargetCardInLibrary(cards.size() == 2 ? 1 : 0, 1, StaticFilters.FILTER_CARD);
    target.withChooseHint("To put on the bottom of your library");
    player.choose(outcome, cards, target, game);
    card = game.getCard(target.getFirstTarget());
    if (card != null) {
        player.putCardsOnBottomOfLibrary(card, game, source, false);
        cards.remove(card);
    }
    if (cards.isEmpty()) {
        return true;
    }
    target = new TargetCardInLibrary();
    target.withChooseHint("To exile (you may play it this turn)");
    player.choose(outcome, cards, target, game);
    card = game.getCard(target.getFirstTarget());
    if (card == null) {
        return true;
    }
    player.moveCardsToExile(card, source, game, true, source.getSourceId(), sourceObject.getIdName());
    game.addEffect(new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, Duration.EndOfTurn).setTargetPointer(new FixedTarget(card, game)), source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) PlayFromNotOwnHandZoneTargetEffect(mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect) MageObject(mage.MageObject) TargetCard(mage.target.TargetCard) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) TargetCard(mage.target.TargetCard)

Example 14 with PlayFromNotOwnHandZoneTargetEffect

use of mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect in project mage by magefree.

the class MissionBriefingReplacementEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    player.surveil(2, source, game);
    Target target = new TargetCardInYourGraveyard(new FilterInstantOrSorceryCard("instant or sorcery card from your graveyard"));
    if (!player.choose(outcome, target, source.getSourceId(), game)) {
        return true;
    }
    Card card = game.getCard(target.getFirstTarget());
    if (card != null) {
        ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect();
        effect.setTargetPointer(new FixedTarget(card, game));
        game.addEffect(effect, source);
        effect = new MissionBriefingReplacementEffect(card.getId());
        game.addEffect(effect, source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) PlayFromNotOwnHandZoneTargetEffect(mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect) FilterInstantOrSorceryCard(mage.filter.common.FilterInstantOrSorceryCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) ContinuousEffect(mage.abilities.effects.ContinuousEffect) FilterInstantOrSorceryCard(mage.filter.common.FilterInstantOrSorceryCard) Card(mage.cards.Card)

Example 15 with PlayFromNotOwnHandZoneTargetEffect

use of mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect in project mage by magefree.

the class CodieVociferousCodexEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Spell spell = (Spell) getValue("spellCast");
    if (controller == null || spell == null) {
        return false;
    }
    Cards toExile = new CardsImpl();
    Card toCast = null;
    for (Card card : controller.getLibrary().getCards(game)) {
        toExile.add(card);
        if (card.isInstantOrSorcery(game) && card.getManaValue() < spell.getManaValue()) {
            toCast = card;
            break;
        }
    }
    if (toCast == null) {
        controller.moveCards(toExile, Zone.EXILED, source, game);
        controller.putCardsOnBottomOfLibrary(toExile, game, source, false);
        return true;
    }
    controller.moveCards(toCast, Zone.EXILED, source, game);
    PlayFromNotOwnHandZoneTargetEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, TargetController.YOU, Duration.EndOfTurn, true);
    effect.setTargetPointer(new FixedTarget(toCast.getId(), game));
    game.addEffect(effect, source);
    toExile.remove(toCast);
    controller.putCardsOnBottomOfLibrary(toExile, game, source, false);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) PlayFromNotOwnHandZoneTargetEffect(mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect) Spell(mage.game.stack.Spell)

Aggregations

PlayFromNotOwnHandZoneTargetEffect (mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect)21 Player (mage.players.Player)19 FixedTarget (mage.target.targetpointer.FixedTarget)17 Card (mage.cards.Card)16 ContinuousEffect (mage.abilities.effects.ContinuousEffect)12 MageObject (mage.MageObject)9 UUID (java.util.UUID)5 FilterCard (mage.filter.FilterCard)4 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)3 FixedTargets (mage.target.targetpointer.FixedTargets)3 Ability (mage.abilities.Ability)2 ConditionalAsThoughEffect (mage.abilities.decorator.ConditionalAsThoughEffect)2 CardsImpl (mage.cards.CardsImpl)2 FilterInstantOrSorceryCard (mage.filter.common.FilterInstantOrSorceryCard)2 FilterNonlandCard (mage.filter.common.FilterNonlandCard)2 Permanent (mage.game.permanent.Permanent)2 Spell (mage.game.stack.Spell)2 Target (mage.target.Target)2 TargetCard (mage.target.TargetCard)2 TargetCardInYourGraveyard (mage.target.common.TargetCardInYourGraveyard)2