use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class RadiantScrollwielderWatcher method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null || player.getGraveyard().count(StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY, game) < 1) {
return false;
}
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY);
target.setNotTarget(true);
target.setRandom(true);
target.chooseTarget(outcome, player.getId(), source, game);
Card card = game.getCard(target.getFirstTarget());
if (card == null) {
return false;
}
PlayFromNotOwnHandZoneTargetEffect.exileAndPlayFromExile(game, source, card, TargetController.YOU, Duration.EndOfTurn, false, false, true);
game.addEffect(new RadiantScrollwielderReplacementEffect(card, game), source);
return true;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class RofellossGiftEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
TargetCardInHand targetCardInHand = new TargetCardInHand(0, Integer.MAX_VALUE, filter1);
if (!player.choose(outcome, player.getHand(), targetCardInHand, game)) {
return false;
}
Cards cards = new CardsImpl();
for (UUID cardId : targetCardInHand.getTargets()) {
Card card = game.getCard(cardId);
if (card != null) {
cards.add(card);
}
}
player.revealCards(source, cards, game);
int enchantmentsToReturn = Math.min(player.getGraveyard().count(filter2, game), targetCardInHand.getTargets().size());
TargetCardInYourGraveyard targetCardInYourGraveyard = new TargetCardInYourGraveyard(enchantmentsToReturn, filter2);
targetCardInYourGraveyard.setNotTarget(true);
if (!player.choose(outcome, targetCardInYourGraveyard, source.getSourceId(), game)) {
return false;
}
cards = new CardsImpl();
for (UUID cardId : targetCardInYourGraveyard.getTargets()) {
Card card = game.getCard(cardId);
if (card != null) {
cards.add(card);
}
}
return player.moveCards(cards, Zone.HAND, source, game);
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class WebOfInertiaRestrictionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
MageObject sourceObject = game.getObject(source.getSourceId());
if (player != null && sourceObject != null) {
Cost cost = new ExileFromGraveCost(new TargetCardInYourGraveyard());
if (cost.canPay(source, source, player.getId(), game) && player.chooseUse(Outcome.Detriment, "Exile a card from your graveyard?", source, game)) {
cost.clearPaid();
if (cost.pay(source, game, source, player.getId(), false, null)) {
if (!game.isSimulation()) {
game.informPlayers(player.getLogName() + " pays the cost to prevent the effect");
}
}
} else {
game.addEffect(new WebOfInertiaRestrictionEffect(player.getId()), source);
}
return true;
}
return false;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class WitherbloomCommandEffect 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(1, StaticFilters.FILTER_CARD_LAND);
target.setNotTarget(true);
if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
return false;
}
player.choose(outcome, target, source.getSourceId(), game);
Card card = game.getCard(target.getFirstTarget());
return card != null && player.moveCards(card, Zone.HAND, source, game);
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class ExileCardFromOwnGraveyardControllerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null || player.getGraveyard().isEmpty()) {
return false;
}
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(Math.min(amount, player.getGraveyard().size()), StaticFilters.FILTER_CARD);
target.setNotTarget(true);
if (!player.chooseTarget(outcome, target, source, game)) {
return true;
}
Cards cards = new CardsImpl();
for (UUID targetId : target.getTargets()) {
cards.add(player.getGraveyard().get(targetId, game));
}
return player.moveCards(cards, Zone.EXILED, source, game);
}
Aggregations