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