use of mage.filter.predicate.card.OwnerIdPredicate in project mage by magefree.
the class TerminusEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new OwnerIdPredicate(player.getId()));
Cards toLib = new CardsImpl();
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
toLib.add(permanent);
}
player.putCardsOnBottomOfLibrary(toLib, game, source, true);
}
}
return true;
}
use of mage.filter.predicate.card.OwnerIdPredicate in project mage by magefree.
the class VirtussManeuverEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
ChooseFriendsAndFoes choice = new ChooseFriendsAndFoes();
if (controller != null && !choice.chooseFriendOrFoe(controller, source, game)) {
return false;
}
Map<UUID, Card> getBackMap = new HashMap<>();
for (Player player : choice.getFriends()) {
if (player == null) {
continue;
}
FilterCard filter = new FilterCreatureCard("creature card in your graveyard");
filter.add(new OwnerIdPredicate(player.getId()));
TargetCardInGraveyard target = new TargetCardInGraveyard(filter);
getBackMap.put(player.getId(), null);
if (player.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) {
getBackMap.put(player.getId(), game.getCard(target.getFirstTarget()));
}
}
for (Player player : choice.getFriends()) {
if (player == null) {
continue;
}
Card card = getBackMap.getOrDefault(player.getId(), null);
if (card == null) {
continue;
}
player.moveCards(card, Zone.HAND, source, game);
}
List<UUID> perms = new ArrayList<>();
for (Player player : choice.getFoes()) {
if (player == null) {
continue;
}
TargetControlledPermanent target = new TargetControlledPermanent(1, 1, StaticFilters.FILTER_CONTROLLED_A_CREATURE, true);
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
perms.addAll(target.getTargets());
}
for (UUID permID : perms) {
Permanent permanent = game.getPermanent(permID);
if (permanent != null) {
permanent.sacrifice(source, game);
}
}
return true;
}
use of mage.filter.predicate.card.OwnerIdPredicate in project mage by magefree.
the class HeraldOfLeshracLeavesEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
if (playerId.equals(source.getControllerId())) {
continue;
}
FilterPermanent filter = new FilterLandPermanent();
filter.add(new OwnerIdPredicate(playerId));
filter.add(new ControllerIdPredicate(source.getControllerId()));
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfGame, playerId);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
}
}
return true;
}
use of mage.filter.predicate.card.OwnerIdPredicate in project mage by magefree.
the class TasigurTheGoldenFangEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
UUID opponentId = null;
if (game.getOpponents(controller.getId()).size() > 1) {
Target target = new TargetOpponent(true);
if (controller.chooseTarget(outcome, target, source, game)) {
opponentId = target.getFirstTarget();
}
} else {
opponentId = game.getOpponents(controller.getId()).iterator().next();
}
if (opponentId != null) {
Player opponent = game.getPlayer(opponentId);
if (opponent != null) {
FilterNonlandCard filter = new FilterNonlandCard("nonland card from " + controller.getLogName() + " graveyard");
filter.add(new OwnerIdPredicate(controller.getId()));
Target target = new TargetCardInGraveyard(filter);
target.setNotTarget(true);
opponent.chooseTarget(outcome, target, source, game);
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
controller.moveCards(card, Zone.HAND, source, game);
}
}
}
return true;
}
return false;
}
Aggregations