Search in sources :

Example 1 with BecomesBlackZombieAdditionEffect

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

the class NecromanticSelectionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (sourceObject != null && controller != null) {
        Cards cards = new CardsImpl();
        for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), source.getSourceId(), game)) {
            permanent.destroy(source, game, false);
            // Meren of the Clan Nel Toth bug #8515
            game.checkStateAndTriggered();
            if (game.getState().getZone(permanent.getId()) == Zone.GRAVEYARD) {
                cards.add(permanent);
            }
        }
        FilterCard filter = new FilterCreatureCard("creature card put into a graveyard with " + sourceObject.getLogName());
        List<Predicate<MageObject>> cardIdPredicates = new ArrayList<>();
        for (UUID cardId : cards) {
            cardIdPredicates.add(new CardIdPredicate(cardId));
        }
        filter.add(Predicates.or(cardIdPredicates));
        Target target = new TargetCardInGraveyard(filter);
        target.setNotTarget(true);
        if (controller.chooseTarget(Outcome.Benefit, target, source, game)) {
            Card card = game.getCard(target.getFirstTarget());
            if (card != null) {
                controller.moveCards(card, Zone.BATTLEFIELD, source, game);
                ContinuousEffect effect = new BecomesBlackZombieAdditionEffect();
                effect.setText("It's a black Zombie in addition to its other colors and types");
                effect.setTargetPointer(new FixedTarget(card.getId(), game));
                game.addEffect(effect, source);
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) MageObject(mage.MageObject) ArrayList(java.util.ArrayList) BecomesBlackZombieAdditionEffect(mage.abilities.effects.common.continuous.BecomesBlackZombieAdditionEffect) Predicate(mage.filter.predicate.Predicate) CardIdPredicate(mage.filter.predicate.mageobject.CardIdPredicate) FilterCreatureCard(mage.filter.common.FilterCreatureCard) FilterCard(mage.filter.FilterCard) FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID) CardIdPredicate(mage.filter.predicate.mageobject.CardIdPredicate)

Example 2 with BecomesBlackZombieAdditionEffect

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

the class GraveBetrayalReplacementEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
    if (creature != null) {
        creature.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game, event.getAppliedEffects());
        ContinuousEffect effect = new BecomesBlackZombieAdditionEffect();
        effect.setTargetPointer(new FixedTarget(creature.getId(), creature.getZoneChangeCounter(game) + 1));
        game.addEffect(effect, source);
    // discard(); why?
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) EntersTheBattlefieldEvent(mage.game.events.EntersTheBattlefieldEvent) BecomesBlackZombieAdditionEffect(mage.abilities.effects.common.continuous.BecomesBlackZombieAdditionEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Example 3 with BecomesBlackZombieAdditionEffect

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

the class DreadSlaverEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    Card card = game.getCard(targetPointer.getFirst(game, source));
    if (card != null) {
        if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
            ContinuousEffect effect = new BecomesBlackZombieAdditionEffect();
            effect.setTargetPointer(new FixedTarget(card.getId(), game));
            game.addEffect(effect, source);
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) BecomesBlackZombieAdditionEffect(mage.abilities.effects.common.continuous.BecomesBlackZombieAdditionEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Card(mage.cards.Card)

Example 4 with BecomesBlackZombieAdditionEffect

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

the class SummonThePackEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    ChooseExpansionSetEffect effect = new ChooseExpansionSetEffect(Outcome.UnboostCreature);
    effect.apply(game, source);
    Player controller = game.getPlayer(source.getControllerId());
    String setChosen = null;
    if (effect.getValue("setchosen") != null) {
        setChosen = (String) effect.getValue("setchosen");
    } else if (game.getState().getValue(this.getId() + "_set") != null) {
        setChosen = (String) game.getState().getValue(this.getId() + "_set");
    }
    if (setChosen != null && controller != null) {
        // ExpansionInfo set = ExpansionRepository.instance.getSetByName(setChosen);
        ExpansionSet expansionSet = Sets.findSet(setChosen);
        if (expansionSet != null) {
            List<Card> boosterPack = expansionSet.create15CardBooster();
            List<Card> creatureCards = new ArrayList<>();
            if (boosterPack != null) {
                StringBuilder message = new StringBuilder(controller.getLogName()).append(" opened: ");
                for (Card c : boosterPack) {
                    if (c != null && c.isCreature(game)) {
                        message.append(c.getName()).append(" ");
                        message.append(" (creature card) ");
                        ContinuousEffect effect2 = new BecomesBlackZombieAdditionEffect(false);
                        effect2.setTargetPointer(new FixedTarget(c.getId()));
                        game.addEffect(effect2, source);
                        creatureCards.add(c);
                        c.setZone(Zone.OUTSIDE, game);
                    }
                }
                if (creatureCards.size() > 0) {
                    Set<Card> ccs = new HashSet<>(creatureCards);
                    game.loadCards(ccs, controller.getId());
                    controller.moveCards(ccs, Zone.BATTLEFIELD, source, game);
                }
                game.informPlayers(message.toString());
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) ArrayList(java.util.ArrayList) BecomesBlackZombieAdditionEffect(mage.abilities.effects.common.continuous.BecomesBlackZombieAdditionEffect) ExpansionSet(mage.cards.ExpansionSet) Card(mage.cards.Card) ChooseExpansionSetEffect(mage.abilities.effects.common.ChooseExpansionSetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) HashSet(java.util.HashSet)

Aggregations

ContinuousEffect (mage.abilities.effects.ContinuousEffect)4 BecomesBlackZombieAdditionEffect (mage.abilities.effects.common.continuous.BecomesBlackZombieAdditionEffect)4 FixedTarget (mage.target.targetpointer.FixedTarget)4 Player (mage.players.Player)3 ArrayList (java.util.ArrayList)2 Card (mage.cards.Card)2 Permanent (mage.game.permanent.Permanent)2 HashSet (java.util.HashSet)1 UUID (java.util.UUID)1 MageObject (mage.MageObject)1 ChooseExpansionSetEffect (mage.abilities.effects.common.ChooseExpansionSetEffect)1 ExpansionSet (mage.cards.ExpansionSet)1 FilterCard (mage.filter.FilterCard)1 FilterCreatureCard (mage.filter.common.FilterCreatureCard)1 Predicate (mage.filter.predicate.Predicate)1 CardIdPredicate (mage.filter.predicate.mageobject.CardIdPredicate)1 EntersTheBattlefieldEvent (mage.game.events.EntersTheBattlefieldEvent)1 Target (mage.target.Target)1 TargetCardInGraveyard (mage.target.common.TargetCardInGraveyard)1