use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class CryptChampionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Set<Card> toBattlefield = new HashSet<>();
if (controller != null) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
FilterCard filter = new FilterCreatureCard("creature card with mana value 3 or less from your graveyard");
filter.add(new OwnerIdPredicate(playerId));
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, 4));
Target target = new TargetCardInGraveyard(filter);
if (target.canChoose(source.getSourceId(), playerId, game) && player.chooseTarget(outcome, target, source, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
toBattlefield.add(card);
}
}
}
}
// must happen simultaneously Rule 101.4
controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game, false, false, true, null);
return true;
}
return false;
}
use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class CrypticGatewayPredicate method apply.
@Override
public boolean apply(Game game, Ability source) {
if (source.getCosts() == null) {
return false;
}
FilterCard filter = new FilterCreatureCard("creature card from your hand that shares a creature type with each creature tapped this way");
for (Cost cost : source.getCosts()) {
if (cost instanceof CrypticGatewayCost) {
Predicate predicate = ((CrypticGatewayCost) cost).getPredicate();
filter.add(predicate);
return new PutCardFromHandOntoBattlefieldEffect(filter).apply(game, source);
}
}
return false;
}
use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class DermoplasmEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent thisCreature = game.getPermanent(source.getId());
FilterCreatureCard filter = new FilterCreatureCard("a creature card with a morph ability");
filter.add(new AbilityPredicate(MorphAbility.class));
Effect effect = new PutCardFromHandOntoBattlefieldEffect(filter);
if (effect.apply(game, source)) {
if (thisCreature != null) {
effect = new ReturnToHandTargetEffect();
effect.setTargetPointer(new FixedTarget(thisCreature.getId(), game));
effect.apply(game, source);
return true;
}
}
return false;
}
use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class ExhumeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Set<Card> toBattlefield = new HashSet<>();
if (controller != null) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
FilterCreatureCard filterCreatureCard = new FilterCreatureCard("creature card from your graveyard");
filterCreatureCard.add(new OwnerIdPredicate(playerId));
TargetCardInGraveyard target = new TargetCardInGraveyard(filterCreatureCard);
target.setNotTarget(true);
if (target.canChoose(source.getSourceId(), playerId, game) && player.chooseTarget(outcome, target, source, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
toBattlefield.add(card);
}
}
}
}
// must happen simultaneously Rule 101.4
controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game, false, false, true, null);
return true;
}
return false;
}
use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class LifesFinaleEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
List<Permanent> permanents = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURES, source.getControllerId(), game);
for (Permanent permanent : permanents) {
permanent.destroy(source, game, false);
}
Player opponent = game.getPlayer(source.getFirstTarget());
Player player = game.getPlayer(source.getControllerId());
if (player != null && opponent != null) {
TargetCardInLibrary target = new TargetCardInLibrary(0, 3, new FilterCreatureCard("creature cards from their library to put in their graveyard"));
if (player.searchLibrary(target, source, game, opponent.getId())) {
player.moveCards(new CardsImpl(target.getTargets()), Zone.GRAVEYARD, source, game);
}
opponent.shuffleLibrary(source, game);
return true;
}
return false;
}
Aggregations