int amount = Math.min(count, game.getBattlefield().countAll(new FilterControlledPermanent(), activePlayer.getId(), game));
Target target = new TargetControlledPermanent(amount, amount, new FilterControlledPermanent(), false);
//A spell or ability could have removed the only legal target this player
//had, if thats the case this ability should fizzle.
if (target.canChoose(activePlayer.getId(), game)) {
while (!target.isChosen() && target.canChoose(activePlayer.getId(), game) && activePlayer.isInGame()) {
activePlayer.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
}
for (int idx = 0; idx < target.getTargets().size(); idx++) {
Permanent permanent = game.getPermanent(target.getTargets().get(idx));