use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class WatchersOfTheDeadEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
if (controller != null) {
for (UUID opponentId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player opponent = game.getPlayer(opponentId);
if (opponent != null && !opponent.equals(controller)) {
TargetCard target = new TargetCardInYourGraveyard(2, 2, new FilterCard());
target.setNotTarget(true);
Cards cardsInGraveyard = opponent.getGraveyard();
if (cardsInGraveyard.size() > 1) {
opponent.choose(outcome, cardsInGraveyard, target, game);
for (Card cardInGraveyard : cardsInGraveyard.getCards(game)) {
if (!target.getTargets().contains(cardInGraveyard.getId())) {
opponent.moveCardToExileWithInfo(cardInGraveyard, CardUtil.getCardExileZoneId(game, source.getId()), sourceObject.getLogName(), source, game, Zone.GRAVEYARD, true);
}
}
}
}
}
return true;
}
return false;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class LichsMasteryLoseLifeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
FilterPermanent filter = new FilterPermanent();
filter.add(new ControllerIdPredicate(controller.getId()));
for (int i = 0; i < amount; i++) {
int handCount = controller.getHand().size();
int graveCount = controller.getGraveyard().size();
int permCount = game.getBattlefield().getActivePermanents(filter, controller.getId(), game).size();
if (graveCount + handCount == 0 || (permCount > 0 && controller.chooseUse(Outcome.Exile, "Exile permanent you control? (No = from hand or graveyard)", source, game))) {
Target target = new TargetControlledPermanent(1, 1, new FilterControlledPermanent(), true);
controller.choose(outcome, target, source.getSourceId(), game);
Effect effect = new ExileTargetEffect();
effect.setTargetPointer(new FixedTarget(target.getFirstTarget(), game));
effect.apply(game, source);
} else if (graveCount == 0 || (handCount > 0 && controller.chooseUse(Outcome.Exile, "Exile a card from your hand? (No = from graveyard)", source, game))) {
Target target = new TargetCardInHand(1, 1, new FilterCard());
controller.choose(outcome, target, source.getSourceId(), game);
Card card = controller.getHand().get(target.getFirstTarget(), game);
if (card != null) {
controller.moveCards(card, Zone.EXILED, source, game);
}
} else if (graveCount > 0) {
Target target = new TargetCardInYourGraveyard(1, 1, new FilterCard(), true);
target.choose(Outcome.Exile, source.getControllerId(), source.getSourceId(), game);
Card card = controller.getGraveyard().get(target.getFirstTarget(), game);
if (card != null) {
controller.moveCards(card, Zone.EXILED, source, game);
}
}
}
return true;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class RootsOfWisdomEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
player.millCards(3, source, game);
TargetCard targetCard = new TargetCardInYourGraveyard(filter);
targetCard.setNotTarget(true);
if (targetCard.canChoose(source.getSourceId(), source.getControllerId(), game) && player.choose(outcome, targetCard, source.getSourceId(), game)) {
Card card = player.getGraveyard().get(targetCard.getFirstTarget(), game);
if (card != null && player.moveCards(card, Zone.HAND, source, game)) {
return true;
}
}
player.drawCards(1, source, game);
return true;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class SkullwinderEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
TargetOpponent targetOpponent = new TargetOpponent(true);
if (controller.choose(Outcome.Detriment, targetOpponent, source.getSourceId(), game)) {
Player opponent = game.getPlayer(targetOpponent.getFirstTarget());
if (opponent != null) {
game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " has chosen " + opponent.getLogName());
// That player returns a card from their graveyard to their hand
TargetCardInYourGraveyard targetCard = new TargetCardInYourGraveyard(new FilterCard("a card from your graveyard to return to your hand"));
targetCard.setNotTarget(true);
if (opponent.choose(outcome, targetCard, source.getSourceId(), game)) {
Card card = game.getCard(targetCard.getFirstTarget());
if (card != null) {
opponent.moveCards(card, Zone.HAND, source, game);
}
}
}
}
return true;
}
return false;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class TayamLuminousEnigmaReplacementEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null || player.getGraveyard().count(filter, game) == 0) {
return false;
}
TargetCard target = new TargetCardInYourGraveyard(filter);
target.setNotTarget(true);
if (!player.choose(outcome, player.getGraveyard(), target, game)) {
return false;
}
return player.moveCards(game.getCard(target.getFirstTarget()), Zone.BATTLEFIELD, source, game);
}
Aggregations