Search in sources :

Example 1 with CardsPutIntoGraveyardWatcher

use of mage.watchers.common.CardsPutIntoGraveyardWatcher in project mage by magefree.

the class FrayingSanityEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    // In the case that the enchantment is blinked
    Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
    if (enchantment == null) {
        // It was not blinked, use the standard method
        enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
    }
    if (enchantment == null) {
        return false;
    }
    Player enchantedPlayer = game.getPlayer(enchantment.getAttachedTo());
    if (enchantedPlayer != null) {
        CardsPutIntoGraveyardWatcher watcher = game.getState().getWatcher(CardsPutIntoGraveyardWatcher.class);
        if (watcher != null) {
            xAmount = watcher.getAmountCardsPutToGraveyard(enchantedPlayer.getId());
        }
        enchantedPlayer.millCards(xAmount, source, game);
        return true;
    }
    return false;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) CardsPutIntoGraveyardWatcher(mage.watchers.common.CardsPutIntoGraveyardWatcher)

Example 2 with CardsPutIntoGraveyardWatcher

use of mage.watchers.common.CardsPutIntoGraveyardWatcher in project mage by magefree.

the class MyojinOfGrimBetrayalEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    CardsPutIntoGraveyardWatcher watcher = game.getState().getWatcher(CardsPutIntoGraveyardWatcher.class);
    if (controller == null || watcher == null) {
        return false;
    }
    Cards cards = new CardsImpl(watcher.getCardsPutIntoGraveyardFromBattlefield(game));
    cards.removeIf(uuid -> !game.getCard(uuid).isCreature(game));
    return controller.moveCards(cards, Zone.BATTLEFIELD, source, game);
}
Also used : Player(mage.players.Player) CardsPutIntoGraveyardWatcher(mage.watchers.common.CardsPutIntoGraveyardWatcher) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 3 with CardsPutIntoGraveyardWatcher

use of mage.watchers.common.CardsPutIntoGraveyardWatcher in project mage by magefree.

the class ThrillingEncoreEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    CardsPutIntoGraveyardWatcher watcher = game.getState().getWatcher(CardsPutIntoGraveyardWatcher.class);
    if (controller == null || watcher == null) {
        return false;
    }
    Cards cards = new CardsImpl(watcher.getCardsPutIntoGraveyardFromBattlefield(game));
    cards.removeIf(uuid -> !game.getCard(uuid).isCreature(game));
    return controller.moveCards(cards, Zone.BATTLEFIELD, source, game);
}
Also used : Player(mage.players.Player) CardsPutIntoGraveyardWatcher(mage.watchers.common.CardsPutIntoGraveyardWatcher) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 4 with CardsPutIntoGraveyardWatcher

use of mage.watchers.common.CardsPutIntoGraveyardWatcher in project mage by magefree.

the class CryOfTheCarnariumReplacementEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    CardsPutIntoGraveyardWatcher watcher = game.getState().getWatcher(CardsPutIntoGraveyardWatcher.class);
    if (controller == null || watcher == null) {
        return false;
    }
    Cards cards = new CardsImpl(watcher.getCardsPutIntoGraveyardFromBattlefield(game));
    cards.removeIf(uuid -> !game.getCard(uuid).isCreature(game));
    return controller.moveCards(cards, Zone.EXILED, source, game);
}
Also used : Player(mage.players.Player) CardsPutIntoGraveyardWatcher(mage.watchers.common.CardsPutIntoGraveyardWatcher) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Aggregations

Player (mage.players.Player)4 CardsPutIntoGraveyardWatcher (mage.watchers.common.CardsPutIntoGraveyardWatcher)4 Cards (mage.cards.Cards)3 CardsImpl (mage.cards.CardsImpl)3 Permanent (mage.game.permanent.Permanent)1 TargetPlayer (mage.target.TargetPlayer)1