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);
}
}
}