use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class AetherVialEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId());
if (permanent == null) {
permanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
if (permanent == null) {
return false;
}
}
int count = permanent.getCounters(game).getCount(CounterType.CHARGE);
FilterCreatureCard filter = new FilterCreatureCard("creature card with mana value equal to " + count);
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, count));
String choiceText = "Put a " + filter.getMessage() + " from your hand onto the battlefield?";
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
if (controller.getHand().count(filter, game) == 0 || !controller.chooseUse(this.outcome, choiceText, source, game)) {
return true;
}
TargetCardInHand target = new TargetCardInHand(filter);
if (controller.choose(this.outcome, target, source.getSourceId(), game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
return controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
return false;
}
use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class CitanulFluteSearchEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
FilterCard filter = new FilterCreatureCard("creature card with mana value X or less");
// Set the mana cost one higher to 'emulate' a less than or equal to comparison.
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, source.getManaCostsToPay().getX() + 1));
TargetCardInLibrary target = new TargetCardInLibrary(filter);
player.searchLibrary(target, source, game);
Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
if (card != null) {
player.revealCards(source, new CardsImpl(card), game);
player.moveCards(card, Zone.HAND, source, game);
}
player.shuffleLibrary(source, game);
return true;
}
use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class AngelOfGlorysRiseEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Set<Card> toExile = new HashSet<>(game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(SubType.ZOMBIE, "Zombie"), source.getControllerId(), source.getSourceId(), game));
controller.moveCards(toExile, Zone.EXILED, source, game);
FilterCreatureCard filterHuman = new FilterCreatureCard();
filterHuman.add(SubType.HUMAN.getPredicate());
controller.moveCards(controller.getGraveyard().getCards(filterHuman, game), Zone.BATTLEFIELD, source, game);
}
return true;
}
use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class DimirDoppelgangerCopyApplier method apply.
@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DimirDoppelgangerEffect(), new ManaCostsImpl("{1}{U}{B}"));
ability.addTarget(new TargetCardInGraveyard(new FilterCreatureCard("creature card in a graveyard")));
blueprint.getAbilities().add(ability);
return true;
}
Aggregations