use of mage.target.TargetCard in project mage by magefree.
the class PhyrexianGrimoireEffect 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) {
if (!controller.getGraveyard().isEmpty()) {
Cards cards = new CardsImpl();
UUID card1 = null;
UUID card2 = null;
for (UUID cardId : controller.getGraveyard()) {
card2 = card1;
card1 = cardId;
}
if (card1 != null) {
cards.add(card1);
}
if (card2 != null) {
cards.add(card2);
}
TargetCard target = new TargetCard(Zone.GRAVEYARD, new FilterCard());
target.setRequired(true);
if (opponent.choose(Outcome.Exile, cards, target, game)) {
Card card = game.getCard(target.getFirstTarget());
cards.remove(target.getFirstTarget());
if (card != null) {
controller.moveCards(card, Zone.EXILED, source, game);
}
if (!cards.isEmpty()) {
card = game.getCard(cards.iterator().next());
if (card != null) {
controller.moveCards(card, Zone.HAND, source, game);
}
}
}
}
return true;
}
return false;
}
use of mage.target.TargetCard in project mage by magefree.
the class RevealingEyeEffect 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);
if (opponent.getHand().count(StaticFilters.FILTER_CARD_NON_LAND, game) < 1) {
return true;
}
TargetCard target = new TargetCardInHand(0, 1, StaticFilters.FILTER_CARD_NON_LAND);
controller.choose(outcome, opponent.getHand(), target, game);
Card card = game.getCard(target.getFirstTarget());
if (card == null) {
return true;
}
opponent.discard(card, false, source, game);
opponent.drawCards(1, source, game);
return true;
}
use of mage.target.TargetCard in project mage by magefree.
the class SaheelisDirectiveEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
int xValue = source.getManaCostsToPay().getX();
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, xValue));
if (!cards.isEmpty()) {
controller.revealCards(source, cards, game);
FilterCard filter = new FilterArtifactCard("artifact cards with mana value " + xValue + " or less to put onto the battlefield");
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, xValue + 1));
TargetCard target1 = new TargetCard(0, Integer.MAX_VALUE, Zone.LIBRARY, filter);
target1.setNotTarget(true);
controller.choose(Outcome.PutCardInPlay, cards, target1, game);
Cards toBattlefield = new CardsImpl(target1.getTargets());
cards.removeAll(toBattlefield);
controller.moveCards(toBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, false, false, false, null);
controller.moveCards(cards, Zone.GRAVEYARD, source, game);
}
return true;
}
use of mage.target.TargetCard in project mage by magefree.
the class StreamOfThoughtEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
TargetCard target = new TargetCardInYourGraveyard(0, 4);
target.setNotTarget(true);
if (!player.choose(outcome, player.getGraveyard(), target, game)) {
return false;
}
Cards cards = new CardsImpl(target.getTargets());
player.putCardsOnTopOfLibrary(cards, game, source, false);
player.shuffleLibrary(source, game);
return true;
}
use of mage.target.TargetCard in project mage by magefree.
the class StrefanMaurerProgenitorPlayVampireEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
TargetCard target = new TargetCardInHand(0, 1, vampireCardFilter);
if (!player.choose(outcome, player.getHand(), target, game)) {
return false;
}
Card card = game.getCard(target.getFirstTarget());
if (card == null) {
return false;
}
player.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, true, null);
Permanent permanent = game.getPermanent(card.getId());
if (permanent == null) {
return false;
}
game.getCombat().addAttackingCreature(permanent.getId(), game);
// Gains indestructable until end of turn
ContinuousEffect effect = new GainAbilityTargetEffect(IndestructibleAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(permanent.getId(), game));
game.addEffect(effect, source);
return true;
}
Aggregations