Search in sources :

Example 1 with TombspawnZombieToken

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

the class TombstoneStairwellDestroyEffect method apply.

@Override
@SuppressWarnings("unchecked")
public boolean apply(Game game, Ability source) {
    Token token = new TombspawnZombieToken();
    Player activePlayer = game.getPlayer(game.getActivePlayerId());
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (game.getPlayer(source.getControllerId()) != null && activePlayer != null && permanent != null) {
        Object object = game.getState().getValue(CardUtil.getCardZoneString("_tokensCreated", source.getSourceId(), game));
        Set<UUID> tokensCreated;
        if (object != null) {
            tokensCreated = (Set<UUID>) object;
        } else {
            tokensCreated = new HashSet<>();
        }
        for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
            Player player = game.getPlayer(playerId);
            int creatureCardsInGraveyard = player.getGraveyard().count(StaticFilters.FILTER_CARD_CREATURE, source.getControllerId(), source.getSourceId(), game);
            token.putOntoBattlefield(creatureCardsInGraveyard, game, source, playerId);
            for (UUID tokenId : token.getLastAddedTokenIds()) {
                tokensCreated.add(tokenId);
            }
        }
        game.getState().setValue(CardUtil.getCardZoneString("_tokensCreated", source.getSourceId(), game), tokensCreated);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) TombspawnZombieToken(mage.game.permanent.token.TombspawnZombieToken) Permanent(mage.game.permanent.Permanent) Token(mage.game.permanent.token.Token) TombspawnZombieToken(mage.game.permanent.token.TombspawnZombieToken) UUID(java.util.UUID)

Aggregations

UUID (java.util.UUID)1 Permanent (mage.game.permanent.Permanent)1 Token (mage.game.permanent.token.Token)1 TombspawnZombieToken (mage.game.permanent.token.TombspawnZombieToken)1 Player (mage.players.Player)1