Search in sources :

Example 1 with ZombieToken

use of mage.game.permanent.token.ZombieToken in project mage by magefree.

the class NoosegrafMobEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getSourceId());
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && permanent != null && permanent.getCounters(game).getCount(CounterType.P1P1) > 0) {
        permanent.removeCounters(CounterType.P1P1.createInstance(), source, game);
        Effect effect = new CreateTokenEffect(new ZombieToken());
        return effect.apply(game, source);
    }
    return false;
}
Also used : Player(mage.players.Player) ZombieToken(mage.game.permanent.token.ZombieToken) Permanent(mage.game.permanent.Permanent) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) Effect(mage.abilities.effects.Effect) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect)

Example 2 with ZombieToken

use of mage.game.permanent.token.ZombieToken in project mage by magefree.

the class AwakenTheErstwhileEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        // discard hands
        Map<UUID, Integer> cardsAmount = new HashMap<>();
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            Player player = game.getPlayer(playerId);
            if (player != null) {
                int cardsInHand = player.getHand().size();
                if (cardsInHand > 0) {
                    player.discard(cardsInHand, false, false, source, game);
                    cardsAmount.put(playerId, cardsInHand);
                }
            }
        }
        // create tokens
        cardsAmount.entrySet().forEach(discardedHand -> {
            Player player = game.getPlayer(discardedHand.getKey());
            int tokensCount = discardedHand.getValue();
            if (player != null && tokensCount > 0) {
                new ZombieToken().putOntoBattlefield(tokensCount, game, source, player.getId());
            }
        });
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) ZombieToken(mage.game.permanent.token.ZombieToken) HashMap(java.util.HashMap) UUID(java.util.UUID)

Example 3 with ZombieToken

use of mage.game.permanent.token.ZombieToken in project mage by magefree.

the class MidnightRitualEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Cards cardsToExile = new CardsImpl(getTargetPointer().getTargets(game, source));
        controller.moveCards(cardsToExile, Zone.EXILED, source, game);
        if (!cardsToExile.isEmpty()) {
            new ZombieToken().putOntoBattlefield(cardsToExile.size(), game, source, controller.getId());
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) ZombieToken(mage.game.permanent.token.ZombieToken) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 4 with ZombieToken

use of mage.game.permanent.token.ZombieToken in project mage by magefree.

the class NecromentiaEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY);
    Player controller = game.getPlayer(source.getControllerId());
    if (cardName != null && controller != null) {
        FilterCard filter = new FilterCard("card named " + cardName);
        filter.add(new NamePredicate(cardName));
        Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
        // cards in Graveyard
        int cardsCount = (cardName.isEmpty() ? 0 : targetPlayer.getGraveyard().count(filter, game));
        if (cardsCount > 0) {
            filter.setMessage("card named " + cardName + " in the graveyard of " + targetPlayer.getName());
            TargetCard target = new TargetCard(0, cardsCount, Zone.GRAVEYARD, filter);
            if (controller.choose(Outcome.Exile, targetPlayer.getGraveyard(), target, game)) {
                controller.moveCards(new CardsImpl(target.getTargets()), Zone.EXILED, source, game);
            }
        }
        // cards in Hand
        int numberOfCardsExiledFromHand = 0;
        cardsCount = (cardName.isEmpty() ? 0 : targetPlayer.getHand().count(filter, game));
        if (cardsCount > 0) {
            filter.setMessage("card named " + cardName + " in the hand of " + targetPlayer.getName());
            TargetCard target = new TargetCard(0, cardsCount, Zone.HAND, filter);
            if (controller.choose(Outcome.Exile, targetPlayer.getHand(), target, game)) {
                numberOfCardsExiledFromHand = target.getTargets().size();
                controller.moveCards(new CardsImpl(target.getTargets()), Zone.EXILED, source, game);
            }
        } else {
            targetPlayer.revealCards(targetPlayer.getName() + "'s Hand", targetPlayer.getHand(), game);
        }
        // cards in Library
        Cards cardsInLibrary = new CardsImpl();
        cardsInLibrary.addAll(targetPlayer.getLibrary().getCards(game));
        cardsCount = (cardName.isEmpty() ? 0 : cardsInLibrary.count(filter, game));
        if (cardsCount > 0) {
            filter.setMessage("card named " + cardName + " in the library of " + targetPlayer.getLogName());
            TargetCardInLibrary targetLib = new TargetCardInLibrary(0, cardsCount, filter);
            if (controller.choose(Outcome.Exile, cardsInLibrary, targetLib, game)) {
                controller.moveCards(new CardsImpl(targetLib.getTargets()), Zone.EXILED, source, game);
            }
        } else {
            targetPlayer.revealCards(targetPlayer.getName() + "'s Library", new CardsImpl(new HashSet<>(targetPlayer.getLibrary().getCards(game))), game);
        }
        targetPlayer.shuffleLibrary(source, game);
        if (numberOfCardsExiledFromHand > 0) {
            game.getState().applyEffects(game);
            Token zombieToken = new ZombieToken();
            zombieToken.putOntoBattlefield(numberOfCardsExiledFromHand, game, source, targetPlayer.getId());
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) ZombieToken(mage.game.permanent.token.ZombieToken) TargetCard(mage.target.TargetCard) Token(mage.game.permanent.token.Token) ZombieToken(mage.game.permanent.token.ZombieToken) CardsImpl(mage.cards.CardsImpl) Cards(mage.cards.Cards) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) HashSet(java.util.HashSet)

Example 5 with ZombieToken

use of mage.game.permanent.token.ZombieToken in project mage by magefree.

the class NecromancersConvenantEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player player = game.getPlayer(source.getFirstTarget());
    if (controller == null || player == null) {
        return false;
    }
    Set<Card> cards = player.getGraveyard().getCards(new FilterCreatureCard(), game);
    UUID exileId = CardUtil.getCardExileZoneId(game, source);
    // a previous refactor removed the exile code.  Just putting it back.
    controller.moveCardsToExile(cards, source, game, true, exileId, "Necromancer's Convenant");
    ExileZone exileZone = game.getState().getExile().getExileZone(exileId);
    if (exileZone != null) {
        int count = exileZone.getCards(game).size();
        return count > 0 && new ZombieToken().putOntoBattlefield(count, game, source, controller.getId());
    }
    return false;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) ZombieToken(mage.game.permanent.token.ZombieToken) ExileZone(mage.game.ExileZone) UUID(java.util.UUID) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card)

Aggregations

ZombieToken (mage.game.permanent.token.ZombieToken)11 Player (mage.players.Player)11 UUID (java.util.UUID)5 Permanent (mage.game.permanent.Permanent)5 TargetPlayer (mage.target.TargetPlayer)4 Effect (mage.abilities.effects.Effect)3 OneShotEffect (mage.abilities.effects.OneShotEffect)3 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)3 HashSet (java.util.HashSet)2 AttachEffect (mage.abilities.effects.common.AttachEffect)2 CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)2 CreateTokenTargetEffect (mage.abilities.effects.common.CreateTokenTargetEffect)2 Card (mage.cards.Card)2 Cards (mage.cards.Cards)2 CardsImpl (mage.cards.CardsImpl)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 AddCountersSourceEffect (mage.abilities.effects.common.counter.AddCountersSourceEffect)1 FilterCard (mage.filter.FilterCard)1 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)1