use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class WildPairPowerToughnessPredicate method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = (Permanent) getValue("permanentEnteringBattlefield");
if (controller == null || permanent == null) {
return false;
}
int totalPT = permanent.getPower().getValue() + permanent.getToughness().getValue();
FilterCreatureCard filter = new FilterCreatureCard("creature card with total power and toughness " + totalPT);
filter.add(new WildPairPowerToughnessPredicate(totalPT));
TargetCardInLibrary target = new TargetCardInLibrary(1, filter);
controller.searchLibrary(target, source, game);
controller.moveCards(new CardsImpl(controller.getLibrary().getCard(target.getFirstTarget(), game)), Zone.BATTLEFIELD, source, game);
controller.shuffleLibrary(source, game);
return true;
}
use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class AethermagesTouchEffect 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) {
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 4));
if (!cards.isEmpty()) {
FilterCreatureCard filter = new FilterCreatureCard("a creature card to put onto the battlefield");
controller.revealCards(sourceObject.getIdName(), cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, filter);
if (cards.count(filter, game) > 0 && controller.choose(outcome, cards, target, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
cards.remove(card);
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
// It gains \"At the beginning of your end step, return this creature to its owner's hand.\"
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
Ability ability = new BeginningOfEndStepTriggeredAbility(Zone.BATTLEFIELD, new ReturnToHandSourceEffect(true), TargetController.YOU, null, false);
ContinuousEffect effect = new GainAbilityTargetEffect(ability, Duration.Custom);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
}
}
}
}
controller.putCardsOnBottomOfLibrary(cards, game, source, true);
}
return true;
}
return false;
}
use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class GraveSifterEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
typeChoice.setMessage("Choose creature type to return cards from your graveyard");
Player controller = game.getPlayer(source.getControllerId());
Set<Card> toHand = new HashSet<>();
if (controller != null) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
typeChoice.clearChoice();
if (player.choose(outcome, typeChoice, game)) {
game.informPlayers(player.getLogName() + " has chosen: " + typeChoice.getChoice());
FilterCard filter = new FilterCreatureCard("creature cards with creature type " + typeChoice.getChoice() + " from your graveyard");
filter.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
Target target = new TargetCardInYourGraveyard(0, Integer.MAX_VALUE, filter);
player.chooseTarget(outcome, target, source, game);
toHand.addAll(new CardsImpl(target.getTargets()).getCards(game));
}
}
}
// must happen simultaneously Rule 101.4
controller.moveCards(toHand, Zone.HAND, source, game, false, false, true, null);
return true;
}
return false;
}
use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class LazavDimirMastermindCopyApplier method apply.
@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
Ability ability = new PutCardIntoGraveFromAnywhereAllTriggeredAbility(new LazavDimirMastermindEffect(), true, new FilterCreatureCard("a creature card"), TargetController.OPPONENT, SetTargetPointer.CARD);
blueprint.getAbilities().add(ability);
blueprint.setName("Lazav, Dimir Mastermind");
blueprint.addSuperType(SuperType.LEGENDARY);
blueprint.getAbilities().add(HexproofAbility.getInstance());
return true;
}
use of mage.filter.common.FilterCreatureCard in project mage by magefree.
the class ReincarnationDelayedEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = (Permanent) game.getLastKnownInformation(target, Zone.BATTLEFIELD);
if (permanent != null && controller != null) {
Player player = game.getPlayer(permanent.getOwnerId());
if (player != null) {
FilterCreatureCard filter = new FilterCreatureCard("a creature card from " + player.getName() + "'s graveyard");
filter.add(new OwnerIdPredicate(player.getId()));
Target targetCreature = new TargetCardInGraveyard(filter);
targetCreature.setNotTarget(true);
if (targetCreature.canChoose(source.getSourceId(), controller.getId(), game) && controller.chooseTarget(outcome, targetCreature, source, game)) {
Card card = game.getCard(targetCreature.getFirstTarget());
if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game, false, false, true, null);
}
}
return true;
}
}
return false;
}
Aggregations