Search in sources :

Example 1 with AsThoughEffect

use of mage.abilities.effects.AsThoughEffect in project mage by magefree.

the class WordOfCommandTestFlashEffect method checkPlayability.

private boolean checkPlayability(Card card, Player targetPlayer, Game game, Ability source) {
    // check for card playability
    boolean canPlay = false;
    if (card.isLand(game)) {
        // we can't use getPlayableObjects(game) in here because it disallows playing lands outside the main step // TODO: replace to getPlayable() checks with disable step condition?
        if (targetPlayer.canPlayLand() && game.getActivePlayerId().equals(targetPlayer.getId())) {
            for (Ability ability : card.getAbilities(game)) {
                if (ability instanceof PlayLandAbility) {
                    if (!game.getContinuousEffects().preventedByRuleModification(GameEvent.getEvent(GameEvent.EventType.PLAY_LAND, ability.getSourceId(), ability, targetPlayer.getId()), ability, game, true)) {
                        canPlay = true;
                    }
                }
            }
        }
    } else {
        // Word of Command allows the chosen card to be played "as if it had flash" so we need to invoke such effect to bypass the check
        AsThoughEffectImpl effect2 = new WordOfCommandTestFlashEffect();
        game.addEffect(effect2, source);
        if (targetPlayer.getPlayableObjects(game, Zone.HAND).containsObject(card.getId())) {
            canPlay = true;
        }
        for (AsThoughEffect eff : game.getContinuousEffects().getApplicableAsThoughEffects(AsThoughEffectType.CAST_AS_INSTANT, game)) {
            if (eff instanceof WordOfCommandTestFlashEffect) {
                eff.discard();
                break;
            }
        }
    }
    return canPlay;
}
Also used : PlayLandAbility(mage.abilities.PlayLandAbility) SpellAbility(mage.abilities.SpellAbility) Ability(mage.abilities.Ability) PlayLandAbility(mage.abilities.PlayLandAbility) AsThoughEffect(mage.abilities.effects.AsThoughEffect) AsThoughEffectImpl(mage.abilities.effects.AsThoughEffectImpl)

Example 2 with AsThoughEffect

use of mage.abilities.effects.AsThoughEffect in project mage by magefree.

the class PlaneswalkersMischiefCondition method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player opponent = game.getPlayer(source.getFirstTarget());
    if (opponent != null && opponent.getHand().size() > 0) {
        Card revealedCard = opponent.getHand().getRandom(game);
        if (revealedCard == null) {
            return false;
        }
        Cards cards = new CardsImpl(revealedCard);
        opponent.revealCards(source, cards, game);
        if (revealedCard.isInstant(game) || revealedCard.isSorcery(game)) {
            opponent.moveCardToExileWithInfo(revealedCard, source.getSourceId(), "Planeswalker's Mischief", source, game, Zone.HAND, true);
            AsThoughEffect effect = new PlaneswalkersMischiefCastFromExileEffect();
            effect.setTargetPointer(new FixedTarget(revealedCard.getId()));
            game.addEffect(effect, source);
            OneShotEffect effect2 = new ReturnFromExileEffect(Zone.HAND);
            Condition condition = new PlaneswalkersMischiefCondition(source.getSourceId(), revealedCard.getId());
            ConditionalOneShotEffect effect3 = new ConditionalOneShotEffect(effect2, condition, "if you haven't cast it, return it to its owner's hand.");
            DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect3);
            delayedAbility.addWatcher(new SpellsCastWatcher());
            game.addDelayedTriggeredAbility(delayedAbility, source);
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Condition(mage.abilities.condition.Condition) Player(mage.players.Player) ReturnFromExileEffect(mage.abilities.effects.common.ReturnFromExileEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) ConditionalOneShotEffect(mage.abilities.decorator.ConditionalOneShotEffect) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) AsThoughEffect(mage.abilities.effects.AsThoughEffect) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) SpellsCastWatcher(mage.watchers.common.SpellsCastWatcher) ConditionalOneShotEffect(mage.abilities.decorator.ConditionalOneShotEffect)

Aggregations

AsThoughEffect (mage.abilities.effects.AsThoughEffect)2 Ability (mage.abilities.Ability)1 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)1 PlayLandAbility (mage.abilities.PlayLandAbility)1 SpellAbility (mage.abilities.SpellAbility)1 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)1 Condition (mage.abilities.condition.Condition)1 ConditionalOneShotEffect (mage.abilities.decorator.ConditionalOneShotEffect)1 AsThoughEffectImpl (mage.abilities.effects.AsThoughEffectImpl)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 ReturnFromExileEffect (mage.abilities.effects.common.ReturnFromExileEffect)1 Player (mage.players.Player)1 FixedTarget (mage.target.targetpointer.FixedTarget)1 SpellsCastWatcher (mage.watchers.common.SpellsCastWatcher)1