use of mage.filter.predicate.card.OwnerIdPredicate in project mage by magefree.
the class ScrabblingClawsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(source.getFirstTarget());
if (targetPlayer == null) {
return false;
}
FilterCard filter = new FilterCard("card from your graveyard");
filter.add(new OwnerIdPredicate(targetPlayer.getId()));
TargetCardInGraveyard target = new TargetCardInGraveyard(filter);
if (!targetPlayer.chooseTarget(Outcome.Exile, target, source, game)) {
return false;
}
Card card = game.getCard(target.getFirstTarget());
return card != null && targetPlayer.moveCards(card, Zone.EXILED, source, game);
}
use of mage.filter.predicate.card.OwnerIdPredicate in project mage by magefree.
the class SwayOfTheStarsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.moveCards(player.getHand(), Zone.LIBRARY, source, game);
player.moveCards(player.getGraveyard(), Zone.LIBRARY, source, game);
FilterPermanent filter = new FilterPermanent();
filter.add(new OwnerIdPredicate(playerId));
Cards toLib = new CardsImpl();
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, controller.getId(), source.getSourceId(), game)) {
toLib.add(permanent);
}
player.shuffleCardsToLibrary(toLib, game, source);
}
}
}
return true;
}
use of mage.filter.predicate.card.OwnerIdPredicate 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;
}
use of mage.filter.predicate.card.OwnerIdPredicate in project mage by magefree.
the class EnslavedHorrorEffect 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)) {
if (playerId.equals(controller.getId())) {
continue;
}
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(0, 1, 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.predicate.card.OwnerIdPredicate in project mage by magefree.
the class MemoryTheftEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
new DiscardCardYouChooseTargetEffect(StaticFilters.FILTER_CARD_NON_LAND, TargetController.ANY).apply(game, source);
Player controller = game.getPlayer(source.getControllerId());
Player player = game.getPlayer(source.getFirstTarget());
if (controller == null || player == null) {
return false;
}
FilterCard filter = new FilterCard("card owned by " + player.getName() + " that has an Adventure");
filter.add(AdventurePredicate.instance);
filter.add(new OwnerIdPredicate(player.getId()));
TargetCard target = new TargetCardInExile(0, 1, filter, null, true);
if (!target.canChoose(source.getSourceId(), source.getControllerId(), game) || !controller.choose(outcome, target, source.getSourceId(), game)) {
return false;
}
Card card = game.getCard(target.getFirstTarget());
return controller.moveCards(card, Zone.GRAVEYARD, source, game);
}
Aggregations