Search in sources :

Example 1 with CreatureWasCastWatcher

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

the class UphillBattleTapEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    Permanent target = ((EntersTheBattlefieldEvent) event).getTarget();
    CreatureWasCastWatcher creatureSpellWatcher = game.getState().getWatcher(CreatureWasCastWatcher.class);
    PlayCreatureLandWatcher landWatcher = game.getState().getWatcher(PlayCreatureLandWatcher.class);
    if (target != null && ((creatureSpellWatcher != null && creatureSpellWatcher.wasCreatureCastThisTurn(target.getId())) || (landWatcher != null && landWatcher.wasLandPlayed(target.getId())))) {
        target.setTapped(true);
    }
    return false;
}
Also used : Permanent(mage.game.permanent.Permanent) EntersTheBattlefieldEvent(mage.game.events.EntersTheBattlefieldEvent) CreatureWasCastWatcher(mage.watchers.common.CreatureWasCastWatcher)

Example 2 with CreatureWasCastWatcher

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

the class ContainmentPriestReplacementEffect method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    if (((ZoneChangeEvent) event).getToZone() == Zone.BATTLEFIELD) {
        Object entersTransformed = game.getState().getValue(TransformAbility.VALUE_KEY_ENTER_TRANSFORMED + event.getTargetId());
        Card card = game.getCard(event.getTargetId());
        if (card != null && entersTransformed instanceof Boolean && (Boolean) entersTransformed && card.getSecondCardFace() != null) {
            card = card.getSecondCardFace();
        }
        if (card != null && card.isCreature(game)) {
            // TODO: Bestow Card cast as Enchantment probably not handled correctly
            CreatureWasCastWatcher watcher = game.getState().getWatcher(CreatureWasCastWatcher.class);
            return watcher != null && !watcher.wasCreatureCastThisTurn(event.getTargetId());
        }
    }
    return false;
}
Also used : CreatureWasCastWatcher(mage.watchers.common.CreatureWasCastWatcher) Card(mage.cards.Card)

Aggregations

CreatureWasCastWatcher (mage.watchers.common.CreatureWasCastWatcher)2 Card (mage.cards.Card)1 EntersTheBattlefieldEvent (mage.game.events.EntersTheBattlefieldEvent)1 Permanent (mage.game.permanent.Permanent)1