use of mage.filter.FilterCard in project mage by magefree.
the class JestersScepterCounterEffect method pay.
@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
Player controller = game.getPlayer(controllerId);
if (controller != null) {
TargetCardInExile target = new TargetCardInExile(new FilterCard(), CardUtil.getCardExileZoneId(game, ability));
target.setNotTarget(true);
Cards cards = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, ability));
if (cards != null && !cards.isEmpty() && controller.choose(Outcome.Benefit, cards, target, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
if (controller.moveCardToGraveyardWithInfo(card, source, game, Zone.EXILED)) {
if (card instanceof SplitCard) {
game.getState().setValue(source.getSourceId() + "_nameOfExiledCardPayment", ((SplitCard) card).getLeftHalfCard().getName());
game.getState().setValue(source.getSourceId() + "_nameOfExiledCardPayment2", ((SplitCard) card).getRightHalfCard().getName());
} else if (card instanceof ModalDoubleFacesCard) {
game.getState().setValue(source.getSourceId() + "_nameOfExiledCardPayment", ((ModalDoubleFacesCard) card).getLeftHalfCard().getName());
game.getState().setValue(source.getSourceId() + "_nameOfExiledCardPayment2", ((ModalDoubleFacesCard) card).getRightHalfCard().getName());
} else {
game.getState().setValue(source.getSourceId() + "_nameOfExiledCardPayment", card.getName());
}
paid = true;
}
}
}
}
return paid;
}
use of mage.filter.FilterCard in project mage by magefree.
the class MindBombEffect 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) {
return false;
}
Map<UUID, Cards> cardsToDiscard = new HashMap<>();
// choose
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player == null) {
continue;
}
Cards cards = new CardsImpl();
Target target = new TargetDiscard(0, 3, new FilterCard(), playerId);
player.chooseTarget(Outcome.Discard, target, source, game);
cards.addAll(target.getTargets());
cardsToDiscard.put(playerId, cards);
}
// discard
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
Cards cardsPlayer = cardsToDiscard.get(playerId);
cardsToDiscard.put(playerId, player.discard(cardsPlayer, false, source, game));
}
}
// damage
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player == null) {
continue;
}
Cards cardsPlayer = cardsToDiscard.get(playerId);
if (cardsPlayer != null) {
player.damage(3 - cardsPlayer.size(), source.getSourceId(), source, game);
}
}
return true;
}
use of mage.filter.FilterCard in project mage by magefree.
the class MoratoriumStoneEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Card card = game.getCard(source.getFirstTarget());
if (card == null) {
return false;
}
String cardName = card.getName();
FilterCard filter1 = new FilterCard();
filter1.add(new NamePredicate(cardName));
FilterPermanent filter2 = new FilterPermanent();
filter2.add(new NamePredicate(cardName));
return new ExileGraveyardAllPlayersEffect(filter1).apply(game, source) && new ExileAllEffect(filter2).apply(game, source);
}
use of mage.filter.FilterCard in project mage by magefree.
the class NoxiousVaporsEffect method chooseCardForColor.
private void chooseCardForColor(ObjectColor color, Set<Card> chosenCards, Player player, Game game, Ability source) {
FilterCard filter = new FilterCard();
filter.add(new ColorPredicate(color));
TargetCardInHand target = new TargetCardInHand(filter);
if (player.choose(Outcome.Benefit, target, source.getSourceId(), game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
chosenCards.add(card);
}
}
}
use of mage.filter.FilterCard in project mage by magefree.
the class OathOfGhoulsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
MageObject sourceObject = game.getObject(source.getSourceId());
Player firstPlayer = game.getPlayer(game.getActivePlayerId());
if (sourceObject == null || firstPlayer == null) {
return false;
}
FilterCard filter = new FilterCreatureCard("creature card");
filter.add(new OwnerIdPredicate(firstPlayer.getId()));
Target target = new TargetCardInGraveyard(filter);
target.setNotTarget(true);
if (target.canChoose(source.getSourceId(), firstPlayer.getId(), game) && firstPlayer.chooseUse(outcome, "Return a creature card from your graveyard to your hand?", source, game) && firstPlayer.chooseTarget(Outcome.ReturnToHand, target, source, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
firstPlayer.moveCards(card, Zone.HAND, source, game);
}
}
return true;
}
Aggregations