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"));
}
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();
}
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;
}
}
}
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;
}
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;
}
Aggregations