use of mage.game.ExileZone in project mage by magefree.
the class IxalansBindingReplacementEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (event.getPlayerId().equals(source.getControllerId())) {
return false;
}
Card card = game.getCard(event.getSourceId());
if (sourcePermanent != null && card != null) {
UUID exileZone = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
if (exileZone != null) {
ExileZone exile = game.getExile().getExileZone(exileZone);
if (exile == null) {
// try without ZoneChangeCounter - that is useful for tokens
exileZone = CardUtil.getCardExileZoneId(game, source);
if (exileZone != null) {
exile = game.getExile().getExileZone(exileZone);
}
}
if (exile != null) {
for (Card e : exile.getCards(game)) {
if (CardUtil.haveSameNames(e, card)) {
return true;
}
}
}
}
}
return false;
}
use of mage.game.ExileZone 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;
}
use of mage.game.ExileZone in project mage by magefree.
the class ProfaneProcessionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
UUID exileId = CardUtil.getCardExileZoneId(game, source);
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && exileId != null && sourceObject != null) {
new ExileTargetEffect(exileId, sourceObject.getIdName()).setTargetPointer(targetPointer).apply(game, source);
game.getState().processAction(game);
ExileZone exileZone = game.getExile().getExileZone(exileId);
if (exileZone != null && exileZone.size() > 2) {
new TransformSourceEffect().apply(game, source);
}
return true;
}
return false;
}
use of mage.game.ExileZone in project mage by magefree.
the class RonaDiscipleOfGixExileEffect method applies.
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
if (affectedControllerId.equals(source.getControllerId())) {
Card card = game.getCard(objectId);
MageObject sourceObject = game.getObject(source.getSourceId());
if (card != null && !card.isLand(game) && sourceObject != null) {
UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), sourceObject.getZoneChangeCounter(game));
if (exileId != null) {
ExileZone exileZone = game.getState().getExile().getExileZone(exileId);
return exileZone != null && exileZone.contains(objectId);
}
}
}
return false;
}
use of mage.game.ExileZone 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