nus-yam/ex-repair huggingface dataset:
Program: 158360
Project: 158360
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Card creatureCard=game.getCard(this.getTargetPointer().getFirst(game,source));
  Player controller=game.getPlayer(source.getControllerId());
  if (creatureCard != null && controller != null) {
    boolean result=false;
    if (game.getState().getZone(creatureCard.getId()).equals(Zone.GRAVEYARD)) {
      controller.moveCards(creatureCard,Zone.BATTLEFIELD,source,game);
    }
    controller.loseLife(creatureCard.getConvertedManaCost(),game);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Card creatureCard=game.getCard(this.getTargetPointer().getFirst(game,source));
  Player controller=game.getPlayer(source.getControllerId());
  if (creatureCard != null && controller != null) {
    boolean result=false;
    if (game.getState().getZone(creatureCard.getId()).equals(Zone.GRAVEYARD)) {
      controller.moveCards(creatureCard,Zone.BATTLEFIELD,source,game);
    }
    controller.loseLife(creatureCard.getConvertedManaCost(),game,false);
    return true;
  }
  return false;
}
Program: 158361
Project: 158361
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getControllerId());
  Player targetPlayer=game.getPlayer(source.getFirstTarget());
  if (player != null && targetPlayer != null) {
    List<Permanent> creatures=game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(),player.getId(),game);
    int amount=0;
    for (    Permanent creature : creatures) {
      int power=creature.getPower().getValue();
      if (amount < power) {
        amount=power;
      }
    }
    if (amount > 0) {
      targetPlayer.loseLife(amount,game);
      player.gainLife(amount,game);
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getControllerId());
  Player targetPlayer=game.getPlayer(source.getFirstTarget());
  if (player != null && targetPlayer != null) {
    List<Permanent> creatures=game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(),player.getId(),game);
    int amount=0;
    for (    Permanent creature : creatures) {
      int power=creature.getPower().getValue();
      if (amount < power) {
        amount=power;
      }
    }
    if (amount > 0) {
      targetPlayer.loseLife(amount,game,false);
      player.gainLife(amount,game);
    }
    return true;
  }
  return false;
}
Program: 158363
Project: 158363
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    if (game.getBattlefield().countAll(new FilterCreaturePermanent("String_Node_Str","String_Node_Str"),source.getControllerId(),game) < 1) {
      controller.loseLife(2,game);
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    if (game.getBattlefield().countAll(new FilterCreaturePermanent("String_Node_Str","String_Node_Str"),source.getControllerId(),game) < 1) {
      controller.loseLife(2,game,false);
    }
    return true;
  }
  return false;
}
Program: 158364
Project: 158364
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    if (game.getBattlefield().countAll(new FilterCreaturePermanent("String_Node_Str","String_Node_Str"),source.getControllerId(),game) < 1) {
      controller.loseLife(1,game);
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    if (game.getBattlefield().countAll(new FilterCreaturePermanent("String_Node_Str","String_Node_Str"),source.getControllerId(),game) < 1) {
      controller.loseLife(1,game,false);
    }
    return true;
  }
  return false;
}
Program: 158365
Project: 158365
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getControllerId());
  if (player == null) {
    return false;
  }
  if (player.getLibrary().size() > 0) {
    Card card=player.getLibrary().getFromTop(game);
    Cards cards=new CardsImpl();
    cards.add(card);
    player.revealCards("String_Node_Str",cards,game);
    if (card != null && card.moveToZone(Zone.HAND,source.getSourceId(),game,false)) {
      player.loseLife(card.getConvertedManaCost(),game);
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getControllerId());
  if (player == null) {
    return false;
  }
  if (player.getLibrary().size() > 0) {
    Card card=player.getLibrary().getFromTop(game);
    Cards cards=new CardsImpl();
    cards.add(card);
    player.revealCards("String_Node_Str",cards,game);
    if (card != null && card.moveToZone(Zone.HAND,source.getSourceId(),game,false)) {
      player.loseLife(card.getConvertedManaCost(),game,false);
      return true;
    }
  }
  return false;
}
Program: 158366
Project: 158366
Buggy source:
@Override public boolean apply(Game game,Ability source){
  int lostAmount=0;
  for (  UUID opponentId : game.getOpponents(source.getControllerId())) {
    lostAmount+=game.getPlayer(opponentId).loseLife(1,game);
  }
  game.getPlayer(source.getControllerId()).gainLife(lostAmount,game);
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  int lostAmount=0;
  for (  UUID opponentId : game.getOpponents(source.getControllerId())) {
    lostAmount+=game.getPlayer(opponentId).loseLife(1,game,false);
  }
  game.getPlayer(source.getControllerId()).gainLife(lostAmount,game);
  return true;
}
Program: 158367
Project: 158367
Buggy source:
@Override public boolean apply(Game game,Ability source){
  int numberSpirits=0;
  for (  Cost cost : source.getCosts()) {
    if (cost instanceof SacrificeTargetCost) {
      numberSpirits+=((SacrificeTargetCost)cost).getPermanents().size();
    }
  }
  int amount=2 + (numberSpirits * 2);
  Player targetPlayer=game.getPlayer(getTargetPointer().getFirst(game,source));
  Player sourcePlayer=game.getPlayer(source.getControllerId());
  if (targetPlayer != null && sourcePlayer != null) {
    targetPlayer.loseLife(amount,game);
    sourcePlayer.gainLife(amount,game);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  int numberSpirits=0;
  for (  Cost cost : source.getCosts()) {
    if (cost instanceof SacrificeTargetCost) {
      numberSpirits+=((SacrificeTargetCost)cost).getPermanents().size();
    }
  }
  int amount=2 + (numberSpirits * 2);
  Player targetPlayer=game.getPlayer(getTargetPointer().getFirst(game,source));
  Player sourcePlayer=game.getPlayer(source.getControllerId());
  if (targetPlayer != null && sourcePlayer != null) {
    targetPlayer.loseLife(amount,game,false);
    sourcePlayer.gainLife(amount,game);
    return true;
  }
  return false;
}
Program: 158368
Project: 158368
Buggy source:
@Override public boolean apply(Game game,Ability source){
  int loseLife=0;
  for (  UUID opponentId : game.getOpponents(source.getControllerId())) {
    loseLife+=game.getPlayer(opponentId).loseLife(5,game);
  }
  if (loseLife > 0)   game.getPlayer(source.getControllerId()).gainLife(loseLife,game);
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  int loseLife=0;
  for (  UUID opponentId : game.getOpponents(source.getControllerId())) {
    loseLife+=game.getPlayer(opponentId).loseLife(5,game,false);
  }
  if (loseLife > 0)   game.getPlayer(source.getControllerId()).gainLife(loseLife,game);
  return true;
}
Program: 158369
Project: 158369
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getControllerId());
  if (player == null) {
    return false;
  }
  boolean doAgain;
  do {
    Cards cards=new CardsImpl();
    int count=Math.min(player.getLibrary().size(),5);
    for (int i=0; i < count; i++) {
      Card card=player.getLibrary().removeFromTop(game);
      if (card != null) {
        cards.add(card);
      }
    }
    player.lookAtCards("String_Node_Str",cards,game);
    doAgain=player.chooseUse(outcome,"String_Node_Str",source,game);
    if (doAgain) {
      player.loseLife(1,game);
    }
 else {
      player.shuffleLibrary(source,game);
    }
    TargetCard target=new TargetCard(Zone.LIBRARY,new FilterCard(doAgain ? textBottom : textTop));
    while (player.canRespond() && cards.size() > 1) {
      player.choose(Outcome.Neutral,cards,target,game);
      Card card=cards.get(target.getFirstTarget(),game);
      if (card != null) {
        cards.remove(card);
        card.moveToZone(Zone.LIBRARY,source.getSourceId(),game,!doAgain);
      }
      target.clearChosen();
    }
    if (cards.size() == 1) {
      Card card=cards.get(cards.iterator().next(),game);
      card.moveToZone(Zone.LIBRARY,source.getSourceId(),game,!doAgain);
    }
  }
 while (doAgain);
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getControllerId());
  if (player == null) {
    return false;
  }
  boolean doAgain;
  do {
    Cards cards=new CardsImpl();
    int count=Math.min(player.getLibrary().size(),5);
    for (int i=0; i < count; i++) {
      Card card=player.getLibrary().removeFromTop(game);
      if (card != null) {
        cards.add(card);
      }
    }
    player.lookAtCards("String_Node_Str",cards,game);
    doAgain=player.chooseUse(outcome,"String_Node_Str",source,game);
    if (doAgain) {
      player.loseLife(1,game,false);
    }
 else {
      player.shuffleLibrary(source,game);
    }
    TargetCard target=new TargetCard(Zone.LIBRARY,new FilterCard(doAgain ? textBottom : textTop));
    while (player.canRespond() && cards.size() > 1) {
      player.choose(Outcome.Neutral,cards,target,game);
      Card card=cards.get(target.getFirstTarget(),game);
      if (card != null) {
        cards.remove(card);
        card.moveToZone(Zone.LIBRARY,source.getSourceId(),game,!doAgain);
      }
      target.clearChosen();
    }
    if (cards.size() == 1) {
      Card card=cards.get(cards.iterator().next(),game);
      card.moveToZone(Zone.LIBRARY,source.getSourceId(),game,!doAgain);
    }
  }
 while (doAgain);
  return true;
}
Program: 158370
Project: 158370
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    int loseLife=0;
    for (    UUID opponentId : game.getOpponents(source.getControllerId())) {
      Player opponent=game.getPlayer(opponentId);
      if (opponent != null) {
        loseLife+=opponent.loseLife(1,game);
      }
    }
    controller.gainLife(loseLife,game);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    int loseLife=0;
    for (    UUID opponentId : game.getOpponents(source.getControllerId())) {
      Player opponent=game.getPlayer(opponentId);
      if (opponent != null) {
        loseLife+=opponent.loseLife(1,game,false);
      }
    }
    controller.gainLife(loseLife,game);
    return true;
  }
  return false;
}
Program: 158371
Project: 158371
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(getTargetPointer().getFirst(game,source));
  if (player != null) {
    Integer amount=(int)Math.ceil(player.getLife() / 2f);
    if (amount > 0) {
      player.loseLife(amount,game);
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(getTargetPointer().getFirst(game,source));
  if (player != null) {
    Integer amount=(int)Math.ceil(player.getLife() / 2f);
    if (amount > 0) {
      player.loseLife(amount,game,false);
    }
    return true;
  }
  return false;
}
Program: 158372
Project: 158372
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    HashMap<UUID,Integer> destroyedCreatures=new HashMap<>();
    for (    Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(),source.getControllerId(),source.getSourceId(),game)) {
      if (permanent.destroy(source.getSourceId(),game,false)) {
        int count=destroyedCreatures.containsKey(permanent.getControllerId()) ? destroyedCreatures.get(permanent.getControllerId()) : 0;
        destroyedCreatures.put(permanent.getControllerId(),count + 1);
      }
    }
    for (    UUID playerId : game.getState().getPlayerList(source.getControllerId())) {
      int count=destroyedCreatures.containsKey(playerId) ? destroyedCreatures.get(playerId) : 0;
      if (count > 0) {
        Player player=game.getPlayer(playerId);
        if (player != null) {
          player.loseLife(count,game);
        }
      }
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    HashMap<UUID,Integer> destroyedCreatures=new HashMap<>();
    for (    Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(),source.getControllerId(),source.getSourceId(),game)) {
      if (permanent.destroy(source.getSourceId(),game,false)) {
        int count=destroyedCreatures.containsKey(permanent.getControllerId()) ? destroyedCreatures.get(permanent.getControllerId()) : 0;
        destroyedCreatures.put(permanent.getControllerId(),count + 1);
      }
    }
    for (    UUID playerId : game.getState().getPlayerList(source.getControllerId())) {
      int count=destroyedCreatures.containsKey(playerId) ? destroyedCreatures.get(playerId) : 0;
      if (count > 0) {
        Player player=game.getPlayer(playerId);
        if (player != null) {
          player.loseLife(count,game,false);
        }
      }
    }
    return true;
  }
  return false;
}
Program: 158373
Project: 158373
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(getTargetPointer().getFirst(game,source));
  if (player != null) {
    Integer amount=(int)Math.ceil(player.getLife() / 2f);
    if (amount > 0) {
      player.loseLife(amount,game);
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(getTargetPointer().getFirst(game,source));
  if (player != null) {
    Integer amount=(int)Math.ceil(player.getLife() / 2f);
    if (amount > 0) {
      player.loseLife(amount,game,false);
    }
    return true;
  }
  return false;
}
Program: 158374
Project: 158374
Buggy source:
@Override public boolean apply(Game game,Ability source){
  int counters=0;
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    for (    UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
      Player player=game.getPlayer(playerId);
      if (player != null) {
        if (player.loseLife(1,game) > 0) {
          counters++;
        }
      }
    }
    Permanent bloodTyrant=game.getPermanent(source.getSourceId());
    if (bloodTyrant != null && counters > 0) {
      bloodTyrant.addCounters(CounterType.P1P1.createInstance(counters),game);
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  int counters=0;
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    for (    UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
      Player player=game.getPlayer(playerId);
      if (player != null) {
        if (player.loseLife(1,game,false) > 0) {
          counters++;
        }
      }
    }
    Permanent bloodTyrant=game.getPermanent(source.getSourceId());
    if (bloodTyrant != null && counters > 0) {
      bloodTyrant.addCounters(CounterType.P1P1.createInstance(counters),game);
    }
    return true;
  }
  return false;
}
Program: 158375
Project: 158375
Buggy source:
@Override public boolean apply(Game game,Ability source){
  for (  UUID opponentId : game.getOpponents(source.getControllerId())) {
    Player opponent=game.getPlayer(opponentId);
    if (opponent != null) {
      opponent.loseLife(2,game);
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  for (  UUID opponentId : game.getOpponents(source.getControllerId())) {
    Player opponent=game.getPlayer(opponentId);
    if (opponent != null) {
      opponent.loseLife(2,game,false);
    }
  }
  return true;
}
Program: 158376
Project: 158376
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player targetPlayer=game.getPlayer(source.getFirstTarget());
  Player you=game.getPlayer(source.getControllerId());
  if (targetPlayer != null) {
    targetPlayer.loseLife(1,game);
  }
  if (you != null) {
    you.gainLife(1,game);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player targetPlayer=game.getPlayer(source.getFirstTarget());
  Player you=game.getPlayer(source.getControllerId());
  if (targetPlayer != null) {
    targetPlayer.loseLife(1,game,false);
  }
  if (you != null) {
    you.gainLife(1,game);
  }
  return true;
}
Program: 158377
Project: 158377
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    for (    UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
      final int count=game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(),playerId,game).size();
      if (count > 0) {
        Player player=game.getPlayer(playerId);
        if (player != null) {
          player.loseLife(count,game);
        }
      }
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    for (    UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
      final int count=game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(),playerId,game).size();
      if (count > 0) {
        Player player=game.getPlayer(playerId);
        if (player != null) {
          player.loseLife(count,game,false);
        }
      }
    }
    return true;
  }
  return false;
}
Program: 158378
Project: 158378
Buggy source:
@Override public boolean apply(Game game,Ability source){
  for (  UUID opponentId : game.getOpponents(source.getControllerId())) {
    game.getPlayer(opponentId).loseLife(4,game);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  for (  UUID opponentId : game.getOpponents(source.getControllerId())) {
    game.getPlayer(opponentId).loseLife(4,game,false);
  }
  return true;
}
Program: 158379
Project: 158379
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  Permanent sourcePermanent=game.getPermanent(source.getSourceId());
  if (controller != null && sourcePermanent != null) {
    if (getTargetPointer().getFirst(game,source) != null) {
      Permanent targetCreature=game.getPermanent(getTargetPointer().getFirst(game,source));
      if (targetCreature != null) {
        int zcc=targetCreature.getZoneChangeCounter(game);
        if (controller.moveCards(targetCreature,Zone.EXILED,source,game)) {
          Effect effect=new ReturnToBattlefieldUnderOwnerControlTargetEffect();
          effect.setTargetPointer(new FixedTarget(targetCreature.getId(),zcc + 1));
          AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility delayedAbility=new AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(effect);
          game.addDelayedTriggeredAbility(delayedAbility,source);
        }
      }
    }
 else {
      int zcc=sourcePermanent.getZoneChangeCounter(game);
      if (controller.moveCards(sourcePermanent,Zone.EXILED,source,game)) {
        Effect effect=new ReturnToBattlefieldUnderOwnerControlTargetEffect();
        effect.setTargetPointer(new FixedTarget(sourcePermanent.getId(),zcc + 1));
        AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility delayedAbility=new AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(effect);
        game.addDelayedTriggeredAbility(delayedAbility,source);
      }
    }
    controller.loseLife(2,game);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  Permanent sourcePermanent=game.getPermanent(source.getSourceId());
  if (controller != null && sourcePermanent != null) {
    if (getTargetPointer().getFirst(game,source) != null) {
      Permanent targetCreature=game.getPermanent(getTargetPointer().getFirst(game,source));
      if (targetCreature != null) {
        int zcc=targetCreature.getZoneChangeCounter(game);
        if (controller.moveCards(targetCreature,Zone.EXILED,source,game)) {
          Effect effect=new ReturnToBattlefieldUnderOwnerControlTargetEffect();
          effect.setTargetPointer(new FixedTarget(targetCreature.getId(),zcc + 1));
          AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility delayedAbility=new AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(effect);
          game.addDelayedTriggeredAbility(delayedAbility,source);
        }
      }
    }
 else {
      int zcc=sourcePermanent.getZoneChangeCounter(game);
      if (controller.moveCards(sourcePermanent,Zone.EXILED,source,game)) {
        Effect effect=new ReturnToBattlefieldUnderOwnerControlTargetEffect();
        effect.setTargetPointer(new FixedTarget(sourcePermanent.getId(),zcc + 1));
        AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility delayedAbility=new AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(effect);
        game.addDelayedTriggeredAbility(delayedAbility,source);
      }
    }
    controller.loseLife(2,game,false);
    return true;
  }
  return false;
}
Program: 158380
Project: 158380
Buggy source:
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Player player=game.getPlayer(event.getPlayerId());
  if (player != null) {
    player.loseLife(event.getAmount(),game);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Player player=game.getPlayer(event.getPlayerId());
  if (player != null) {
    player.loseLife(event.getAmount(),game,false);
  }
  return true;
}
Program: 158381
Project: 158381
Buggy source:
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Player player=game.getPlayer(event.getPlayerId());
  if (player != null) {
    player.drawCards(2,game,event.getAppliedEffects());
    player.loseLife(1,game);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Player player=game.getPlayer(event.getPlayerId());
  if (player != null) {
    player.drawCards(2,game,event.getAppliedEffects());
    player.loseLife(1,game,false);
  }
  return true;
}
Program: 158382
Project: 158382
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player targetPlayer=game.getPlayer(targetPointer.getFirst(game,source));
  if (targetPlayer != null) {
    targetPlayer.drawCards(source.getManaCostsToPay().getX(),game);
    targetPlayer.loseLife(source.getManaCostsToPay().getX(),game);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player targetPlayer=game.getPlayer(targetPointer.getFirst(game,source));
  if (targetPlayer != null) {
    targetPlayer.drawCards(source.getManaCostsToPay().getX(),game);
    targetPlayer.loseLife(source.getManaCostsToPay().getX(),game,false);
    return true;
  }
  return false;
}
Program: 158383
Project: 158383
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  Player targetOpponent=game.getPlayer(getTargetPointer().getFirst(game,source));
  if (controller != null && targetOpponent != null) {
    int amount=new AttackingFilterCreatureCount(filter).calculate(game,source,this);
    if (amount > 0) {
      targetOpponent.loseLife(amount,game);
      controller.gainLife(amount,game);
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  Player targetOpponent=game.getPlayer(getTargetPointer().getFirst(game,source));
  if (controller != null && targetOpponent != null) {
    int amount=new AttackingFilterCreatureCount(filter).calculate(game,source,this);
    if (amount > 0) {
      targetOpponent.loseLife(amount,game,false);
      controller.gainLife(amount,game);
    }
    return true;
  }
  return false;
}
Program: 158384
Project: 158384
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player targetOpponent=game.getPlayer(source.getTargets().getFirstTarget());
  Player controller=game.getPlayer(source.getControllerId());
  if (targetOpponent == null || controller == null) {
    return false;
  }
  FilterControlledPermanent filter=new FilterControlledPermanent("String_Node_Str");
  filter.add(new CardTypePredicate(CardType.CREATURE));
  filter.add(new ControllerPredicate(TargetController.YOU));
  filter.add(Predicates.or(new ColorPredicate(ObjectColor.GREEN),new ColorPredicate(ObjectColor.WHITE)));
  TargetControlledPermanent target=new TargetControlledPermanent(1,1,filter,true);
  if (target.canChoose(source.getSourceId(),targetOpponent.getId(),game)) {
    targetOpponent.chooseTarget(Outcome.Sacrifice,target,source,game);
    Permanent permanent=game.getPermanent(target.getFirstTarget());
    if (permanent != null) {
      if (permanent.sacrifice(source.getSourceId(),game)) {
        targetOpponent.loseLife(2,game);
      }
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player targetOpponent=game.getPlayer(source.getTargets().getFirstTarget());
  Player controller=game.getPlayer(source.getControllerId());
  if (targetOpponent == null || controller == null) {
    return false;
  }
  FilterControlledPermanent filter=new FilterControlledPermanent("String_Node_Str");
  filter.add(new CardTypePredicate(CardType.CREATURE));
  filter.add(new ControllerPredicate(TargetController.YOU));
  filter.add(Predicates.or(new ColorPredicate(ObjectColor.GREEN),new ColorPredicate(ObjectColor.WHITE)));
  TargetControlledPermanent target=new TargetControlledPermanent(1,1,filter,true);
  if (target.canChoose(source.getSourceId(),targetOpponent.getId(),game)) {
    targetOpponent.chooseTarget(Outcome.Sacrifice,target,source,game);
    Permanent permanent=game.getPermanent(target.getFirstTarget());
    if (permanent != null) {
      if (permanent.sacrifice(source.getSourceId(),game)) {
        targetOpponent.loseLife(2,game,false);
      }
    }
  }
  return true;
}
Program: 158385
Project: 158385
Buggy source:
@Override public boolean pay(Ability ability,Game game,UUID sourceId,UUID controllerId,boolean noMana,Cost costToPay){
  Player controller=game.getPlayer(controllerId);
  if (controller != null) {
    int currentLife=controller.getLife();
    int lifeToPay=(currentLife + currentLife % 2) / 2;
    if (lifeToPay < 0) {
      this.paid=true;
    }
 else {
      this.paid=(controller.loseLife(lifeToPay,game) == lifeToPay);
    }
    return this.paid;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean pay(Ability ability,Game game,UUID sourceId,UUID controllerId,boolean noMana,Cost costToPay){
  Player controller=game.getPlayer(controllerId);
  if (controller != null) {
    int currentLife=controller.getLife();
    int lifeToPay=(currentLife + currentLife % 2) / 2;
    if (lifeToPay < 0) {
      this.paid=true;
    }
 else {
      this.paid=(controller.loseLife(lifeToPay,game,false) == lifeToPay);
    }
    return this.paid;
  }
  return false;
}
Program: 158386
Project: 158386
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player you=game.getPlayer(source.getControllerId());
  Permanent permanent=game.getPermanent(this.getTargetPointer().getFirst(game,source));
  if (permanent != null && you != null) {
    permanent.destroy(source.getSourceId(),game,false);
    Player permController=game.getPlayer(permanent.getControllerId());
    if (permController != null) {
      permController.loseLife(2,game);
      you.gainLife(2,game);
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player you=game.getPlayer(source.getControllerId());
  Permanent permanent=game.getPermanent(this.getTargetPointer().getFirst(game,source));
  if (permanent != null && you != null) {
    permanent.destroy(source.getSourceId(),game,false);
    Player permController=game.getPlayer(permanent.getControllerId());
    if (permController != null) {
      permController.loseLife(2,game,false);
      you.gainLife(2,game);
      return true;
    }
  }
  return false;
}
Program: 158387
Project: 158387
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    for (    UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
      final int amount=game.getBattlefield().getAllActivePermanents(new FilterAttackingCreature(),playerId,game).size();
      if (amount > 0) {
        Player player=game.getPlayer(playerId);
        if (player != null) {
          player.loseLife(amount,game);
        }
      }
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    for (    UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
      final int amount=game.getBattlefield().getAllActivePermanents(new FilterAttackingCreature(),playerId,game).size();
      if (amount > 0) {
        Player player=game.getPlayer(playerId);
        if (player != null) {
          player.loseLife(amount,game,false);
        }
      }
    }
    return true;
  }
  return false;
}
Program: 158388
Project: 158388
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  MageObject sourceObject=source.getSourceObject(game);
  if (controller != null && sourceObject != null) {
    if (controller.getLibrary().size() > 0) {
      Card card=controller.getLibrary().getFromTop(game);
      Cards cards=new CardsImpl(card);
      controller.revealCards(sourceObject.getIdName(),cards,game);
      if (card.getCardType().contains(CardType.CREATURE)) {
        controller.gainLife(card.getToughness().getValue(),game);
        controller.loseLife(card.getPower().getValue(),game);
        return controller.moveCards(cards.getCards(game),Zone.HAND,source,game);
      }
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  MageObject sourceObject=source.getSourceObject(game);
  if (controller != null && sourceObject != null) {
    if (controller.getLibrary().size() > 0) {
      Card card=controller.getLibrary().getFromTop(game);
      Cards cards=new CardsImpl(card);
      controller.revealCards(sourceObject.getIdName(),cards,game);
      if (card.getCardType().contains(CardType.CREATURE)) {
        controller.gainLife(card.getToughness().getValue(),game);
        controller.loseLife(card.getPower().getValue(),game,false);
        return controller.moveCards(cards.getCards(game),Zone.HAND,source,game);
      }
    }
    return true;
  }
  return false;
}
Program: 158389
Project: 158389
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player caster=game.getPlayer(targetPointer.getFirst(game,source));
  if (caster != null) {
    caster.loseLife(1,game);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player caster=game.getPlayer(targetPointer.getFirst(game,source));
  if (caster != null) {
    caster.loseLife(1,game,false);
    return true;
  }
  return false;
}
Program: 158390
Project: 158390
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Permanent creature=game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game,source));
  if (creature != null) {
    Player controller=game.getPlayer(creature.getControllerId());
    if (controller != null) {
      controller.loseLife(3,game);
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Permanent creature=game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game,source));
  if (creature != null) {
    Player controller=game.getPlayer(creature.getControllerId());
    if (controller != null) {
      controller.loseLife(3,game,false);
      return true;
    }
  }
  return false;
}
Program: 158391
Project: 158391
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getControllerId());
  Permanent target=game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game,source));
  if (player != null && target != null) {
    player.loseLife(target.getToughness().getValue(),game);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getControllerId());
  Permanent target=game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game,source));
  if (player != null && target != null) {
    player.loseLife(target.getToughness().getValue(),game,false);
    return true;
  }
  return false;
}
Program: 158393
Project: 158393
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    int creaturesControlled=game.getBattlefield().countAll(new FilterCreaturePermanent(),controller.getId(),game);
    controller.drawCards(creaturesControlled,game);
    controller.loseLife(creaturesControlled,game);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    int creaturesControlled=game.getBattlefield().countAll(new FilterCreaturePermanent(),controller.getId(),game);
    controller.drawCards(creaturesControlled,game);
    controller.loseLife(creaturesControlled,game,false);
    return true;
  }
  return false;
}
Program: 158394
Project: 158394
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Card sourceCard=game.getCard(source.getSourceId());
  if (sourceCard == null) {
    return false;
  }
  for (  Player player : game.getPlayers().values()) {
    if (player.getLibrary().size() > 0) {
      Card card=player.getLibrary().removeFromTop(game);
      if (card != null) {
        Cards cards=new CardsImpl();
        cards.add(card);
        player.revealCards(sourceCard.getName() + "String_Node_Str" + player.getName(),cards,game);
        player.loseLife(card.getConvertedManaCost(),game);
        card.moveToZone(Zone.HAND,source.getSourceId(),game,true);
      }
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Card sourceCard=game.getCard(source.getSourceId());
  if (sourceCard == null) {
    return false;
  }
  for (  Player player : game.getPlayers().values()) {
    if (player.getLibrary().size() > 0) {
      Card card=player.getLibrary().removeFromTop(game);
      if (card != null) {
        Cards cards=new CardsImpl();
        cards.add(card);
        player.revealCards(sourceCard.getName() + "String_Node_Str" + player.getName(),cards,game);
        player.loseLife(card.getConvertedManaCost(),game,false);
        card.moveToZone(Zone.HAND,source.getSourceId(),game,true);
      }
    }
  }
  return true;
}
Program: 158395
Project: 158395
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Permanent target=game.getPermanent(getTargetPointer().getFirst(game,source));
  Player controller=game.getPlayer(source.getControllerId());
  if (target != null && controller != null) {
    int toughness=target.getToughness().getValue();
    target.destroy(source.getSourceId(),game,false);
    if (toughness > 0) {
      controller.loseLife(toughness,game);
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Permanent target=game.getPermanent(getTargetPointer().getFirst(game,source));
  Player controller=game.getPlayer(source.getControllerId());
  if (target != null && controller != null) {
    int toughness=target.getToughness().getValue();
    target.destroy(source.getSourceId(),game,false);
    if (toughness > 0) {
      controller.loseLife(toughness,game,false);
    }
    return true;
  }
  return false;
}
Program: 158397
Project: 158397
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Integer amountLifeGained=(Integer)this.getValue("String_Node_Str");
  if (amountLifeGained != null) {
    for (    UUID opponentId : game.getOpponents(source.getControllerId())) {
      Player opponent=game.getPlayer(opponentId);
      if (opponent != null) {
        opponent.loseLife(amountLifeGained,game);
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Integer amountLifeGained=(Integer)this.getValue("String_Node_Str");
  if (amountLifeGained != null) {
    for (    UUID opponentId : game.getOpponents(source.getControllerId())) {
      Player opponent=game.getPlayer(opponentId);
      if (opponent != null) {
        opponent.loseLife(amountLifeGained,game,false);
      }
    }
  }
  return false;
}
Program: 158398
Project: 158398
Buggy source:
@Override public boolean apply(Game game,Ability source){
  int loseLife=0;
  for (  UUID opponentId : game.getOpponents(source.getControllerId())) {
    loseLife+=game.getPlayer(opponentId).loseLife(1,game);
  }
  if (loseLife > 0)   game.getPlayer(source.getControllerId()).gainLife(loseLife,game);
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  int loseLife=0;
  for (  UUID opponentId : game.getOpponents(source.getControllerId())) {
    loseLife+=game.getPlayer(opponentId).loseLife(1,game,false);
  }
  if (loseLife > 0)   game.getPlayer(source.getControllerId()).gainLife(loseLife,game);
  return true;
}
Program: 158399
Project: 158399
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player targetPlayer=game.getPlayer(source.getFirstTarget());
  Player controllerPlayer=game.getPlayer(source.getControllerId());
  if (targetPlayer != null && controllerPlayer != null) {
    targetPlayer.loseLife(1,game);
    controllerPlayer.gainLife(1,game);
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player targetPlayer=game.getPlayer(source.getFirstTarget());
  Player controllerPlayer=game.getPlayer(source.getControllerId());
  if (targetPlayer != null && controllerPlayer != null) {
    targetPlayer.loseLife(1,game,false);
    controllerPlayer.gainLife(1,game);
  }
  return false;
}
Program: 158400
Project: 158400
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Integer amount=(Integer)this.getValue("String_Node_Str");
  Player player=game.getPlayer(source.getControllerId());
  if (player != null) {
    player.gainLife(amount,game);
  }
  UUID attackerId=(UUID)this.getValue("String_Node_Str");
  Player attacker=game.getPlayer(attackerId);
  if (attacker != null) {
    attacker.loseLife(amount,game);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Integer amount=(Integer)this.getValue("String_Node_Str");
  Player player=game.getPlayer(source.getControllerId());
  if (player != null) {
    player.gainLife(amount,game);
  }
  UUID attackerId=(UUID)this.getValue("String_Node_Str");
  Player attacker=game.getPlayer(attackerId);
  if (attacker != null) {
    attacker.loseLife(amount,game,false);
  }
  return true;
}
Program: 158401
Project: 158401
Buggy source:
public Modes(final Modes modes){
  for (  Map.Entry<UUID,Mode> entry : modes.entrySet()) {
    this.put(entry.getKey(),entry.getValue().copy());
  }
  this.minModes=modes.minModes;
  this.maxModes=modes.maxModes;
  this.currentMode=values().iterator().next();
  selectedModes.addAll(modes.getSelectedModes());
  this.modeChooser=modes.modeChooser;
  this.eachModeOnlyOnce=modes.eachModeOnlyOnce;
  this.eachModeMoreThanOnce=modes.eachModeMoreThanOnce;
}

Fixed version (ground truth):
public Modes(final Modes modes){
  for (  Map.Entry<UUID,Mode> entry : modes.entrySet()) {
    this.put(entry.getKey(),entry.getValue().copy());
  }
  this.minModes=modes.minModes;
  this.maxModes=modes.maxModes;
  this.selectedModes.addAll(modes.getSelectedModes());
  if (modes.getSelectedModes().isEmpty()) {
    this.currentMode=values().iterator().next();
  }
 else {
    this.currentMode=get(selectedModes.get(0));
  }
  this.modeChooser=modes.modeChooser;
  this.eachModeOnlyOnce=modes.eachModeOnlyOnce;
  this.eachModeMoreThanOnce=modes.eachModeMoreThanOnce;
}
Program: 158402
Project: 158402
Buggy source:
@Override public boolean applies(GameEvent event,Ability source,Game game){
  if (event.getTargetId().equals(source.getSourceId())) {
    ZoneChangeEvent zEvent=(ZoneChangeEvent)event;
    if (zEvent.getFromZone() == Zone.STACK && source.getSourceId().equals(event.getSourceId())) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(GameEvent event,Ability source,Game game){
  if (event.getTargetId().equals(source.getSourceId())) {
    ZoneChangeEvent zEvent=(ZoneChangeEvent)event;
    if (zEvent.getFromZone() == Zone.STACK && zEvent.getToZone() == Zone.GRAVEYARD && source.getSourceId().equals(event.getSourceId())) {
      return true;
    }
  }
  return false;
}
Program: 158403
Project: 158403
Buggy source:
/** 
 * Tatterkite is getting counters on it, i have him in a edh deck with Mikaeus, the Lunarch and when Tatterkite dies it triggers the undying and he gets the +1/+1 counters
 */
@Test public void testUndyingMikaeusAndTatterkite(){
  addCard(Zone.HAND,playerA,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str","String_Node_Str");
  setStopAt(1,PhaseStep.BEGIN_COMBAT);
  execute();
  assertGraveyardCount(playerA,"String_Node_Str",1);
  assertPermanentCount(playerA,"String_Node_Str",1);
  assertPermanentCount(playerA,"String_Node_Str",1);
  assertCounterCount("String_Node_Str",CounterType.P1P1,0);
  assertPowerToughness(playerA,"String_Node_Str",3,2);
}

Fixed version (ground truth):
/** 
 * Tatterkite is getting counters on it, I have him in a edh deck with Mikaeus, the Lunarch and when Tatterkite dies it triggers the undying and he gets the +1/+1 counters
 */
@Test public void testUndyingMikaeusAndTatterkite(){
  addCard(Zone.HAND,playerA,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str","String_Node_Str");
  setStopAt(1,PhaseStep.BEGIN_COMBAT);
  execute();
  assertGraveyardCount(playerA,"String_Node_Str",1);
  assertPermanentCount(playerA,"String_Node_Str",1);
  assertPermanentCount(playerA,"String_Node_Str",1);
  assertCounterCount("String_Node_Str",CounterType.P1P1,0);
  assertPowerToughness(playerA,"String_Node_Str",3,2);
}
Program: 158404
Project: 158404
Buggy source:
@Override public boolean isInUseableZone(Game game,MageObject source,GameEvent event){
  if (game.getShortLivingLKI(getSourceId(),zone)) {
    return true;
  }
  return super.isInUseableZone(game,source,event);
}

Fixed version (ground truth):
@Override public boolean isInUseableZone(Game game,MageObject source,GameEvent event){
  if (game.getShortLivingLKI(getSourceId(),zone)) {
    return true;
  }
  if (game.getPermanentEntering(getSourceId()) != null && zone.equals(Zone.BATTLEFIELD)) {
    return true;
  }
  return super.isInUseableZone(game,source,event);
}
Program: 158405
Project: 158405
Buggy source:
@Override public boolean moveToZone(Zone toZone,UUID sourceId,Game game,boolean flag,ArrayList<UUID> appliedEffects){
  Zone fromZone=game.getState().getZone(objectId);
  ZoneChangeEvent event=new ZoneChangeEvent(this.objectId,sourceId,ownerId,fromZone,toZone,appliedEffects);
  ZoneChangeInfo zoneChangeInfo;
  if (toZone == Zone.LIBRARY) {
    zoneChangeInfo=new ZoneChangeInfo.Library(event,flag);
  }
 else   if (toZone == Zone.BATTLEFIELD) {
    zoneChangeInfo=new ZoneChangeInfo.Battlefield(event,flag);
  }
 else {
    zoneChangeInfo=new ZoneChangeInfo(event);
  }
  return ZonesHandler.moveCard(zoneChangeInfo,game);
}

Fixed version (ground truth):
@Override public boolean moveToZone(Zone toZone,UUID sourceId,Game game,boolean flag,ArrayList<UUID> appliedEffects){
  Zone fromZone=game.getState().getZone(objectId);
  ZoneChangeEvent event=new ZoneChangeEvent(this.objectId,sourceId,ownerId,fromZone,toZone,appliedEffects);
  ZoneChangeInfo zoneChangeInfo;
  if (null != toZone) {
switch (toZone) {
case LIBRARY:
      zoneChangeInfo=new ZoneChangeInfo.Library(event,flag);
    break;
case BATTLEFIELD:
  zoneChangeInfo=new ZoneChangeInfo.Battlefield(event,flag);
break;
default :
zoneChangeInfo=new ZoneChangeInfo(event);
break;
}
return ZonesHandler.moveCard(zoneChangeInfo,game);
}
return false;
}