Search in sources :

Example 1 with CardsAmountDrawnThisTurnWatcher

use of mage.watchers.common.CardsAmountDrawnThisTurnWatcher 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 2 with CardsAmountDrawnThisTurnWatcher

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

the class NarsetParterOfVeilsEffect method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    CardsAmountDrawnThisTurnWatcher watcher = game.getState().getWatcher(CardsAmountDrawnThisTurnWatcher.class);
    Player controller = game.getPlayer(source.getControllerId());
    return watcher != null && controller != null && watcher.getAmountCardsDrawn(event.getPlayerId()) >= 1 && game.isOpponent(controller, event.getPlayerId());
}
Also used : CardsAmountDrawnThisTurnWatcher(mage.watchers.common.CardsAmountDrawnThisTurnWatcher) Player(mage.players.Player)

Example 3 with CardsAmountDrawnThisTurnWatcher

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

the class LeovoldEmissaryOfTrestTriggeredAbility method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    CardsAmountDrawnThisTurnWatcher watcher = game.getState().getWatcher(CardsAmountDrawnThisTurnWatcher.class);
    Player controller = game.getPlayer(source.getControllerId());
    return watcher != null && controller != null && watcher.getAmountCardsDrawn(event.getPlayerId()) >= 1 && game.isOpponent(controller, event.getPlayerId());
}
Also used : CardsAmountDrawnThisTurnWatcher(mage.watchers.common.CardsAmountDrawnThisTurnWatcher) Player(mage.players.Player)

Example 4 with CardsAmountDrawnThisTurnWatcher

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

the class GodEternalKefnetDrawCardReplacementEffect method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    if (!event.getPlayerId().equals(source.getControllerId())) {
        return false;
    }
    Permanent god = game.getPermanent(source.getSourceId());
    Player you = game.getPlayer(source.getControllerId());
    if (god == null && you == null) {
        return false;
    }
    Card topCard = you.getLibrary().getFromTop(game);
    if (topCard == null) {
        return false;
    }
    // only first draw card
    // if card casted on that turn or controlled changed then needs history from watcher
    CardsAmountDrawnThisTurnWatcher watcher = game.getState().getWatcher(CardsAmountDrawnThisTurnWatcher.class);
    if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) != 0) {
        return false;
    }
    // one time use (if multiple cards drawn)
    String mark = getAppliedMark(game, source);
    if (game.getState().getValue(mark) != null) {
        return false;
    }
    game.getState().setValue(mark, true);
    // ask player to reveal top cards
    String mes = topCard.getName() + ", " + (topCard.isInstantOrSorcery(game) ? HintUtils.prepareText("you can copy it and cast {2} less", Color.green) : HintUtils.prepareText("you can't copy it", Color.red));
    return you.chooseUse(Outcome.Benefit, "Reveal first drawn card (" + mes + ")?", source, game);
}
Also used : Player(mage.players.Player) CardsAmountDrawnThisTurnWatcher(mage.watchers.common.CardsAmountDrawnThisTurnWatcher) Permanent(mage.game.permanent.Permanent)

Aggregations

Player (mage.players.Player)4 CardsAmountDrawnThisTurnWatcher (mage.watchers.common.CardsAmountDrawnThisTurnWatcher)4 Permanent (mage.game.permanent.Permanent)2 DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)1 DrawCardSourceControllerEffect (mage.abilities.effects.common.DrawCardSourceControllerEffect)1 Card (mage.cards.Card)1 CardsImpl (mage.cards.CardsImpl)1 TargetAnyTarget (mage.target.common.TargetAnyTarget)1