use of mage.game.ExileZone in project mage by magefree.
the class NightveilSpecterEffect method applies.
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
Card theCard = game.getCard(objectId);
if (theCard == null) {
return false;
}
// for split cards
objectId = theCard.getMainCard().getId();
if (affectedControllerId.equals(source.getControllerId()) && game.getState().getZone(objectId) == Zone.EXILED) {
ExileZone zone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source));
return zone != null && zone.contains(objectId);
}
return false;
}
use of mage.game.ExileZone in project mage by magefree.
the class PossibilityStormEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source));
// spell was exiled already by another effect, for example NivMagus Elemental
boolean noLongerOnStack = false;
if (spell == null) {
spell = ((Spell) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.STACK));
noLongerOnStack = true;
}
MageObject sourceObject = source.getSourceObject(game);
if (sourceObject != null && spell != null) {
Player spellController = game.getPlayer(spell.getControllerId());
if (spellController != null) {
if (!noLongerOnStack) {
spellController.moveCardsToExile(spell, source, game, true, source.getSourceId(), sourceObject.getIdName());
}
if (spellController.getLibrary().hasCards()) {
Library library = spellController.getLibrary();
Card card;
do {
card = library.getFromTop(game);
if (card != null) {
spellController.moveCardsToExile(card, source, game, true, source.getSourceId(), sourceObject.getIdName());
}
} while (library.hasCards() && card != null && !sharesType(card, spell.getCardType(game), game));
if (card != null && sharesType(card, spell.getCardType(game), game) && !card.isLand(game) && card.getSpellAbility().canChooseTarget(game, spellController.getId())) {
if (spellController.chooseUse(Outcome.PlayForFree, "Cast " + card.getLogName() + " without paying cost?", source, game)) {
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
spellController.cast(spellController.chooseAbilityForCast(card, game, true), game, true, new ApprovingObject(source, game));
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
}
}
ExileZone exile = game.getExile().getExileZone(source.getSourceId());
if (exile != null) {
spellController.putCardsOnBottomOfLibrary(exile, game, source, false);
}
}
return true;
}
}
return false;
}
use of mage.game.ExileZone in project mage by magefree.
the class SaviorOfOllenbockEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source));
return player != null && exileZone != null && !exileZone.isEmpty() && player.moveCards(exileZone.getCards(game), Zone.BATTLEFIELD, source, game, false, false, true, null);
}
use of mage.game.ExileZone in project mage by magefree.
the class SistersOfStoneDeathEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
CardsImpl cardsInExile = new CardsImpl();
TargetCard target = new TargetCard(Zone.EXILED, StaticFilters.FILTER_CARD_CREATURE);
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
ExileZone exile = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source));
if (exile != null) {
LinkedList<UUID> cards = new LinkedList<>(exile);
for (UUID cardId : cards) {
Card card = game.getCard(cardId);
if (card != null) {
cardsInExile.add(card);
}
}
if (controller.choose(Outcome.PutCreatureInPlay, cardsInExile, target, game)) {
Card chosenCard = game.getCard(target.getFirstTarget());
return controller.moveCards(chosenCard, Zone.BATTLEFIELD, source, game);
}
}
}
return false;
}
use of mage.game.ExileZone in project mage by magefree.
the class ThreeWishesPlayFromExileEffect method applies.
@Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), 0);
ExileZone exile = game.getExile().getExileZone(exileId);
return exile != null && getTargetPointer().getFirst(game, source) != null && getTargetPointer().getFirst(game, source).equals(sourceId) && source.isControlledBy(affectedControllerId) && game.getState().getZone(sourceId) == Zone.EXILED && exile.contains(sourceId);
}
Aggregations