use of mage.game.ExileZone in project mage by magefree.
the class UnderworldSentinelEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()));
return exileZone != null && controller.moveCards(exileZone, Zone.BATTLEFIELD, source, game);
}
use of mage.game.ExileZone in project mage by magefree.
the class InducedAmnesiaReturnEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source));
return controller != null && exileZone != null && !exileZone.isEmpty() && controller.moveCards(exileZone, Zone.HAND, source, game);
}
use of mage.game.ExileZone in project mage by magefree.
the class MirrorGolemEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent sourceObject = game.getPermanent(source.getSourceId());
ExileZone exileZone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source.getSourceId()));
if (sourceObject == null || sourceObject.getImprinted() == null) {
return false;
}
for (UUID imprinted : sourceObject.getImprinted()) {
if (imprinted != null && exileZone.contains(imprinted)) {
Card card = game.getCard(imprinted);
if (card != null) {
for (CardType cardType : card.getCardType(game)) {
FilterCard filterCard;
if (cardType.equals(CardType.SORCERY)) {
filterCard = new FilterCard("sorceries");
} else if (cardType.equals(CardType.TRIBAL)) {
filterCard = new FilterCard("tribal");
} else {
filterCard = new FilterCard(cardType.toString() + "s");
}
filterCard.add(cardType.getPredicate());
sourceObject.addAbility(new ProtectionAbility(filterCard), source.getSourceId(), game);
}
}
}
}
return true;
}
use of mage.game.ExileZone in project mage by magefree.
the class PraetorsGraspRevealEffect method applies.
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
if (objectId.equals(cardId) && affectedControllerId.equals(source.getControllerId())) {
Player controller = game.getPlayer(source.getControllerId());
UUID exileId = CardUtil.getExileZoneId(cardId.toString() + game.getState().getZoneChangeCounter(cardId), game);
if (exileId != null && controller != null) {
ExileZone exileZone = game.getExile().getExileZone(exileId);
if (exileZone != null && exileZone.contains(cardId)) {
return true;
} else {
discard();
}
}
}
return false;
}
use of mage.game.ExileZone in project mage by magefree.
the class SearchTheCityExiledCardToHandEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getPlayerId().equals(this.getControllerId())) {
String cardName = "";
if (event.getType() == GameEvent.EventType.SPELL_CAST) {
Spell spell = game.getStack().getSpell(event.getTargetId());
if (spell != null) {
cardName = spell.getName();
}
}
if (event.getType() == GameEvent.EventType.LAND_PLAYED) {
Card card = game.getCard(event.getTargetId());
if (card != null) {
cardName = card.getName();
}
}
if (!cardName.isEmpty()) {
ExileZone searchTheCityExileZone = game.getExile().getExileZone(this.getSourceId());
FilterCard filter = new FilterCard();
filter.add(new NamePredicate(cardName));
if (searchTheCityExileZone.count(filter, game) > 0) {
this.getEffects().get(0).setValue("cardName", cardName);
return true;
}
}
}
return false;
}
Aggregations