@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { // Each player loses a third of his or her life, for (UUID playerId : controller.getInRange()) { Player player = game.getPlayer(playerId); if (player != null) { int lifeToLose = (int) Math.ceil(player.getLife() / 3.0); player.loseLife(lifeToLose, game); } } // then discards a third of the cards in his or her hand, for (UUID playerId : controller.getInRange()) { Player player = game.getPlayer(playerId); if (player != null) { int cardsToDiscard = (int) Math.ceil(player.getHand().size() / 3.0); if (cardsToDiscard > 0) { player.discard(cardsToDiscard, false, source, game); } } } // then sacrifices a third of the creatures he or she controls, for (UUID playerId : controller.getInRange()) { Player player = game.getPlayer(playerId); if (player != null) { FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(); int creaturesToSacrifice = (int) Math.ceil( game.getBattlefield() .count(filter, source.getSourceId(), player.getId(), game) / 3.0); if (creaturesToSacrifice > 0) { Target target = new TargetControlledCreaturePermanent( creaturesToSacrifice, creaturesToSacrifice, filter, true); target.chooseTarget(Outcome.Sacrifice, playerId, source, 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) { FilterControlledLandPermanent filter = new FilterControlledLandPermanent(); int landsToSacrifice = (int) Math.ceil( game.getBattlefield() .count(filter, source.getSourceId(), player.getId(), game) / 3.0); if (landsToSacrifice > 0) { Target target = new TargetControlledPermanent(landsToSacrifice, landsToSacrifice, filter, true); target.chooseTarget(Outcome.Sacrifice, playerId, source, game); for (UUID permanentId : target.getTargets()) { Permanent permanent = game.getPermanent(permanentId); if (permanent != null) { permanent.sacrifice(source.getSourceId(), game); } } } } } return true; } return false; }