use of mage.game.ExileZone in project mage by magefree.
the class HideawayLookAtFaceDownCardEffect method applies.
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
if (game.getState().getZone(objectId) != Zone.EXILED || !game.getState().getCardState(objectId).isFaceDown()) {
return false;
}
// TODO: Does not handle if a player had the control of the land permanent some time before
// we would need to add a watcher to handle this
Permanent sourcePermanet = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (sourcePermanet != null && sourcePermanet.isControlledBy(affectedControllerId)) {
ExileZone exile = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source));
Card card = game.getCard(objectId);
if (exile != null && exile.contains(objectId) && card != null) {
Player player = game.getPlayer(affectedControllerId);
if (player != null) {
player.lookAtCards("Hideaway by " + sourcePermanet.getIdName(), card, game);
}
}
}
// only the current or a previous controller can see the card, so always return false for reveal request
return false;
}
use of mage.game.ExileZone in project mage by magefree.
the class ReboundCastSpellFromExileEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
ExileZone zone = game.getExile().getExileZone(source.getSourceId());
if (zone == null || zone.isEmpty()) {
return false;
}
Card reboundCard = zone.get(source.getSourceId(), game);
Player player = game.getPlayer(source.getControllerId());
if (player != null && reboundCard != null) {
game.getState().setValue("PlayFromNotOwnHandZone" + reboundCard.getId(), Boolean.TRUE);
Boolean cardWasCast = player.cast(player.chooseAbilityForCast(reboundCard, game, true), game, true, new ApprovingObject(source, game));
game.getState().setValue("PlayFromNotOwnHandZone" + reboundCard.getId(), null);
return cardWasCast;
}
return false;
}
use of mage.game.ExileZone in project mage by magefree.
the class AminatousAuguryCastFromExileEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
// move cards from library to exile
controller.moveCardsToExile(controller.getLibrary().getTopCards(game, 8), source, game, true, source.getSourceId(), CardUtil.createObjectRealtedWindowTitle(source, game, null));
ExileZone auguryExileZone = game.getExile().getExileZone(source.getSourceId());
if (auguryExileZone == null) {
return true;
}
Cards cardsToCast = new CardsImpl();
cardsToCast.addAll(auguryExileZone.getCards(game));
// put a land card from among them onto the battlefield
TargetCard target = new TargetCard(Zone.EXILED, StaticFilters.FILTER_CARD_LAND_A);
if (cardsToCast.count(StaticFilters.FILTER_CARD_LAND, game) > 0) {
if (controller.chooseUse(Outcome.PutLandInPlay, "Put a land from among the exiled cards into play?", source, game)) {
if (controller.choose(Outcome.PutLandInPlay, cardsToCast, target, game)) {
Card card = cardsToCast.get(target.getFirstTarget(), game);
if (card != null) {
cardsToCast.remove(card);
controller.moveCards(card, Zone.BATTLEFIELD, source, game, false, false, true, null);
}
}
}
}
for (Card card : cardsToCast.getCards(StaticFilters.FILTER_CARD_NON_LAND, game)) {
AminatousAuguryCastFromExileEffect effect = new AminatousAuguryCastFromExileEffect();
effect.setTargetPointer(new FixedTarget(card, game));
game.addEffect(effect, source);
}
}
return false;
}
use of mage.game.ExileZone in project mage by magefree.
the class BagOfHoldingEffect 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()));
if (exileZone == null) {
return true;
}
return controller.moveCards(exileZone, Zone.HAND, source, game);
}
use of mage.game.ExileZone in project mage by magefree.
the class CemeteryIlluminatorWatcher method applies.
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
// Once per turn clause checked by Watcher same as Lurrus of the Dream Den
if (affectedControllerId.equals(source.getControllerId())) {
Player controller = game.getPlayer(source.getControllerId());
CemeteryIlluminatorWatcher watcher = game.getState().getWatcher(CemeteryIlluminatorWatcher.class);
Permanent sourceObject = game.getPermanent(source.getSourceId());
if (controller != null && watcher != null && sourceObject != null && !watcher.isAbilityUsed(new MageObjectReference(sourceObject, game))) {
Card card = game.getCard(objectId);
Card topCard = controller.getLibrary().getFromTop(game);
if (card != null && topCard != null && topCard.getId().equals(card.getMainCard().getId()) && !card.isLand(game) && !card.getManaCost().isEmpty()) {
// Check if it shares a card type with exiled cards
UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), game.getState().getZoneChangeCounter(source.getSourceId()));
ExileZone exileZone = game.getExile().getExileZone(exileId);
if (exileZone != null) {
HashSet<CardType> cardTypes = new HashSet<>(card.getCardType(game));
for (UUID exileCardId : exileZone) {
Card exileCard = game.getCard(exileCardId);
if (exileCard != null) {
for (CardType exileType : exileCard.getCardType(game)) {
if (cardTypes.contains(exileType)) {
return true;
}
}
}
}
}
}
}
}
return false;
}
Aggregations