use of mage.game.permanent.token.CustomIllusionToken in project mage by magefree.
the class SkyclaveApparitionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanentLeftBattlefield = (Permanent) getValue("permanentLeftBattlefield");
ExileZone exile = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), permanentLeftBattlefield.getZoneChangeCounter(game)));
if (exile == null || exile.isEmpty()) {
return false;
}
// From ZNR Release Notes:
// https://magic.wizards.com/en/articles/archive/feature/zendikar-rising-release-notes-2020-09-10
// If Skyclave Apparition's first ability exiled more than one card owned by a single player,
// that player creates a token with power and toughness equal to the sum of those cards' converted mana costs.
// If the first ability exiled cards owned by more than one player, each of those players creates a token
// with power and toughness equal to the sum of the converted mana costs of all cards exiled by the first ability.
Set<UUID> owners = new HashSet<>();
int totalCMC = exile.getCards(game).stream().filter(Objects::nonNull).map(card -> owners.add(card.getOwnerId()) ? card : card).mapToInt(MageObject::getManaValue).sum();
for (UUID playerId : owners) {
new CustomIllusionToken(totalCMC).putOntoBattlefield(1, game, source, playerId);
}
return true;
}
Aggregations