Search in sources :

Example 91 with ExileZone

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

the class CemeteryProwlerCostReductionEffect method apply.

@Override
public boolean apply(Game game, Ability source, Ability abilityToModify) {
    if (abilityToModify instanceof SpellAbility) {
        // sourceObjectZoneChangeCounter is not working here.  Getting it from GameState works.
        UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), game.getState().getZoneChangeCounter(source.getSourceId()));
        ExileZone exileZone = game.getExile().getExileZone(exileId);
        Card castCard = ((SpellAbility) abilityToModify).getCharacteristics(game);
        if (exileZone != null && castCard != null) {
            HashSet<CardType> cardTypes = new HashSet<>();
            for (UUID cardId : exileZone) {
                Card card = game.getCard(cardId);
                if (card != null) {
                    cardTypes.addAll(card.getCardType(game));
                }
            }
            int sharedTypes = 0;
            for (CardType type : castCard.getCardType(game)) {
                if (cardTypes.contains(type)) {
                    sharedTypes++;
                }
            }
            if (sharedTypes > 0) {
                CardUtil.reduceCost(abilityToModify, sharedTypes);
                return true;
            }
        }
    }
    return false;
}
Also used : ExileZone(mage.game.ExileZone) SpellAbility(mage.abilities.SpellAbility) UUID(java.util.UUID) Card(mage.cards.Card) HashSet(java.util.HashSet)

Example 92 with ExileZone

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

the class AzorsGatewayEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    UUID exileId = CardUtil.getCardExileZoneId(game, source);
    MageObject sourceObject = source.getSourceObject(game);
    if (controller != null && exileId != null && sourceObject != null) {
        controller.drawCards(1, source, game);
        TargetCardInHand target = new TargetCardInHand();
        controller.choose(outcome, target, source.getSourceId(), game);
        Card cardToExile = game.getCard(target.getFirstTarget());
        if (cardToExile != null) {
            controller.moveCardsToExile(cardToExile, source, game, true, exileId, sourceObject.getIdName());
        }
        Set<Integer> usedCMC = new HashSet<>();
        ExileZone exileZone = game.getExile().getExileZone(exileId);
        if (exileZone != null) {
            for (Card card : exileZone.getCards(game)) {
                usedCMC.add(card.getManaValue());
            }
            if (usedCMC.size() > 4) {
                controller.gainLife(4, game, source);
                new UntapSourceEffect().apply(game, source);
                new TransformSourceEffect().apply(game, source);
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) TargetCardInHand(mage.target.common.TargetCardInHand) TransformSourceEffect(mage.abilities.effects.common.TransformSourceEffect) MageObject(mage.MageObject) UntapSourceEffect(mage.abilities.effects.common.UntapSourceEffect) ExileZone(mage.game.ExileZone) UUID(java.util.UUID) Card(mage.cards.Card) HashSet(java.util.HashSet)

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