}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Target target = new TargetPermanentOrPlayerWithCounter(0, Integer.MAX_VALUE, true);
//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(controller.getId(), game)) {
boolean abilityApplied = false;
Map<String, Serializable> options = new HashMap<>();
options.put("UI.right.btn.text", "Done");
while (target.canChoose(controller.getId(), game)) {
if (controller.choose(Outcome.Benefit, target, source.getSourceId(), game, options)) {
break;
}
}
for (int idx = 0; idx < target.getTargets().size(); idx++) {
UUID chosen = (UUID) target.getTargets().get(idx);
Permanent permanent = game.getPermanent(chosen);
if (permanent != null) {
if (permanent.getCounters().size() > 0) {
if (permanent.getCounters().size() == 1) {
for (Counter counter : permanent.getCounters().values()) {