Search in sources :

Example 1 with SpiritWhiteToken

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

the class MarchOfSoulsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Map<UUID, Integer> playersWithCreatures = new HashMap<>();
    for (Permanent p : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURES, source.getControllerId(), source.getSourceId(), game)) {
        UUID controllerId = p.getControllerId();
        if (p.destroy(source, game, true)) {
            playersWithCreatures.put(controllerId, playersWithCreatures.getOrDefault(controllerId, 0) + 1);
        }
    }
    SpiritWhiteToken token = new SpiritWhiteToken();
    for (Map.Entry<UUID, Integer> destroyedCreaturePerPlayer : playersWithCreatures.entrySet()) {
        token.putOntoBattlefield(destroyedCreaturePerPlayer.getValue(), game, source, destroyedCreaturePerPlayer.getKey());
    }
    return true;
}
Also used : Permanent(mage.game.permanent.Permanent) SpiritWhiteToken(mage.game.permanent.token.SpiritWhiteToken) HashMap(java.util.HashMap) UUID(java.util.UUID) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with SpiritWhiteToken

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

the class KayaGeistHunterEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Cards cards = new CardsImpl();
    game.getState().getPlayersInRange(source.getControllerId(), game).stream().map(game::getPlayer).filter(Objects::nonNull).map(Player::getGraveyard).map(g -> g.getCards(game)).flatMap(Collection::stream).forEach(cards::add);
    player.moveCards(cards, Zone.EXILED, source, game);
    cards.retainZone(Zone.EXILED, game);
    if (cards.isEmpty()) {
        return true;
    }
    new SpiritWhiteToken().putOntoBattlefield(cards.size(), game, source);
    return true;
}
Also used : Player(mage.players.Player) SpiritWhiteToken(mage.game.permanent.token.SpiritWhiteToken) Objects(java.util.Objects) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 3 with SpiritWhiteToken

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

the class OccultEpiphanyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    int xValue = source.getManaCostsToPay().getX();
    if (player == null || xValue < 1) {
        return false;
    }
    player.drawCards(xValue, source, game);
    int cardTypes = player.discard(xValue, false, false, source, game).getCards(game).stream().map(card -> card.getCardType(game)).flatMap(Collection::stream).distinct().mapToInt(x -> 1).sum();
    if (cardTypes > 0) {
        new SpiritWhiteToken().putOntoBattlefield(cardTypes, game, source);
    }
    return true;
}
Also used : CardSetInfo(mage.cards.CardSetInfo) Game(mage.game.Game) SpiritWhiteToken(mage.game.permanent.token.SpiritWhiteToken) CardImpl(mage.cards.CardImpl) Collection(java.util.Collection) CardType(mage.constants.CardType) Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) UUID(java.util.UUID) Player(mage.players.Player) Ability(mage.abilities.Ability) Player(mage.players.Player) SpiritWhiteToken(mage.game.permanent.token.SpiritWhiteToken)

Example 4 with SpiritWhiteToken

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

the class FuneralPyreEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Card exiledCard = game.getCard(source.getFirstTarget());
    if (player == null || exiledCard == null) {
        return false;
    }
    Player owner = game.getPlayer(exiledCard.getOwnerId());
    player.moveCards(exiledCard, Zone.EXILED, source, game);
    if (owner != null) {
        new SpiritWhiteToken().putOntoBattlefield(1, game, source, owner.getId());
    }
    return true;
}
Also used : Player(mage.players.Player) SpiritWhiteToken(mage.game.permanent.token.SpiritWhiteToken) Card(mage.cards.Card)

Example 5 with SpiritWhiteToken

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

the class NotForgottenEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Card targetCard = game.getCard(source.getFirstTarget());
    if (controller != null && targetCard != null) {
        boolean onTop = controller.chooseUse(outcome, "Put " + targetCard.getName() + " on top of it's owners library (otherwise on bottom)?", source, game);
        boolean moved = controller.moveCardToLibraryWithInfo(targetCard, source, game, Zone.GRAVEYARD, onTop, true);
        if (moved) {
            Token token = new SpiritWhiteToken();
            token.putOntoBattlefield(1, game, source, source.getControllerId(), false, false);
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) SpiritWhiteToken(mage.game.permanent.token.SpiritWhiteToken) SpiritWhiteToken(mage.game.permanent.token.SpiritWhiteToken) Token(mage.game.permanent.token.Token) Card(mage.cards.Card)

Aggregations

SpiritWhiteToken (mage.game.permanent.token.SpiritWhiteToken)8 Player (mage.players.Player)5 Permanent (mage.game.permanent.Permanent)3 UUID (java.util.UUID)2 Card (mage.cards.Card)2 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)2 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Objects (java.util.Objects)1 MageObjectReference (mage.MageObjectReference)1 Ability (mage.abilities.Ability)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)1 CreateTokenTargetEffect (mage.abilities.effects.common.CreateTokenTargetEffect)1 CardImpl (mage.cards.CardImpl)1 CardSetInfo (mage.cards.CardSetInfo)1 Cards (mage.cards.Cards)1 CardsImpl (mage.cards.CardsImpl)1 CardType (mage.constants.CardType)1