int minLand = Integer.MAX_VALUE;
Cards landsToSacrifice = new CardsImpl();
for (UUID playerId : controller.getInRange()) {
Player player = game.getPlayer(playerId);
if (player != null) {
int count = game.getBattlefield().countAll(new FilterControlledLandPermanent(), player.getId(), game);
if (count < minLand) {
minLand = count;
}
}
}
for (UUID playerId : controller.getInRange()) {
Player player = game.getPlayer(playerId);
if (player != null) {
TargetControlledPermanent target = new TargetControlledPermanent(minLand, minLand, new FilterControlledLandPermanent(), true);
if (target.choose(Outcome.Sacrifice, player.getId(), source.getSourceId(), game)) {
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledLandPermanent(), player.getId(), source.getSourceId(), game)) {
if (permanent != null && !target.getTargets().contains(permanent.getId())) {
landsToSacrifice.add(permanent);
}
}
}