use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class VivienMonstersAdvocateTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Spell spell = game.getSpell(event.getTargetId());
if (spell != null && spell.isCreature(game)) {
int cmc = spell.getManaValue();
FilterCard filter = new FilterCreatureCard("creature card with mana value less than " + cmc);
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, cmc));
this.getEffects().clear();
this.getEffects().add(new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter)));
return true;
}
return false;
}
use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class ViviensArkbowEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
int xValue = source.getManaCostsToPay().getX();
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, xValue));
player.lookAtCards(source, null, cards, game);
FilterCard filter = new FilterCreatureCard("creature card with mana value " + xValue + " or less");
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, xValue + 1));
TargetCard target = new TargetCardInLibrary(0, 1, filter);
if (player.choose(outcome, cards, target, game)) {
Card card = game.getCard(target.getFirstTarget());
if (player.moveCards(card, Zone.BATTLEFIELD, source, game)) {
cards.remove(card);
}
}
return player.putCardsOnBottomOfLibrary(cards, game, source, false);
}
use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class VirtussManeuverEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
ChooseFriendsAndFoes choice = new ChooseFriendsAndFoes();
if (controller != null && !choice.chooseFriendOrFoe(controller, source, game)) {
return false;
}
Map<UUID, Card> getBackMap = new HashMap<>();
for (Player player : choice.getFriends()) {
if (player == null) {
continue;
}
FilterCard filter = new FilterCreatureCard("creature card in your graveyard");
filter.add(new OwnerIdPredicate(player.getId()));
TargetCardInGraveyard target = new TargetCardInGraveyard(filter);
getBackMap.put(player.getId(), null);
if (player.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) {
getBackMap.put(player.getId(), game.getCard(target.getFirstTarget()));
}
}
for (Player player : choice.getFriends()) {
if (player == null) {
continue;
}
Card card = getBackMap.getOrDefault(player.getId(), null);
if (card == null) {
continue;
}
player.moveCards(card, Zone.HAND, source, game);
}
List<UUID> perms = new ArrayList<>();
for (Player player : choice.getFoes()) {
if (player == null) {
continue;
}
TargetControlledPermanent target = new TargetControlledPermanent(1, 1, StaticFilters.FILTER_CONTROLLED_A_CREATURE, true);
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
perms.addAll(target.getTargets());
}
for (UUID permID : perms) {
Permanent permanent = game.getPermanent(permID);
if (permanent != null) {
permanent.sacrifice(source, game);
}
}
return true;
}
use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class WoodSageEffect 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;
}
String cardName = ChooseACardNameEffect.TypeOfName.CREATURE_NAME.getChoice(controller, game, source, false);
FilterCreatureCard filter = new FilterCreatureCard("all of them with that name");
filter.add(new NamePredicate(cardName));
new RevealLibraryPutIntoHandEffect(4, filter, Zone.GRAVEYARD).apply(game, source);
return true;
}
use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class ReturnCreaturesFromExileEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
ExileZone exile = game.getExile().getExileZone(exileId);
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && exile != null) {
controller.moveCards(exile.getCards(new FilterCreatureCard(), game), Zone.BATTLEFIELD, source, game, false, false, this.byOwner, null);
return true;
}
return false;
}
Aggregations