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;
}
Aggregations