use of mage.filter.FilterCard in project mage by magefree.
the class DomriChaosBringerTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!event.getSourceId().equals(spellId)) {
return false;
}
if (game.getTurnNum() != turnNumber) {
return false;
}
MageObject mo = game.getObject(event.getTargetId());
if (mo == null || !mo.isCreature(game)) {
return false;
}
StackObject stackObject = game.getStack().getStackObject(event.getTargetId());
if (stackObject == null) {
return false;
}
this.getEffects().clear();
FilterCard filter = new FilterCard();
filter.add(new CardIdPredicate(stackObject.getSourceId()));
this.addEffect(new GainAbilityControlledSpellsEffect(new RiotAbility(), filter));
return true;
}
use of mage.filter.FilterCard in project mage by magefree.
the class EnigmaticIncarnationEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null || game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) == 0 || !player.chooseUse(outcome, "Sacrifice an enchantment?", source, game)) {
return false;
}
TargetPermanent target = new TargetPermanent(0, 1, filter, true);
player.choose(outcome, target, source.getSourceId(), game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent == null) {
return false;
}
game.getState().processAction(game);
int cmc = permanent.getManaValue();
if (!permanent.sacrifice(source, game)) {
return false;
}
FilterCard filterCard = new FilterCreatureCard("creature card with mana value " + (cmc + 1));
filterCard.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, cmc + 1));
return new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filterCard)).apply(game, source);
}
use of mage.filter.FilterCard in project mage by magefree.
the class FaithsShieldEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject mageObject = game.getObject(source.getSourceId());
if (controller != null && mageObject != null) {
if (FatefulHourCondition.instance.apply(game, source)) {
ChoiceColor choice = new ChoiceColor();
if (!controller.choose(Outcome.Protect, choice, game)) {
return false;
}
if (choice.getColor() != null) {
game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice());
FilterCard filter = new FilterCard();
filter.add(new ColorPredicate(choice.getColor()));
filter.setMessage(choice.getChoice());
Ability ability = new ProtectionAbility(filter);
game.addEffect(new GainAbilityControlledEffect(ability, Duration.EndOfTurn), source);
game.addEffect(new GainAbilityControllerEffect(ability, Duration.EndOfTurn), source);
return true;
}
} else {
game.addEffect(new GainProtectionFromColorTargetEffect(Duration.EndOfTurn), source);
return true;
}
}
return false;
}
use of mage.filter.FilterCard in project mage by magefree.
the class GiftsUngivenTarget method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Card sourceCard = game.getCard(source.getSourceId());
if (player == null || sourceCard == null) {
return false;
}
Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source));
if (opponent == null) {
return false;
}
GiftsUngivenTarget target = new GiftsUngivenTarget();
if (player.searchLibrary(target, source, game)) {
if (!target.getTargets().isEmpty()) {
Cards cards = new CardsImpl();
for (UUID cardId : target.getTargets()) {
Card card = player.getLibrary().remove(cardId, game);
if (card != null) {
cards.add(card);
}
}
player.revealCards(sourceCard.getIdName(), cards, game);
CardsImpl cardsToKeep = new CardsImpl();
if (cards.size() > 2) {
cardsToKeep.addAll(cards);
TargetCard targetDiscard = new TargetCard(2, Zone.LIBRARY, new FilterCard("cards to put in graveyard"));
if (opponent.choose(Outcome.Discard, cards, targetDiscard, game)) {
cardsToKeep.removeAll(targetDiscard.getTargets());
cards.removeAll(cardsToKeep);
}
}
player.moveCards(cards, Zone.GRAVEYARD, source, game);
player.moveCards(cardsToKeep, Zone.HAND, source, game);
}
player.shuffleLibrary(source, game);
return true;
}
player.shuffleLibrary(source, game);
return false;
}
use of mage.filter.FilterCard in project mage by magefree.
the class IsarethTheAwakenerReplacementEffect method makeFilter.
private static FilterCard makeFilter(int xValue) {
FilterCard filter = new FilterCreatureCard("creature card with mana value " + xValue + " or less from your graveyard");
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, xValue));
return filter;
}
Aggregations