Search in sources :

Example 51 with Card

use of mage.cards.Card in project mage by magefree.

the class MavindaStudentsAdvocateCostEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    if (!super.apply(game, source)) {
        return false;
    }
    Card card = game.getCard(this.getTargetPointer().getFirst(game, source));
    if (card == null) {
        return false;
    }
    game.addEffect(new MavindaStudentsAdvocateCostEffect(card, game), source);
    return true;
}
Also used : Card(mage.cards.Card)

Example 52 with Card

use of mage.cards.Card in project mage by magefree.

the class MemoryPlunderEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card card = game.getCard(getTargetPointer().getFirst(game, source));
    if (card != null) {
        Player controller = game.getPlayer(source.getControllerId());
        if (controller != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD && controller.chooseUse(Outcome.PlayForFree, "Cast " + card.getName() + " without paying cost?", source, game)) {
            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);
            return cardWasCast;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) ApprovingObject(mage.ApprovingObject) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 53 with Card

use of mage.cards.Card in project mage by magefree.

the class MemoryLeakEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player opponent = game.getPlayer(source.getFirstTarget());
    if (controller == null || opponent == null) {
        return false;
    }
    opponent.revealCards(source, opponent.getHand(), game);
    TargetCard target;
    Cards cards;
    if (controller.chooseUse(outcome, "Exile a card from hand or graveyard?", null, "Hand", "Graveyard", source, game)) {
        FilterCard filter = new FilterNonlandCard("nonland card in " + opponent.getName() + "'s hand");
        target = new TargetCard(Zone.HAND, filter);
        target.setNotTarget(true);
        cards = opponent.getHand();
    } else {
        FilterCard filter = new FilterNonlandCard("nonland card in " + opponent.getName() + "'s graveyard");
        target = new TargetCard(Zone.GRAVEYARD, filter);
        target.setNotTarget(true);
        cards = opponent.getGraveyard();
    }
    if (controller.choose(outcome, cards, target, game)) {
        Card card = game.getCard(target.getFirstTarget());
        if (card != null) {
            controller.moveCards(card, Zone.EXILED, source, game);
        }
    }
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) FilterNonlandCard(mage.filter.common.FilterNonlandCard) TargetCard(mage.target.TargetCard) Cards(mage.cards.Cards) FilterCard(mage.filter.FilterCard) FilterNonlandCard(mage.filter.common.FilterNonlandCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 54 with Card

use of mage.cards.Card 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 55 with Card

use of mage.cards.Card 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)

Aggregations

Card (mage.cards.Card)1448 Player (mage.players.Player)1096 Permanent (mage.game.permanent.Permanent)423 FilterCard (mage.filter.FilterCard)381 UUID (java.util.UUID)340 CardsImpl (mage.cards.CardsImpl)253 MageObject (mage.MageObject)212 FixedTarget (mage.target.targetpointer.FixedTarget)173 TargetCard (mage.target.TargetCard)165 Cards (mage.cards.Cards)159 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)111 ContinuousEffect (mage.abilities.effects.ContinuousEffect)99 TargetCardInHand (mage.target.common.TargetCardInHand)98 Target (mage.target.Target)86 HashSet (java.util.HashSet)85 FilterCreatureCard (mage.filter.common.FilterCreatureCard)84 ApprovingObject (mage.ApprovingObject)77 Ability (mage.abilities.Ability)71 TargetPlayer (mage.target.TargetPlayer)67 TargetPermanent (mage.target.TargetPermanent)64