Search in sources :

Example 6 with BecomesFaceDownCreatureEffect

use of mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect in project mage by magefree.

the class ManifestEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Ability newSource = source.copy();
        newSource.setWorksFaceDown(true);
        Set<Card> cards = controller.getLibrary().getTopCards(game, amount);
        for (Card card : cards) {
            ManaCosts manaCosts = null;
            if (card.isCreature(game)) {
                manaCosts = card.getSpellAbility() != null ? card.getSpellAbility().getManaCosts() : null;
                if (manaCosts == null) {
                    manaCosts = new ManaCostsImpl("{0}");
                }
            }
            MageObjectReference objectReference = new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) + 1, game);
            game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource);
        }
        controller.moveCards(cards, Zone.BATTLEFIELD, source, game, false, true, false, null);
        for (Card card : cards) {
            Permanent permanent = game.getPermanent(card.getId());
            if (permanent != null) {
                permanent.setManifested(true);
            }
        }
        return true;
    }
    return false;
}
Also used : Ability(mage.abilities.Ability) ManaCosts(mage.abilities.costs.mana.ManaCosts) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) MageObjectReference(mage.MageObjectReference) Card(mage.cards.Card) BecomesFaceDownCreatureEffect(mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect)

Example 7 with BecomesFaceDownCreatureEffect

use of mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect in project mage by magefree.

the class ThievingAmalgamLifeLossEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player active = game.getPlayer(game.getActivePlayerId());
    if (controller == null || active == null) {
        return false;
    }
    Ability newSource = source.copy();
    newSource.setWorksFaceDown(true);
    Set<Card> cards = active.getLibrary().getTopCards(game, 1);
    cards.stream().forEach(card -> {
        ManaCosts manaCosts = null;
        if (card.isCreature(game)) {
            manaCosts = card.getSpellAbility() != null ? card.getSpellAbility().getManaCosts() : null;
            if (manaCosts == null) {
                manaCosts = new ManaCostsImpl("{0}");
            }
        }
        MageObjectReference objectReference = new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) + 1, game);
        game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, BecomesFaceDownCreatureEffect.FaceDownType.MANIFESTED), newSource);
    });
    controller.moveCards(cards, Zone.BATTLEFIELD, source, game, false, true, false, null);
    cards.stream().map(Card::getId).map(game::getPermanent).filter(permanent -> permanent != null).forEach(permanent -> permanent.setManifested(true));
    return true;
}
Also used : DiesCreatureTriggeredAbility(mage.abilities.common.DiesCreatureTriggeredAbility) BeginningOfUpkeepTriggeredAbility(mage.abilities.common.BeginningOfUpkeepTriggeredAbility) Ability(mage.abilities.Ability) ManaCosts(mage.abilities.costs.mana.ManaCosts) DiesCreatureTriggeredAbility(mage.abilities.common.DiesCreatureTriggeredAbility) ManaCosts(mage.abilities.costs.mana.ManaCosts) Set(java.util.Set) MageObjectReference(mage.MageObjectReference) OneShotEffect(mage.abilities.effects.OneShotEffect) UUID(java.util.UUID) MageInt(mage.MageInt) FilterPermanent(mage.filter.FilterPermanent) Player(mage.players.Player) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect) CardSetInfo(mage.cards.CardSetInfo) BeginningOfUpkeepTriggeredAbility(mage.abilities.common.BeginningOfUpkeepTriggeredAbility) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) Game(mage.game.Game) Effect(mage.abilities.effects.Effect) CardImpl(mage.cards.CardImpl) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) BecomesFaceDownCreatureEffect(mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect) Card(mage.cards.Card) mage.constants(mage.constants) Ability(mage.abilities.Ability) Player(mage.players.Player) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) MageObjectReference(mage.MageObjectReference) Card(mage.cards.Card) BecomesFaceDownCreatureEffect(mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect)

Aggregations

MageObjectReference (mage.MageObjectReference)7 BecomesFaceDownCreatureEffect (mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect)7 Ability (mage.abilities.Ability)6 ManaCosts (mage.abilities.costs.mana.ManaCosts)6 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)6 Card (mage.cards.Card)6 Player (mage.players.Player)6 UUID (java.util.UUID)3 Permanent (mage.game.permanent.Permanent)3 Set (java.util.Set)2 OneShotEffect (mage.abilities.effects.OneShotEffect)2 CardImpl (mage.cards.CardImpl)2 CardSetInfo (mage.cards.CardSetInfo)2 Game (mage.game.Game)2 HashSet (java.util.HashSet)1 Objects (java.util.Objects)1 Collectors (java.util.stream.Collectors)1 MageInt (mage.MageInt)1 BeginningOfUpkeepTriggeredAbility (mage.abilities.common.BeginningOfUpkeepTriggeredAbility)1 DealsCombatDamageToAPlayerTriggeredAbility (mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility)1