Search in sources :

Example 1 with ExileZone

use of mage.game.ExileZone in project mage by magefree.

the class HaukensInsightWatcher method applies.

@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
    if (affectedControllerId.equals(source.getControllerId()) && game.isActivePlayer(source.getControllerId())) {
        Player controller = game.getPlayer(source.getControllerId());
        HaukensInsightWatcher watcher = game.getState().getWatcher(HaukensInsightWatcher.class);
        Permanent sourceObject = game.getPermanent(source.getSourceId());
        if (controller != null && watcher != null && sourceObject != null && !watcher.isAbilityUsed(new MageObjectReference(sourceObject, game))) {
            UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), game.getState().getZoneChangeCounter(source.getSourceId()));
            ExileZone exileZone = game.getExile().getExileZone(exileId);
            if (exileZone != null && exileZone.contains(CardUtil.getMainCardId(game, objectId))) {
                allowCardToPlayWithoutMana(objectId, source, affectedControllerId, game);
                return true;
            }
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) ExileZone(mage.game.ExileZone) UUID(java.util.UUID) MageObjectReference(mage.MageObjectReference)

Example 2 with ExileZone

use of mage.game.ExileZone in project mage by magefree.

the class HazoretsUndyingFuryEffect 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) {
        controller.shuffleLibrary(source, game);
        // move cards from library to exile
        controller.moveCardsToExile(controller.getLibrary().getTopCards(game, 4), source, game, true, source.getSourceId(), sourceObject.getIdName());
        // cast the possible cards without paying the mana
        ExileZone hazoretsUndyingFuryExileZone = game.getExile().getExileZone(source.getSourceId());
        Cards cardsToCast = new CardsImpl();
        if (hazoretsUndyingFuryExileZone == null) {
            return true;
        }
        cardsToCast.addAll(hazoretsUndyingFuryExileZone.getCards(filter, source.getSourceId(), source.getControllerId(), game));
        while (controller.canRespond() && !cardsToCast.isEmpty()) {
            if (!controller.chooseUse(Outcome.PlayForFree, "Cast (another) a card exiled with " + sourceObject.getLogName() + " without paying its mana cost?", source, game)) {
                break;
            }
            TargetCard targetCard = new TargetCard(1, Zone.EXILED, new FilterCard("nonland card to cast for free"));
            if (controller.choose(Outcome.PlayForFree, cardsToCast, targetCard, game)) {
                Card card = game.getCard(targetCard.getFirstTarget());
                if (card != null) {
                    game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
                    Boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(card, game, true), game, true, new ApprovingObject(source, game));
                    game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
                    cardsToCast.remove(card);
                    if (!cardWasCast) {
                        game.informPlayer(controller, "You're not able to cast " + card.getIdName() + " or you canceled the casting.");
                    }
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) ApprovingObject(mage.ApprovingObject) MageObject(mage.MageObject) ExileZone(mage.game.ExileZone) TargetCard(mage.target.TargetCard) FilterCard(mage.filter.FilterCard) TargetCard(mage.target.TargetCard)

Example 3 with ExileZone

use of mage.game.ExileZone in project mage by magefree.

the class TargetCardInMuseVesselExile method possibleTargets.

@Override
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
    Set<UUID> possibleTargets = new HashSet<>();
    Card sourceCard = game.getCard(sourceId);
    if (sourceCard != null) {
        UUID exileId = CardUtil.getCardExileZoneId(game, sourceId);
        ExileZone exile = game.getExile().getExileZone(exileId);
        if (exile != null && !exile.isEmpty()) {
            possibleTargets.addAll(exile);
        }
    }
    return possibleTargets;
}
Also used : ExileZone(mage.game.ExileZone) UUID(java.util.UUID) HashSet(java.util.HashSet) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 4 with ExileZone

use of mage.game.ExileZone in project mage by magefree.

the class TargetCardInMuseVesselExile method canChoose.

@Override
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
    Card sourceCard = game.getCard(sourceId);
    if (sourceCard != null) {
        UUID exileId = CardUtil.getCardExileZoneId(game, sourceId);
        ExileZone exile = game.getExile().getExileZone(exileId);
        if (exile != null && !exile.isEmpty()) {
            return true;
        }
    }
    return false;
}
Also used : ExileZone(mage.game.ExileZone) UUID(java.util.UUID) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 5 with ExileZone

use of mage.game.ExileZone in project mage by magefree.

the class ValakutExplorationDamageEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()));
    if (exileZone == null) {
        return false;
    }
    int count = exileZone.size();
    if (count < 1) {
        return false;
    }
    player.moveCards(exileZone, Zone.GRAVEYARD, source, game);
    for (UUID playerId : game.getOpponents(source.getControllerId())) {
        player = game.getPlayer(playerId);
        if (playerId == null) {
            continue;
        }
        player.damage(count, source.getSourceId(), source, game);
    }
    return true;
}
Also used : Player(mage.players.Player) ExileZone(mage.game.ExileZone) UUID(java.util.UUID)

Aggregations

ExileZone (mage.game.ExileZone)92 Player (mage.players.Player)61 UUID (java.util.UUID)44 Card (mage.cards.Card)44 MageObject (mage.MageObject)24 Permanent (mage.game.permanent.Permanent)23 FilterCard (mage.filter.FilterCard)15 HashSet (java.util.HashSet)11 ApprovingObject (mage.ApprovingObject)9 CardsImpl (mage.cards.CardsImpl)9 TargetCard (mage.target.TargetCard)9 Cards (mage.cards.Cards)7 MageObjectReference (mage.MageObjectReference)6 Ability (mage.abilities.Ability)5 Spell (mage.game.stack.Spell)5 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)3 TransformSourceEffect (mage.abilities.effects.common.TransformSourceEffect)3 TargetPlayer (mage.target.TargetPlayer)3 Objects (java.util.Objects)2 Set (java.util.Set)2