Search in sources :

Example 86 with Card

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

the class PutToLibraryTest method testPutSecondFromTop.

@Test
public void testPutSecondFromTop() {
    addCard(Zone.BATTLEFIELD, playerA, "Plains", 1);
    // Put target creature into its owner's library second from the top. Its controller gains 3 life.
    // Sorcery {W}
    addCard(Zone.HAND, playerA, "Oust");
    addCard(Zone.BATTLEFIELD, playerB, "Dread Wanderer");
    castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Oust", "Dread Wanderer");
    setStopAt(1, PhaseStep.BEGIN_COMBAT);
    execute();
    assertGraveyardCount(playerA, "Oust", 1);
    assertLibraryCount(playerB, "Dread Wanderer", 1);
    assertLife(playerA, 20);
    assertLife(playerB, 23);
    ArrayList<Card> cardArray = new ArrayList<>(playerB.getLibrary().getCards(currentGame));
    Assert.assertTrue("Library has no cards but should have", cardArray.size() > 1);
    Card secondCard = cardArray.get(1);
    Assert.assertTrue("Second card from top should be Dread Wanderer, but it isn't", secondCard != null && secondCard.getName().equals("Dread Wanderer"));
}
Also used : ArrayList(java.util.ArrayList) Card(mage.cards.Card) Test(org.junit.Test)

Example 87 with Card

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

the class CommanderColorIdentityTest method getColorIdentityString.

private String getColorIdentityString(String cardName) {
    CardInfo cardInfo = CardRepository.instance.findCard(cardName);
    if (cardInfo == null) {
        throw new IllegalArgumentException("Couldn't find the card " + cardName + " in the DB.");
    }
    Card card = cardInfo.getCard();
    FilterMana filterMana = card.getColorIdentity();
    return filterMana.toString();
}
Also used : FilterMana(mage.filter.FilterMana) CardInfo(mage.cards.repository.CardInfo) Card(mage.cards.Card)

Example 88 with Card

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

the class TargetHasCounterCondition method apply.

@Override
@SuppressWarnings("null")
public boolean apply(Game game, Ability source) {
    Card card = null;
    Permanent permanent = game.getPermanentOrLKIBattlefield(source.getFirstTarget());
    if (permanent == null) {
        card = game.getCard(source.getFirstTarget());
        if (card == null) {
            return false;
        }
    }
    if (from != -1) {
        // range compare
        int count;
        if (card != null) {
            count = card.getCounters(game).getCount(counterType);
        } else {
            count = permanent.getCounters(game).getCount(counterType);
        }
        if (to == Integer.MAX_VALUE) {
            return count >= from;
        }
        return count >= from && count <= to;
    } else {
        // single compare (lte)
        if (card != null) {
            return card.getCounters(game).getCount(counterType) >= amount;
        } else {
            return permanent.getCounters(game).getCount(counterType) >= amount;
        }
    }
}
Also used : Permanent(mage.game.permanent.Permanent) Card(mage.cards.Card)

Example 89 with Card

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

the class DiscardSourceCost method pay.

@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
    Player player = game.getPlayer(controllerId);
    if (player != null) {
        Card card = player.getHand().get(source.getSourceId(), game);
        paid = player.discard(card, true, source, game);
    }
    return paid;
}
Also used : Player(mage.players.Player) Card(mage.cards.Card)

Example 90 with Card

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

the class ExileFromHandCost method pay.

@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
    if (targets.choose(Outcome.Exile, controllerId, source.getSourceId(), game)) {
        Player player = game.getPlayer(controllerId);
        int cmc = 0;
        for (UUID targetId : targets.get(0).getTargets()) {
            Card card = player.getHand().get(targetId, game);
            if (card == null) {
                return false;
            }
            cmc += card.getManaValue();
            this.cards.add(card);
        }
        Cards cardsToExile = new CardsImpl();
        cardsToExile.addAll(cards);
        player.moveCards(cardsToExile, Zone.EXILED, ability, game);
        paid = true;
        if (setXFromCMC) {
            VariableManaCost vmc = new VariableManaCost(VariableCostType.ALTERNATIVE);
            // no x events - rules from Unbound Flourishing:
            // - Spells with additional costs that include X won't be affected by Unbound Flourishing. X must be in the spell's mana cost.
            // TODO: wtf, look at setXFromCMC usage -- it used in cards with alternative costs, not additional... need to fix?
            vmc.setAmount(cmc, cmc, false);
            vmc.setPaid();
            ability.getManaCostsToPay().add(vmc);
        }
    }
    return paid;
}
Also used : Player(mage.players.Player) UUID(java.util.UUID) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card) VariableManaCost(mage.abilities.costs.mana.VariableManaCost)

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