Search in sources :

Example 1 with MorphAbility

use of mage.abilities.keyword.MorphAbility in project mage by magefree.

the class BecomesFaceDownCreatureAllEffect method init.

@Override
public void init(Ability source, Game game) {
    super.init(source, game);
    for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
        if (!perm.isFaceDown(game) && !perm.isTransformable()) {
            affectedObjectList.add(new MageObjectReference(perm, game));
            perm.setFaceDown(true, game);
            // check for Morph
            Card card = game.getCard(perm.getId());
            if (card != null) {
                for (Ability ability : card.getAbilities(game)) {
                    if (ability instanceof MorphAbility) {
                        this.turnFaceUpAbilityMap.put(card.getId(), new TurnFaceUpAbility(((MorphAbility) ability).getMorphCosts()));
                    }
                }
            }
        }
    }
}
Also used : TurnFaceUpAbility(mage.abilities.common.TurnFaceUpAbility) MorphAbility(mage.abilities.keyword.MorphAbility) Ability(mage.abilities.Ability) MorphAbility(mage.abilities.keyword.MorphAbility) Permanent(mage.game.permanent.Permanent) FilterPermanent(mage.filter.FilterPermanent) TurnFaceUpAbility(mage.abilities.common.TurnFaceUpAbility) MageObjectReference(mage.MageObjectReference) Card(mage.cards.Card)

Example 2 with MorphAbility

use of mage.abilities.keyword.MorphAbility in project mage by magefree.

the class CastAsThoughItHadFlashAllEffect method applies.

@Override
public boolean applies(UUID affectedSpellId, Ability source, UUID affectedControllerId, Game game) {
    if (anyPlayer || source.isControlledBy(affectedControllerId)) {
        Card card = game.getCard(affectedSpellId);
        if (card != null) {
            // Allow lands with morph to be played at instant speed
            if (card.isLand(game)) {
                boolean morphAbility = card.getAbilities().stream().anyMatch(ability -> ability instanceof MorphAbility);
                if (morphAbility) {
                    Card cardCopy = card.copy();
                    cardCopy.removeAllCardTypes(game);
                    cardCopy.addCardType(game, CardType.CREATURE);
                    return filter.match(cardCopy, source.getSourceId(), affectedControllerId, game);
                }
            }
            return filter.match(card, source.getSourceId(), affectedControllerId, game);
        }
    }
    return false;
}
Also used : MorphAbility(mage.abilities.keyword.MorphAbility) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Aggregations

MorphAbility (mage.abilities.keyword.MorphAbility)2 Card (mage.cards.Card)2 MageObjectReference (mage.MageObjectReference)1 Ability (mage.abilities.Ability)1 TurnFaceUpAbility (mage.abilities.common.TurnFaceUpAbility)1 FilterCard (mage.filter.FilterCard)1 FilterPermanent (mage.filter.FilterPermanent)1 Permanent (mage.game.permanent.Permanent)1