use of mage.abilities.effects.common.ReturnToHandFromBattlefieldAllEffect in project mage by magefree.
the class DispersalEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Set<PermanentIdPredicate> permsToReturn = new HashSet<>();
for (UUID opponentId : game.getOpponents(player.getId())) {
Player opponent = game.getPlayer(opponentId);
if (opponent == null) {
continue;
}
int highestCMC = 0;
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(opponentId)) {
if (permanent != null) {
highestCMC = Math.max(highestCMC, permanent.getManaValue());
}
}
FilterPermanent filter = new FilterNonlandPermanent("permanent you control with mana value " + highestCMC);
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, highestCMC));
filter.add(new ControllerIdPredicate(opponentId));
Target target = new TargetPermanent(1, 1, filter, true);
if (opponent.choose(outcome, target, source.getSourceId(), game)) {
if (target.getFirstTarget() == null) {
continue;
}
permsToReturn.add(new PermanentIdPredicate(target.getFirstTarget()));
}
}
FilterPermanent filter = new FilterPermanent();
filter.add(Predicates.or(permsToReturn));
new ReturnToHandFromBattlefieldAllEffect(filter).apply(game, source);
new DiscardEachPlayerEffect(StaticValue.get(1), false, TargetController.OPPONENT).apply(game, source);
return true;
}
use of mage.abilities.effects.common.ReturnToHandFromBattlefieldAllEffect in project mage by magefree.
the class DromarTheBanisherEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
ChoiceColor choice = new ChoiceColor();
if (player.choose(outcome, choice, game)) {
game.informPlayers(player.getLogName() + " chooses " + choice.getChoice());
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ColorPredicate(choice.getColor()));
new ReturnToHandFromBattlefieldAllEffect(filter).apply(game, source);
return true;
}
}
return false;
}
use of mage.abilities.effects.common.ReturnToHandFromBattlefieldAllEffect 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;
}
Aggregations