Search in sources :

Example 1 with AsThoughEffectImpl

use of mage.abilities.effects.AsThoughEffectImpl 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)

Aggregations

Ability (mage.abilities.Ability)1 PlayLandAbility (mage.abilities.PlayLandAbility)1 SpellAbility (mage.abilities.SpellAbility)1 AsThoughEffect (mage.abilities.effects.AsThoughEffect)1 AsThoughEffectImpl (mage.abilities.effects.AsThoughEffectImpl)1