// then sacrifices a third of the creatures he or she controls,
for (UUID playerId : controller.getInRange()) {
Player player = game.getPlayer(playerId);
if (player != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ControllerIdPredicate(playerId));
int creaturesToSacrifice = (int) Math.ceil(game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) / 3.0);
if (creaturesToSacrifice > 0) {
Target target = new TargetCreaturePermanent(creaturesToSacrifice, creaturesToSacrifice, filter, true);
target.choose(Outcome.Sacrifice, playerId, source.getSourceId(), game);
for (UUID permanentId : target.getTargets()) {
Permanent permanent = game.getPermanent(permanentId);
if (permanent != null) {
permanent.sacrifice(source.getSourceId(), game);
}
}
}
}
}
// then sacrifices a third of the lands he or she controls.
for (UUID playerId : controller.getInRange()) {
Player player = game.getPlayer(playerId);
if (player != null) {
FilterLandPermanent filter = new FilterLandPermanent();
filter.add(new ControllerIdPredicate(playerId));
int landsToSacrifice = (int) Math.ceil(game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) / 3.0);
if (landsToSacrifice > 0) {
Target target = new TargetLandPermanent(landsToSacrifice, landsToSacrifice, filter, true);
target.choose(Outcome.Sacrifice, playerId, source.getSourceId(), game);
for (UUID permanentId : target.getTargets()) {