use of mage.filter.FilterCard in project mage by magefree.
the class PatriarchsBiddingEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
Set<String> chosenTypes = new HashSet<>();
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
Choice typeChoice = new ChoiceCreatureType(sourceObject);
if (!player.choose(Outcome.PutCreatureInPlay, typeChoice, game)) {
continue;
}
String chosenType = typeChoice.getChoice();
game.informPlayers(sourceObject.getLogName() + ": " + player.getLogName() + " has chosen " + chosenType);
chosenTypes.add(chosenType);
}
List<SubType.SubTypePredicate> predicates = new ArrayList<>();
for (String type : chosenTypes) {
predicates.add(SubType.byDescription(type).getPredicate());
}
FilterCard filter = new FilterCreatureCard();
filter.add(Predicates.or(predicates));
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.moveCards(player.getGraveyard().getCards(filter, game), Zone.BATTLEFIELD, source, game);
}
}
return true;
}
return false;
}
use of mage.filter.FilterCard in project mage by magefree.
the class PrimeSpeakerVannifarEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent sacrificedPermanent = null;
for (Cost cost : source.getCosts()) {
if (cost instanceof SacrificeTargetCost) {
SacrificeTargetCost sacrificeCost = (SacrificeTargetCost) cost;
if (!sacrificeCost.getPermanents().isEmpty()) {
sacrificedPermanent = sacrificeCost.getPermanents().get(0);
}
break;
}
}
Player controller = game.getPlayer(source.getControllerId());
if (sacrificedPermanent == null || controller == null) {
return false;
}
int newConvertedCost = sacrificedPermanent.getManaValue() + 1;
FilterCard filter = new FilterCard("creature card with mana value " + newConvertedCost);
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, newConvertedCost));
filter.add(CardType.CREATURE.getPredicate());
TargetCardInLibrary target = new TargetCardInLibrary(filter);
if (controller.searchLibrary(target, source, game)) {
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
controller.shuffleLibrary(source, game);
return true;
}
use of mage.filter.FilterCard in project mage by magefree.
the class RakdosAugermageEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
Player controller = game.getPlayer(source.getControllerId());
if (player != null && controller != null) {
Cards revealedCards = new CardsImpl();
revealedCards.addAll(controller.getHand());
Card sourceCard = game.getCard(source.getSourceId());
player.revealCards((sourceCard != null ? sourceCard.getIdName() + " (" + sourceCard.getZoneChangeCounter(game) + ") (" : "Discard (") + controller.getName() + ")", revealedCards, game);
TargetCard target = new TargetCard(Zone.HAND, new FilterCard());
if (player.choose(Outcome.Benefit, revealedCards, target, game)) {
Card card = revealedCards.get(target.getFirstTarget(), game);
return player.discard(card, false, source, game);
}
}
return false;
}
use of mage.filter.FilterCard in project mage by magefree.
the class SawtoothLoonEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
controller.drawCards(2, source, game);
TargetCardInHand target = new TargetCardInHand(2, 2, new FilterCard());
controller.chooseTarget(Outcome.Detriment, target, source, game);
Cards cardsToLibrary = new CardsImpl(target.getTargets());
if (!cardsToLibrary.isEmpty()) {
controller.putCardsOnBottomOfLibrary(cardsToLibrary, game, source, false);
}
return true;
}
return false;
}
use of mage.filter.FilterCard in project mage by magefree.
the class ShrineOfPiercingVisionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
if (player == null || permanent == null) {
return false;
}
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, permanent.getCounters(game).getCount(CounterType.CHARGE)));
if (!cards.isEmpty()) {
player.lookAtCards(source, null, cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put into your hand"));
if (player.choose(Outcome.DrawCard, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
player.moveCards(card, Zone.HAND, source, game);
}
}
player.putCardsOnBottomOfLibrary(cards, game, source, true);
}
return true;
}
Aggregations