@Override public PhaseOutAllEffect copy() { return new PhaseOutAllEffect(this); }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { List<UUID> permIds = new ArrayList<>(); for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_PERMANENT, controller.getId(), game)) { permIds.add(permanent.getId()); } return new PhaseOutAllEffect(permIds).apply(game, source); } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { List<UUID> permIds = new ArrayList<>(); for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledLandPermanent(), controller.getId(), game)) { permIds.add(permanent.getId()); } return new PhaseOutAllEffect(permIds).apply(game, source); } return false; } }
private void phaseOutCardType(Player controller, Player targetPlayer, CardType cardType, Ability source, Game game) { FilterPermanent filter = new FilterControlledPermanent(); filter.add(new CardTypePredicate(cardType)); int numberController = game.getBattlefield().count(filter, source.getSourceId(), controller.getId(), game); int numberTargetPlayer = game.getBattlefield().count(filter, source.getSourceId(), targetPlayer.getId(), game); int excess = numberTargetPlayer - numberController; if (excess > 0) { FilterPermanent filterChoose = new FilterPermanent(cardType.toString().toLowerCase(Locale.ENGLISH) + (excess > 1 ? "s" : "") + " of target player"); filterChoose.add(new ControllerIdPredicate(targetPlayer.getId())); filterChoose.add(new CardTypePredicate(cardType)); Target target = new TargetPermanent(excess, excess, filterChoose, true); controller.chooseTarget(outcome, target, source, game); new PhaseOutAllEffect(target.getTargets()).apply(game, source); } } }
permIds.add(permanent.getId()); return new PhaseOutAllEffect(permIds).apply(game, source);