use of mage.filter.predicate.card.OwnerIdPredicate in project mage by magefree.
the class ForgottenLoreEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player you = game.getPlayer(source.getControllerId());
Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
if (you != null && opponent != null) {
FilterCard filter = new FilterCard();
filter.add(new OwnerIdPredicate(you.getId()));
Cost cost = new ManaCostsImpl("{G}");
TargetCardInGraveyard chosenCard;
Card card = null;
boolean done = false;
do {
chosenCard = new TargetCardInGraveyard(filter);
chosenCard.setNotTarget(true);
if (chosenCard.canChoose(source.getSourceId(), opponent.getId(), game)) {
opponent.chooseTarget(Outcome.ReturnToHand, chosenCard, source, game);
card = game.getCard(chosenCard.getFirstTarget());
if (card != null) {
filter.add(Predicates.not(new CardIdPredicate(card.getId())));
game.informPlayers("Forgotten Lore: " + opponent.getLogName() + " has chosen " + card.getLogName());
}
} else {
done = true;
}
if (!done) {
if (cost.canPay(source, source, you.getId(), game) && you.chooseUse(Outcome.Benefit, "Pay {G} to choose a different card ?", source, game)) {
cost.clearPaid();
if (!cost.pay(source, game, source, you.getId(), false, null)) {
done = true;
}
} else {
done = true;
}
}
} while (!done);
if (card != null) {
Cards cardsToHand = new CardsImpl();
cardsToHand.add(card);
you.moveCards(cardsToHand, Zone.HAND, source, game);
}
return true;
}
return false;
}
use of mage.filter.predicate.card.OwnerIdPredicate in project mage by magefree.
the class HurkylsRecallReturnToHandEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
if (targetPointer.getFirst(game, source) != null) {
FilterPermanent filter = new FilterArtifactPermanent();
filter.add(new OwnerIdPredicate(targetPointer.getFirst(game, source)));
return new ReturnToHandFromBattlefieldAllEffect(filter).apply(game, source);
}
return false;
}
use of mage.filter.predicate.card.OwnerIdPredicate in project mage by magefree.
the class InkEyesServantOfOniTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!event.getSourceId().equals(this.sourceId) || !((DamagedPlayerEvent) event).isCombatDamage()) {
return false;
}
Player damagedPlayer = game.getPlayer(event.getTargetId());
if (damagedPlayer == null) {
return false;
}
FilterCard filter = new FilterCard("creature in " + damagedPlayer.getName() + "'s graveyard");
filter.add(CardType.CREATURE.getPredicate());
filter.add(new OwnerIdPredicate(damagedPlayer.getId()));
TargetCardInGraveyard target = new TargetCardInGraveyard(filter);
this.getTargets().clear();
this.addTarget(target);
return true;
}
use of mage.filter.predicate.card.OwnerIdPredicate in project mage by magefree.
the class RelicOfProgenitusEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(source.getFirstTarget());
if (targetPlayer != null) {
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)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
targetPlayer.moveCardToExileWithInfo(card, null, "", source, game, Zone.GRAVEYARD, true);
}
return true;
}
}
return false;
}
use of mage.filter.predicate.card.OwnerIdPredicate in project mage by magefree.
the class TemptWithImmortalityEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
returnCreatureFromGraveToBattlefield(controller, source, game);
int opponentsReturnedCreatures = 0;
for (UUID playerId : game.getOpponents(controller.getId())) {
Player opponent = game.getPlayer(playerId);
if (opponent != null) {
FilterCard filter = new FilterCreatureCard("creature card from your graveyard");
filter.add(new OwnerIdPredicate(opponent.getId()));
Target targetCardOpponent = new TargetCardInGraveyard(filter);
if (targetCardOpponent.canChoose(source.getSourceId(), opponent.getId(), game)) {
if (opponent.chooseUse(outcome, "Return a creature card from your graveyard to the battlefield?", source, game)) {
if (opponent.chooseTarget(outcome, targetCardOpponent, source, game)) {
Card card = game.getCard(targetCardOpponent.getFirstTarget());
if (card != null) {
opponentsReturnedCreatures++;
opponent.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
}
}
}
}
if (opponentsReturnedCreatures > 0) {
for (int i = 0; i < opponentsReturnedCreatures; i++) {
returnCreatureFromGraveToBattlefield(controller, source, game);
}
}
return true;
}
return false;
}
Aggregations