use of mage.game.ExileZone in project mage by magefree.
the class AshioksErasureReplacementEffect 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) {
return false;
}
UUID exileZone = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
ExileZone exile = game.getExile().getExileZone(exileZone);
if (exile == null) {
// try without ZoneChangeCounter - that is useful for tokens
exileZone = CardUtil.getCardExileZoneId(game, source);
exile = game.getExile().getExileZone(exileZone);
}
if (exile == null) {
return false;
}
Set<Card> cards = exile.getCards(game);
if (cards.isEmpty()) {
return false;
}
Card exiledCard = cards.iterator().next();
if (exiledCard != null) {
return CardUtil.haveSameNames(exiledCard, card);
}
return false;
}
use of mage.game.ExileZone in project mage by magefree.
the class AsmodeusTheArchfiendReturnEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
UUID exileZoneId = (UUID) this.getValue("exileZoneId");
if (controller != null && exileZoneId != null) {
ExileZone exileZone = game.getExile().getExileZone(exileZoneId);
if (exileZone != null) {
int numCards = exileZone.size();
if (numCards > 0) {
controller.moveCards(exileZone, Zone.HAND, source, game);
controller.loseLife(numCards, game, source, false);
return true;
}
}
}
return false;
}
use of mage.game.ExileZone in project mage by magefree.
the class BrainMaggotReturnExiledCardEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (sourceObject != null && controller != null) {
ExileZone exile = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()));
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (exile != null && sourcePermanent != null) {
controller.moveCards(exile, Zone.HAND, source, game);
return true;
}
}
return false;
}
use of mage.game.ExileZone in project mage by magefree.
the class KheruMindEaterLookAtCardEffect method applies.
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
if (affectedControllerId.equals(source.getControllerId())) {
Card card = game.getCard(objectId);
if (card != null) {
MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject == null) {
return false;
}
UUID exileId = CardUtil.getCardExileZoneId(game, source);
ExileZone exile = game.getExile().getExileZone(exileId);
return exile != null && exile.contains(objectId);
}
}
return false;
}
use of mage.game.ExileZone in project mage by magefree.
the class LivingLoreSacrificeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
int zcc = game.getState().getZoneChangeCounter(source.getSourceId());
if (permanent == null) {
permanent = game.getPermanentEntering(source.getSourceId());
zcc++;
}
if (permanent == null) {
return true;
}
UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), zcc);
if (exileId != null) {
ExileZone exileZone = game.getExile().getExileZone(exileId);
if (exileZone == null) {
return false;
}
Card exiledCard = null;
for (Card card : exileZone.getCards(game)) {
exiledCard = card;
break;
}
if (exiledCard != null) {
int value = exiledCard.getManaValue();
permanent.getPower().setValue(value);
permanent.getToughness().setValue(value);
}
}
return true;
}
Aggregations