nus-yam/ex-repair huggingface dataset:
Program: 158622
Project: 158622
Buggy source:
@Override public Object getValueAt(int arg0,int arg1){
switch (arg1) {
case 0:
    return matches[arg0].getDeckType();
case 1:
  return matches[arg0].getPlayers();
case 2:
return matches[arg0].getGameType();
case 3:
return matches[arg0].getResult();
case 4:
if (matches[arg0].getStartTime() != null) {
return timeFormatter.format(matches[arg0].getStartTime());
}
 else {
return "String_Node_Str";
}
case 5:
if (matches[arg0].getEndTime() != null) {
return timeFormatter.format(matches[arg0].getEndTime());
}
 else {
return "String_Node_Str";
}
case 6:
if (matches[arg0].isTournament()) {
return "String_Node_Str";
}
 else {
if (matches[arg0].isReplayAvailable()) {
return "String_Node_Str";
}
 else {
return "String_Node_Str";
}
}
case 7:
return matches[arg0].getGames();
}
return "String_Node_Str";
}

Fixed version (ground truth):
@Override public Object getValueAt(int arg0,int arg1){
switch (arg1) {
case 0:
    return matches[arg0].getDeckType();
case 1:
  return matches[arg0].getPlayers();
case 2:
return matches[arg0].getGameType();
case 3:
return matches[arg0].getResult();
case 4:
if (matches[arg0].getStartTime() != null) {
return timeFormatter.format(matches[arg0].getStartTime());
}
 else {
return "String_Node_Str";
}
case 5:
if (matches[arg0].getEndTime() != null) {
return timeFormatter.format(matches[arg0].getEndTime());
}
 else {
return "String_Node_Str";
}
case 6:
if (matches[arg0].isTournament()) {
return "String_Node_Str";
}
 else if (matches[arg0].isReplayAvailable()) {
return "String_Node_Str";
}
 else {
return "String_Node_Str";
}
case 7:
return matches[arg0].getGames();
}
return "String_Node_Str";
}
Program: 158623
Project: 158623
Buggy source:
private void btnQuickStartActionPerformed(java.awt.event.ActionEvent evt){
  TableView table;
  try {
    File f=new File("String_Node_Str");
    if (!f.exists()) {
      JOptionPane.showMessageDialog(null,"String_Node_Str","String_Node_Str",JOptionPane.ERROR_MESSAGE);
      return;
    }
    MatchOptions options=new MatchOptions("String_Node_Str","String_Node_Str");
    options.getPlayerTypes().add("String_Node_Str");
    options.getPlayerTypes().add("String_Node_Str");
    options.setDeckType("String_Node_Str");
    options.setAttackOption(MultiplayerAttackOption.LEFT);
    options.setRange(RangeOfInfluence.ALL);
    options.setWinsNeeded(1);
    options.setMatchTimeLimit(MatchTimeLimit.NONE);
    options.setFreeMulligans(2);
    options.setSkillLevel(SkillLevel.CASUAL);
    options.setRollbackTurnsAllowed(true);
    table=session.createTable(roomId,options);
    session.joinTable(roomId,table.getTableId(),"String_Node_Str","String_Node_Str",1,DeckImporterUtil.importDeck("String_Node_Str"),"String_Node_Str");
    session.joinTable(roomId,table.getTableId(),"String_Node_Str","String_Node_Str",5,DeckImporterUtil.importDeck("String_Node_Str"),"String_Node_Str");
    session.startMatch(roomId,table.getTableId());
  }
 catch (  HeadlessException ex) {
    handleError(ex);
  }
}

Fixed version (ground truth):
private void btnQuickStartActionPerformed(java.awt.event.ActionEvent evt){
  TableView table;
  try {
    File f=new File("String_Node_Str");
    if (!f.exists()) {
      JOptionPane.showMessageDialog(null,"String_Node_Str","String_Node_Str",JOptionPane.ERROR_MESSAGE);
      return;
    }
    MatchOptions options=new MatchOptions("String_Node_Str","String_Node_Str");
    options.getPlayerTypes().add("String_Node_Str");
    options.getPlayerTypes().add("String_Node_Str");
    options.setDeckType("String_Node_Str");
    options.setAttackOption(MultiplayerAttackOption.LEFT);
    options.setRange(RangeOfInfluence.ALL);
    options.setWinsNeeded(1);
    options.setMatchTimeLimit(MatchTimeLimit.NONE);
    options.setFreeMulligans(2);
    options.setSkillLevel(SkillLevel.CASUAL);
    options.setRollbackTurnsAllowed(true);
    options.setQuitRatio(100);
    table=session.createTable(roomId,options);
    session.joinTable(roomId,table.getTableId(),"String_Node_Str","String_Node_Str",1,DeckImporterUtil.importDeck("String_Node_Str"),"String_Node_Str");
    session.joinTable(roomId,table.getTableId(),"String_Node_Str","String_Node_Str",5,DeckImporterUtil.importDeck("String_Node_Str"),"String_Node_Str");
    session.startMatch(roomId,table.getTableId());
  }
 catch (  HeadlessException ex) {
    handleError(ex);
  }
}
Program: 158624
Project: 158624
Buggy source:
public void handleException(Exception ex){
  if (ex != null) {
    logger.fatal("String_Node_Str" + (ex.getMessage() == null ? "String_Node_Str" : ex.getMessage()));
    if (ex.getCause() != null) {
      logger.debug("String_Node_Str" + (ex.getCause().getMessage() == null ? "String_Node_Str" : ex.getCause().getMessage()));
    }
    ex.printStackTrace();
  }
 else {
    logger.fatal("String_Node_Str");
  }
}

Fixed version (ground truth):
public void handleException(Exception ex){
  if (ex != null) {
    LOGGER.fatal("String_Node_Str" + (ex.getMessage() == null ? "String_Node_Str" : ex.getMessage()));
    if (ex.getCause() != null) {
      LOGGER.debug("String_Node_Str" + (ex.getCause().getMessage() == null ? "String_Node_Str" : ex.getCause().getMessage()));
    }
    ex.printStackTrace();
  }
 else {
    LOGGER.fatal("String_Node_Str");
  }
}
Program: 158625
Project: 158625
Buggy source:
public void updateUserHistory(){
  callExecutor.execute(new Runnable(){
    @Override public void run(){
      for (      String updatedUser : UserStatsRepository.instance.updateUserStats()) {
        User user=getUserByName(updatedUser);
        if (user != null) {
          user.resetUserStats();
        }
      }
    }
  }
);
}

Fixed version (ground truth):
public void updateUserHistory(){
  CALL_EXECUTOR.execute(new Runnable(){
    @Override public void run(){
      for (      String updatedUser : UserStatsRepository.instance.updateUserStats()) {
        User user=getUserByName(updatedUser);
        if (user != null) {
          user.resetUserStats();
        }
      }
    }
  }
);
}
Program: 158626
Project: 158626
Buggy source:
public void removeUser(final UUID userId,final DisconnectReason reason){
  if (userId != null) {
    final User user=users.get(userId);
    if (user != null) {
      callExecutor.execute(new Runnable(){
        @Override public void run(){
          try {
            logger.info("String_Node_Str" + user.getName() + "String_Node_Str"+ reason.toString()+ "String_Node_Str"+ userId);
            user.remove(reason);
            logger.debug("String_Node_Str" + user.getName());
          }
 catch (          Exception ex) {
            handleException(ex);
          }
 finally {
            users.remove(userId);
            usersByName.remove(user.getName());
          }
        }
      }
);
    }
 else {
      logger.warn("String_Node_Str" + userId + "String_Node_Str");
    }
  }
}

Fixed version (ground truth):
public void removeUser(final UUID userId,final DisconnectReason reason){
  if (userId != null) {
    final User user=users.get(userId);
    if (user != null) {
      CALL_EXECUTOR.execute(new Runnable(){
        @Override public void run(){
          try {
            LOGGER.info("String_Node_Str" + user.getName() + "String_Node_Str"+ reason.toString()+ "String_Node_Str"+ userId);
            user.remove(reason);
            LOGGER.debug("String_Node_Str" + user.getName());
          }
 catch (          Exception ex) {
            handleException(ex);
          }
 finally {
            users.remove(userId);
            usersByName.remove(user.getName());
          }
        }
      }
);
    }
 else {
      LOGGER.warn("String_Node_Str" + userId + "String_Node_Str");
    }
  }
}
Program: 158627
Project: 158627
Buggy source:
@Override public int calculate(Game game,Ability sourceAbility,Effect effect){
  int count=0;
  for (  UUID playerId : game.getPlayer(sourceAbility.getControllerId()).getInRange()) {
    Player player=game.getPlayer(playerId);
    if (player != null) {
      count+=player.getGraveyard().size();
    }
  }
  return count;
}

Fixed version (ground truth):
@Override public int calculate(Game game,Ability sourceAbility,Effect effect){
  int count=0;
  for (  UUID playerId : game.getState().getPlayersInRange(sourceAbility.getControllerId(),game)) {
    Player player=game.getPlayer(playerId);
    if (player != null) {
      count+=player.getGraveyard().size();
    }
  }
  return count;
}
Program: 158628
Project: 158628
Buggy source:
@Override public boolean apply(Game game,Ability source){
  for (  Permanent permanent : game.getBattlefield().getActivePermanents(filter,source.getControllerId(),source.getSourceId(),game)) {
    permanent.moveToZone(Zone.HAND,source.getSourceId(),game,true);
  }
  for (  UUID playerId : game.getPlayer(source.getControllerId()).getInRange()) {
    Player player=game.getPlayer(playerId);
    if (player != null) {
      for (      Card card : player.getGraveyard().getCards(filter2,game)) {
        card.moveToZone(Zone.HAND,source.getSourceId(),game,true);
      }
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  for (  Permanent permanent : game.getBattlefield().getActivePermanents(filter,source.getControllerId(),source.getSourceId(),game)) {
    permanent.moveToZone(Zone.HAND,source.getSourceId(),game,true);
  }
  for (  UUID playerId : game.getState().getPlayersInRange(source.getControllerId(),game)) {
    Player player=game.getPlayer(playerId);
    if (player != null) {
      for (      Card card : player.getGraveyard().getCards(filter2,game)) {
        card.moveToZone(Zone.HAND,source.getSourceId(),game,true);
      }
    }
  }
  return true;
}
Program: 158629
Project: 158629
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    for (    UUID playerId : controller.getInRange()) {
      Player player=game.getPlayer(playerId);
      if (player != null) {
        for (        Card card : player.getHand().getCards(game)) {
          card.moveToZone(Zone.LIBRARY,source.getSourceId(),game,true);
        }
        for (        Card card : player.getGraveyard().getCards(game)) {
          card.moveToZone(Zone.LIBRARY,source.getSourceId(),game,true);
        }
        player.shuffleLibrary(game);
      }
    }
    for (    Card card : controller.getLibrary().getTopCards(game,10)) {
      controller.moveCardToExileWithInfo(card,null,"String_Node_Str",source.getSourceId(),game,Zone.LIBRARY,true);
    }
    for (    UUID playerId : controller.getInRange()) {
      Player player=game.getPlayer(playerId);
      if (player != null) {
        int cardsToDrawCount=player.getAmount(0,7,"String_Node_Str",game);
        player.drawCards(cardsToDrawCount,game);
      }
    }
  }
  return true;
}

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)) {
      Player player=game.getPlayer(playerId);
      if (player != null) {
        for (        Card card : player.getHand().getCards(game)) {
          card.moveToZone(Zone.LIBRARY,source.getSourceId(),game,true);
        }
        for (        Card card : player.getGraveyard().getCards(game)) {
          card.moveToZone(Zone.LIBRARY,source.getSourceId(),game,true);
        }
        player.shuffleLibrary(game);
      }
    }
    for (    Card card : controller.getLibrary().getTopCards(game,10)) {
      controller.moveCardToExileWithInfo(card,null,"String_Node_Str",source.getSourceId(),game,Zone.LIBRARY,true);
    }
    for (    UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
      Player player=game.getPlayer(playerId);
      if (player != null) {
        int cardsToDrawCount=player.getAmount(0,7,"String_Node_Str",game);
        player.drawCards(cardsToDrawCount,game);
      }
    }
  }
  return true;
}
Program: 158630
Project: 158630
Buggy source:
@Override public boolean apply(Game game,Ability source){
  for (  UUID playerId : game.getPlayer(source.getControllerId()).getInRange()) {
    Player player=game.getPlayer(playerId);
    if (player != null) {
      player.gainLife(1,game);
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  for (  UUID playerId : game.getState().getPlayersInRange(source.getControllerId(),game)) {
    Player player=game.getPlayer(playerId);
    if (player != null) {
      player.gainLife(1,game);
    }
  }
  return true;
}
Program: 158632
Project: 158632
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player sourcePlayer=game.getPlayer(source.getControllerId());
  Permanent permanent=game.getPermanent(source.getSourceId());
  if (permanent != null) {
    int amount=permanent.getCounters().getCount(CounterType.CHARGE);
    if (amount > 0) {
      for (      UUID playerId : sourcePlayer.getInRange()) {
        Player player=game.getPlayer(playerId);
        if (player != null) {
          player.drawCards(amount,game);
        }
      }
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player sourcePlayer=game.getPlayer(source.getControllerId());
  Permanent permanent=game.getPermanent(source.getSourceId());
  if (permanent != null) {
    int amount=permanent.getCounters().getCount(CounterType.CHARGE);
    if (amount > 0) {
      for (      UUID playerId : game.getState().getPlayersInRange(sourcePlayer.getId(),game)) {
        Player player=game.getPlayer(playerId);
        if (player != null) {
          player.drawCards(amount,game);
        }
      }
    }
  }
  return true;
}
Program: 158634
Project: 158634
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    for (    UUID playerId : controller.getInRange()) {
      Player player=game.getPlayer(playerId);
      if (player != null) {
        int damage=player.getLife() / 2;
        player.damage(damage,source.getSourceId(),game,false,true);
      }
    }
    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)) {
      Player player=game.getPlayer(playerId);
      if (player != null) {
        int damage=player.getLife() / 2;
        player.damage(damage,source.getSourceId(),game,false,true);
      }
    }
    return true;
  }
  return false;
}
Program: 158635
Project: 158635
Buggy source:
@Override public boolean apply(Game game,Ability source){
  PreventDamageToTargetEffect effect=new PreventDamageToTargetEffect(Duration.EndOfTurn,1);
  List<Permanent> permanents=game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(),source.getControllerId(),game);
  for (  Permanent permanent : permanents) {
    effect.setTargetPointer(new FixedTarget(permanent.getId()));
    game.addEffect(effect,source);
  }
  for (  UUID playerId : game.getPlayer(source.getControllerId()).getInRange()) {
    Player player=game.getPlayer(playerId);
    if (player != null) {
      effect.setTargetPointer(new FixedTarget(player.getId()));
      game.addEffect(effect,source);
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  PreventDamageToTargetEffect effect=new PreventDamageToTargetEffect(Duration.EndOfTurn,1);
  List<Permanent> permanents=game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(),source.getControllerId(),game);
  for (  Permanent permanent : permanents) {
    effect.setTargetPointer(new FixedTarget(permanent.getId()));
    game.addEffect(effect,source);
  }
  for (  UUID playerId : game.getState().getPlayersInRange(source.getControllerId(),game)) {
    Player player=game.getPlayer(playerId);
    if (player != null) {
      effect.setTargetPointer(new FixedTarget(player.getId()));
      game.addEffect(effect,source);
    }
  }
  return false;
}
Program: 158636
Project: 158636
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    MageObject target=game.getObject(source.getSourceId());
    if (target != null) {
      HashSet<CardType> foundCardTypes=new HashSet<>();
      for (      UUID playerId : controller.getInRange()) {
        Player player=game.getPlayer(playerId);
        if (player != null) {
          for (          Card card : player.getGraveyard().getCards(game)) {
            foundCardTypes.addAll(card.getCardType());
          }
        }
      }
      int number=foundCardTypes.size();
      return number < 4;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    MageObject target=game.getObject(source.getSourceId());
    if (target != null) {
      HashSet<CardType> foundCardTypes=new HashSet<>();
      for (      UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
        Player player=game.getPlayer(playerId);
        if (player != null) {
          for (          Card card : player.getGraveyard().getCards(game)) {
            foundCardTypes.addAll(card.getCardType());
          }
        }
      }
      int number=foundCardTypes.size();
      return number < 4;
    }
  }
  return false;
}
Program: 158638
Project: 158638
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    Choice lifeChoice=new ChoiceImpl(true);
    Set<String> choices=new HashSet<String>();
    for (    UUID playerId : controller.getInRange()) {
      Player player=game.getPlayer(playerId);
      if (player != null) {
        choices.add(new StringBuilder(Integer.toString(player.getLife())).append("String_Node_Str").append(player.getLogName()).toString());
      }
    }
    lifeChoice.setChoices(choices);
    for (    UUID playersId : controller.getInRange()) {
      Player player=game.getPlayer(playersId);
      if (player != null) {
        String selectedChoice;
        if (choices.size() > 1) {
          lifeChoice.setMessage("String_Node_Str" + player.getLogName());
          controller.choose(Outcome.Detriment,lifeChoice,game);
          selectedChoice=lifeChoice.getChoice();
        }
 else {
          selectedChoice=choices.iterator().next();
        }
        int index=selectedChoice.indexOf("String_Node_Str");
        if (index > 0) {
          String lifeString=selectedChoice.substring(0,index);
          int life=Integer.parseInt(lifeString);
          player.setLife(life,game);
          choices.remove(selectedChoice);
          game.informPlayers(new StringBuilder("String_Node_Str").append(player.getLogName()).append("String_Node_Str").append(life).toString());
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    Choice lifeChoice=new ChoiceImpl(true);
    Set<String> choices=new HashSet<String>();
    for (    UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
      Player player=game.getPlayer(playerId);
      if (player != null) {
        choices.add(new StringBuilder(Integer.toString(player.getLife())).append("String_Node_Str").append(player.getLogName()).toString());
      }
    }
    lifeChoice.setChoices(choices);
    for (    UUID playersId : game.getState().getPlayersInRange(controller.getId(),game)) {
      Player player=game.getPlayer(playersId);
      if (player != null) {
        String selectedChoice;
        if (choices.size() > 1) {
          lifeChoice.setMessage("String_Node_Str" + player.getLogName());
          controller.choose(Outcome.Detriment,lifeChoice,game);
          selectedChoice=lifeChoice.getChoice();
        }
 else {
          selectedChoice=choices.iterator().next();
        }
        int index=selectedChoice.indexOf("String_Node_Str");
        if (index > 0) {
          String lifeString=selectedChoice.substring(0,index);
          int life=Integer.parseInt(lifeString);
          player.setLife(life,game);
          choices.remove(selectedChoice);
          game.informPlayers(new StringBuilder("String_Node_Str").append(player.getLogName()).append("String_Node_Str").append(life).toString());
        }
      }
    }
  }
  return false;
}
Program: 158639
Project: 158639
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    int xSum=0;
    xSum+=playerPaysXGenericMana(controller,source,game);
    for (    UUID playerId : controller.getInRange()) {
      if (playerId != controller.getId()) {
        Player player=game.getPlayer(playerId);
        if (player != null) {
          xSum+=playerPaysXGenericMana(player,source,game);
        }
      }
    }
    if (xSum > 0) {
      for (      UUID playerId : controller.getInRange()) {
        Effect effect=new CreateTokenTargetEffect(new SoldierToken(),xSum);
        effect.setTargetPointer(new FixedTarget(playerId));
        effect.apply(game,source);
      }
    }
    controller.resetStoredBookmark(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 xSum=0;
    xSum+=playerPaysXGenericMana(controller,source,game);
    for (    UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
      if (playerId != controller.getId()) {
        Player player=game.getPlayer(playerId);
        if (player != null) {
          xSum+=playerPaysXGenericMana(player,source,game);
        }
      }
    }
    if (xSum > 0) {
      for (      UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
        Effect effect=new CreateTokenTargetEffect(new SoldierToken(),xSum);
        effect.setTargetPointer(new FixedTarget(playerId));
        effect.apply(game,source);
      }
    }
    controller.resetStoredBookmark(game);
    return true;
  }
  return false;
}
Program: 158640
Project: 158640
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    int xSum=0;
    xSum+=playerPaysXGenericMana(controller,source,game);
    for (    UUID playerId : controller.getInRange()) {
      if (playerId != controller.getId()) {
        Player player=game.getPlayer(playerId);
        if (player != null) {
          xSum+=playerPaysXGenericMana(player,source,game);
        }
      }
    }
    for (    UUID playerId : controller.getInRange()) {
      Player player=game.getPlayer(playerId);
      if (player != null) {
        TargetCardInLibrary target=new TargetCardInLibrary(0,xSum,new FilterBasicLandCard());
        if (player.searchLibrary(target,game)) {
          for (          UUID cardId : target.getTargets()) {
            Card card=player.getLibrary().getCard(cardId,game);
            if (card != null) {
              card.putOntoBattlefield(game,Zone.LIBRARY,source.getSourceId(),player.getId(),true);
            }
          }
          player.shuffleLibrary(game);
        }
      }
    }
    controller.resetStoredBookmark(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 xSum=0;
    xSum+=playerPaysXGenericMana(controller,source,game);
    for (    UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
      if (playerId != controller.getId()) {
        Player player=game.getPlayer(playerId);
        if (player != null) {
          xSum+=playerPaysXGenericMana(player,source,game);
        }
      }
    }
    for (    UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
      Player player=game.getPlayer(playerId);
      if (player != null) {
        TargetCardInLibrary target=new TargetCardInLibrary(0,xSum,new FilterBasicLandCard());
        if (player.searchLibrary(target,game)) {
          for (          UUID cardId : target.getTargets()) {
            Card card=player.getLibrary().getCard(cardId,game);
            if (card != null) {
              card.putOntoBattlefield(game,Zone.LIBRARY,source.getSourceId(),player.getId(),true);
            }
          }
          player.shuffleLibrary(game);
        }
      }
    }
    controller.resetStoredBookmark(game);
    return true;
  }
  return false;
}
Program: 158641
Project: 158641
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    for (    UUID playerId : controller.getInRange()) {
      if (!playerId.equals(this.getTargetPointer().getFirst(game,source))) {
        Token token=new DragonToken2();
        token.putOntoBattlefield(1,game,source.getSourceId(),playerId);
      }
    }
    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)) {
      if (!playerId.equals(this.getTargetPointer().getFirst(game,source))) {
        Token token=new DragonToken2();
        token.putOntoBattlefield(1,game,source.getSourceId(),playerId);
      }
    }
    return true;
  }
  return false;
}
Program: 158642
Project: 158642
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    int xSum=0;
    xSum+=playerPaysXGenericMana(controller,source,game);
    for (    UUID playerId : controller.getInRange()) {
      if (playerId != controller.getId()) {
        Player player=game.getPlayer(playerId);
        if (player != null) {
          xSum+=playerPaysXGenericMana(player,source,game);
        }
      }
    }
    ContinuousEffect effect=new BoostSourceEffect(xSum,0,Duration.EndOfTurn);
    game.addEffect(effect,source);
    controller.resetStoredBookmark(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 xSum=0;
    xSum+=playerPaysXGenericMana(controller,source,game);
    for (    UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
      if (playerId != controller.getId()) {
        Player player=game.getPlayer(playerId);
        if (player != null) {
          xSum+=playerPaysXGenericMana(player,source,game);
        }
      }
    }
    ContinuousEffect effect=new BoostSourceEffect(xSum,0,Duration.EndOfTurn);
    game.addEffect(effect,source);
    controller.resetStoredBookmark(game);
    return true;
  }
  return false;
}
Program: 158643
Project: 158643
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    int xSum=0;
    xSum+=playerPaysXGenericMana(controller,source,game);
    for (    UUID playerId : controller.getInRange()) {
      if (playerId != controller.getId()) {
        Player player=game.getPlayer(playerId);
        if (player != null) {
          xSum+=playerPaysXGenericMana(player,source,game);
        }
      }
    }
    if (xSum > 0) {
      for (      UUID playerId : controller.getInRange()) {
        Player player=game.getPlayer(playerId);
        if (player != null) {
          player.drawCards(xSum,game);
        }
      }
    }
    controller.resetStoredBookmark(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 xSum=0;
    xSum+=playerPaysXGenericMana(controller,source,game);
    for (    UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
      if (playerId != controller.getId()) {
        Player player=game.getPlayer(playerId);
        if (player != null) {
          xSum+=playerPaysXGenericMana(player,source,game);
        }
      }
    }
    if (xSum > 0) {
      for (      UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
        Player player=game.getPlayer(playerId);
        if (player != null) {
          player.drawCards(xSum,game);
        }
      }
    }
    controller.resetStoredBookmark(game);
    return true;
  }
  return false;
}
Program: 158644
Project: 158644
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    int xSum=0;
    xSum+=playerPaysXGenericMana(controller,source,game);
    for (    UUID playerId : controller.getInRange()) {
      if (playerId != controller.getId()) {
        Player player=game.getPlayer(playerId);
        if (player != null) {
          xSum+=playerPaysXGenericMana(player,source,game);
        }
      }
    }
    if (xSum > 0) {
      for (      UUID playerId : controller.getInRange()) {
        Effect effect=new PutTopCardOfLibraryIntoGraveTargetEffect(xSum);
        effect.setTargetPointer(new FixedTarget(playerId));
        effect.apply(game,source);
      }
    }
    controller.resetStoredBookmark(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 xSum=0;
    xSum+=playerPaysXGenericMana(controller,source,game);
    for (    UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
      if (playerId != controller.getId()) {
        Player player=game.getPlayer(playerId);
        if (player != null) {
          xSum+=playerPaysXGenericMana(player,source,game);
        }
      }
    }
    if (xSum > 0) {
      for (      UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
        Effect effect=new PutTopCardOfLibraryIntoGraveTargetEffect(xSum);
        effect.setTargetPointer(new FixedTarget(playerId));
        effect.apply(game,source);
      }
    }
    controller.resetStoredBookmark(game);
    return true;
  }
  return false;
}
Program: 158645
Project: 158645
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    List<Player> usingPlayers=new ArrayList<>();
    this.chooseAndSearchLibrary(usingPlayers,controller,source,game);
    for (    UUID playerId : controller.getInRange()) {
      if (!playerId.equals(controller.getId())) {
        Player player=game.getPlayer(playerId);
        if (player != null) {
          this.chooseAndSearchLibrary(usingPlayers,player,source,game);
        }
      }
    }
    for (    Player player : usingPlayers) {
      player.shuffleLibrary(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) {
    List<Player> usingPlayers=new ArrayList<>();
    this.chooseAndSearchLibrary(usingPlayers,controller,source,game);
    for (    UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
      if (!playerId.equals(controller.getId())) {
        Player player=game.getPlayer(playerId);
        if (player != null) {
          this.chooseAndSearchLibrary(usingPlayers,player,source,game);
        }
      }
    }
    for (    Player player : usingPlayers) {
      player.shuffleLibrary(game);
    }
    return true;
  }
  return false;
}
Program: 158646
Project: 158646
Buggy source:
@Override public void init(Ability source,Game game){
  super.init(source,game);
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    for (    UUID playerId : controller.getInRange()) {
      FilterPermanent playerFilter=filter.copy();
      playerFilter.add(new OwnerIdPredicate(playerId));
      for (      Permanent permanent : game.getBattlefield().getActivePermanents(playerFilter,playerId,game)) {
        affectedObjectList.add(new MageObjectReference(permanent,game));
      }
    }
  }
}

Fixed version (ground truth):
@Override public void init(Ability source,Game game){
  super.init(source,game);
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    for (    UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
      FilterPermanent playerFilter=filter.copy();
      playerFilter.add(new OwnerIdPredicate(playerId));
      for (      Permanent permanent : game.getBattlefield().getActivePermanents(playerFilter,playerId,game)) {
        affectedObjectList.add(new MageObjectReference(permanent,game));
      }
    }
  }
}
Program: 158647
Project: 158647
Buggy source:
public String getUserHistory(String userName){
  User user=getUserByName(userName);
  if (user == null) {
    UserStats userStats=UserStatsRepository.instance.getUser(userName);
    if (userStats == null) {
      return "String_Node_Str" + userName + "String_Node_Str";
    }
    return User.userStatsToString(userStats.getProto());
  }
  return "String_Node_Str" + userName + "String_Node_Str"+ user.getUserData().getHistory();
}

Fixed version (ground truth):
public String getUserHistory(String userName){
  User user=getUserByName(userName);
  if (user == null) {
    UserStats userStats=UserStatsRepository.instance.getUser(userName);
    if (userStats == null) {
      return "String_Node_Str" + userName + "String_Node_Str";
    }
    return "String_Node_Str" + userName + "String_Node_Str"+ User.userStatsToMatchHistory(userStats.getProto())+ "String_Node_Str"+ User.userStatsToTourneyHistory(userStats.getProto());
  }
  return "String_Node_Str" + userName + "String_Node_Str"+ user.getUserData().getMatchHistory()+ "String_Node_Str"+ user.getUserData().getTourneyHistory();
}
Program: 158648
Project: 158648
Buggy source:
@Override public boolean applies(GameEvent event,Ability source,Game game){
  if (event.getSourceId().equals(source.getSourceId())) {
    return (turnPhase == null || !game.getPhase().getType().equals(turnPhase)) && (phaseStep == null || !game.getTurn().getStepType().equals(phaseStep)) && (condition == null || !condition.apply(game,source));
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(GameEvent event,Ability source,Game game){
  if (event.getSourceId().equals(source.getSourceId())) {
    if ((turnPhase != null && !game.getPhase().getType().equals(turnPhase)) || (phaseStep != null && !game.getTurn().getStepType().equals(phaseStep)) || (condition != null && !condition.apply(game,source))) {
      return true;
    }
  }
  return false;
}
Program: 158649
Project: 158649
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  Permanent permanent=game.getPermanent(targetPointer.getFirst(game,source));
  if (permanent != null && controller != null) {
    if (permanent.isAttacking()) {
      if (controller.chooseUse(Outcome.Neutral,"String_Node_Str" + permanent.getIdName() + "String_Node_Str",source,game)) {
        new PutOnLibraryTargetEffect(true).apply(game,source);
      }
    }
 else {
      new ReturnToHandTargetEffect(true).apply(game,source);
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  Permanent permanent=game.getPermanent(targetPointer.getFirst(game,source));
  if (permanent != null && controller != null) {
    if (permanent.isAttacking()) {
      if (controller.chooseUse(Outcome.Neutral,"String_Node_Str" + permanent.getIdName() + "String_Node_Str",source,game)) {
        new PutOnLibraryTargetEffect(true).apply(game,source);
      }
 else {
        new ReturnToHandTargetEffect(true).apply(game,source);
      }
    }
 else {
      new ReturnToHandTargetEffect(true).apply(game,source);
    }
    return true;
  }
  return false;
}
Program: 158650
Project: 158650
Buggy source:
public SeatView(Seat seat){
  if (seat.getPlayer() != null) {
    this.playerId=seat.getPlayer().getId();
    this.playerName=seat.getPlayer().getName();
    if (seat.getPlayer().getUserData() == null) {
      this.flagName=UserData.getDefaultFlagName();
      this.history="String_Node_Str";
    }
 else {
      this.flagName=seat.getPlayer().getUserData().getFlagName();
      this.history=seat.getPlayer().getUserData().getHistory();
    }
  }
 else {
    this.playerName="String_Node_Str";
    this.flagName="String_Node_Str";
    this.history="String_Node_Str";
  }
  this.playerType=seat.getPlayerType();
}

Fixed version (ground truth):
public SeatView(Seat seat){
  if (seat.getPlayer() != null) {
    this.playerId=seat.getPlayer().getId();
    this.playerName=seat.getPlayer().getName();
    if (seat.getPlayer().getUserData() == null) {
      this.flagName=UserData.getDefaultFlagName();
      this.history="String_Node_Str";
    }
 else {
      this.flagName=seat.getPlayer().getUserData().getFlagName();
      this.history=seat.getPlayer().getUserData().getMatchHistory() + "String_Node_Str" + seat.getPlayer().getUserData().getTourneyHistory();
    }
  }
 else {
    this.playerName="String_Node_Str";
    this.flagName="String_Node_Str";
    this.history="String_Node_Str";
  }
  this.playerType=seat.getPlayerType();
}
Program: 158651
Project: 158651
Buggy source:
@Override public boolean hasSourceObjectAbility(Game game,MageObject source,GameEvent event){
  MageObject object=source;
  if (object == null) {
    object=game.getPermanentEntering(getSourceId());
    if (object == null) {
      object=game.getObject(getSourceId());
    }
  }
  if (object != null && !object.getAbilities().contains(this)) {
    if (object instanceof Permanent) {
      return false;
    }
 else {
      Abilities<Ability> otherAbilities=game.getState().getAllOtherAbilities(this.getSourceId());
      if (otherAbilities == null || !otherAbilities.contains(this)) {
        return false;
      }
    }
  }
  if (object instanceof Permanent) {
    return ((Permanent)object).isPhasedIn();
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean hasSourceObjectAbility(Game game,MageObject source,GameEvent event){
  MageObject object=source;
  if (object == null) {
    object=game.getPermanentEntering(getSourceId());
    if (object == null) {
      object=game.getObject(getSourceId());
    }
  }
  if (object != null) {
    if (object instanceof Permanent) {
      if (!((Permanent)object).getAbilities(game).contains(this)) {
        return false;
      }
      return ((Permanent)object).isPhasedIn();
    }
 else     if (!object.getAbilities().contains(this)) {
      Abilities<Ability> otherAbilities=game.getState().getAllOtherAbilities(this.getSourceId());
      if (otherAbilities == null || !otherAbilities.contains(this)) {
        return false;
      }
    }
  }
  return true;
}
Program: 158652
Project: 158652
Buggy source:
@Override public void setSourceId(UUID sourceId){
  if (this.sourceId == null) {
    this.sourceId=sourceId;
  }
 else {
    if (!(this instanceof MageSingleton)) {
      this.sourceId=sourceId;
    }
  }
  if (subAbilities != null) {
    for (    Ability subAbility : subAbilities) {
      subAbility.setSourceId(sourceId);
    }
  }
  if (watchers != null) {
    for (    Watcher watcher : watchers) {
      watcher.setSourceId(sourceId);
    }
  }
}

Fixed version (ground truth):
@Override public void setSourceId(UUID sourceId){
  if (this.sourceId == null) {
    this.sourceId=sourceId;
  }
 else   if (!(this instanceof MageSingleton)) {
    this.sourceId=sourceId;
  }
  if (subAbilities != null) {
    for (    Ability subAbility : subAbilities) {
      subAbility.setSourceId(sourceId);
    }
  }
  if (watchers != null) {
    for (    Watcher watcher : watchers) {
      watcher.setSourceId(sourceId);
    }
  }
}
Program: 158654
Project: 158654
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  ZoneChangeEvent zEvent=(ZoneChangeEvent)event;
  Permanent permanent=zEvent.getTarget();
  if (permanent != null && zEvent.getToZone() == Zone.GRAVEYARD && zEvent.getFromZone() == Zone.BATTLEFIELD && permanent.getId().equals(this.getSourceId())) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getTargetId().equals(getSourceId())) {
    ZoneChangeEvent zEvent=(ZoneChangeEvent)event;
    Permanent permanent=zEvent.getTarget();
    if (permanent != null && zEvent.getToZone() == Zone.GRAVEYARD && zEvent.getFromZone() == Zone.BATTLEFIELD) {
      return true;
    }
  }
  return false;
}
Program: 158655
Project: 158655
Buggy source:
@Override public boolean apply(Game game,Ability source){
  return !game.getOpponents(source.getControllerId()).contains(game.getActivePlayerId());
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  return game.getOpponents(source.getControllerId()).contains(game.getActivePlayerId());
}
Program: 158656
Project: 158656
Buggy source:
public static Condition getInstance(){
  return fInstance;
}

Fixed version (ground truth):
public static Condition getInstance(){
  return F_INSTANCE;
}
Program: 158659
Project: 158659
Buggy source:
public boolean asThough(UUID objectId,AsThoughEffectType type,Ability affectedAbility,UUID controllerId,Game game){
  List<AsThoughEffect> asThoughEffectsList=getApplicableAsThoughEffects(type,game);
  for (  AsThoughEffect effect : asThoughEffectsList) {
    HashSet<Ability> abilities=asThoughEffectsMap.get(type).getAbility(effect.getId());
    for (    Ability ability : abilities) {
      if (affectedAbility == null) {
        if (effect.applies(objectId,ability,controllerId,game)) {
          return true;
        }
      }
 else {
        if (effect.applies(objectId,affectedAbility,ability,game)) {
          return true;
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
public boolean asThough(UUID objectId,AsThoughEffectType type,Ability affectedAbility,UUID controllerId,Game game){
  List<AsThoughEffect> asThoughEffectsList=getApplicableAsThoughEffects(type,game);
  for (  AsThoughEffect effect : asThoughEffectsList) {
    HashSet<Ability> abilities=asThoughEffectsMap.get(type).getAbility(effect.getId());
    for (    Ability ability : abilities) {
      if (affectedAbility == null) {
        if (effect.applies(objectId,ability,controllerId,game)) {
          return true;
        }
      }
 else       if (effect.applies(objectId,affectedAbility,ability,game)) {
        return true;
      }
    }
  }
  return false;
}
Program: 158660
Project: 158660
Buggy source:
private boolean checkAbilityStillExists(Ability ability,ContinuousEffect effect,GameEvent event,Game game){
switch (effect.getDuration()) {
case EndOfCombat:
case EndOfGame:
case EndOfStep:
case EndOfTurn:
case OneUse:
case Custom:
    return true;
}
if (ability.getSourceId() == null) {
  return true;
}
MageObject object;
if (event.getType().equals(EventType.ZONE_CHANGE) && ((ZoneChangeEvent)event).getFromZone().equals(Zone.BATTLEFIELD) && event.getTargetId().equals(ability.getSourceId())) {
  object=((ZoneChangeEvent)event).getTarget();
}
 else {
  object=game.getObject(ability.getSourceId());
}
if (object == null) {
  return false;
}
boolean exists=true;
if (!object.getAbilities().contains(ability)) {
  exists=false;
  if (object instanceof PermanentCard) {
    PermanentCard permanent=(PermanentCard)object;
    if (permanent.canTransform() && event.getType() == GameEvent.EventType.TRANSFORMED) {
      exists=permanent.getCard().getAbilities().contains(ability);
    }
  }
}
 else {
  if (object instanceof PermanentCard) {
    PermanentCard permanent=(PermanentCard)object;
    if (permanent.isFaceDown(game) && !ability.getWorksFaceDown()) {
      return false;
    }
  }
 else   if (object instanceof Spell) {
    Spell spell=(Spell)object;
    if (spell.isFaceDown(game) && !ability.getWorksFaceDown()) {
      return false;
    }
  }
}
return exists;
}

Fixed version (ground truth):
private boolean checkAbilityStillExists(Ability ability,ContinuousEffect effect,GameEvent event,Game game){
switch (effect.getDuration()) {
case EndOfCombat:
case EndOfGame:
case EndOfStep:
case EndOfTurn:
case OneUse:
case Custom:
    return true;
}
if (ability.getSourceId() == null) {
  return true;
}
MageObject object;
if (event.getType().equals(EventType.ZONE_CHANGE) && ((ZoneChangeEvent)event).getFromZone().equals(Zone.BATTLEFIELD) && event.getTargetId().equals(ability.getSourceId())) {
  object=((ZoneChangeEvent)event).getTarget();
}
 else {
  object=game.getObject(ability.getSourceId());
}
if (object == null) {
  return false;
}
boolean exists=true;
if (!object.getAbilities().contains(ability)) {
  exists=false;
  if (object instanceof PermanentCard) {
    PermanentCard permanent=(PermanentCard)object;
    if (permanent.canTransform() && event.getType() == GameEvent.EventType.TRANSFORMED) {
      exists=permanent.getCard().getAbilities().contains(ability);
    }
  }
}
 else if (object instanceof PermanentCard) {
  PermanentCard permanent=(PermanentCard)object;
  if (permanent.isFaceDown(game) && !ability.getWorksFaceDown()) {
    return false;
  }
}
 else if (object instanceof Spell) {
  Spell spell=(Spell)object;
  if (spell.isFaceDown(game) && !ability.getWorksFaceDown()) {
    return false;
  }
}
return exists;
}
Program: 158661
Project: 158661
Buggy source:
public Map<String,String> getReplacementEffectsTexts(HashMap<ReplacementEffect,HashSet<Ability>> rEffects,Game game){
  Map<String,String> texts=new LinkedHashMap<>();
  for (  Map.Entry<ReplacementEffect,HashSet<Ability>> entry : rEffects.entrySet()) {
    if (entry.getValue() != null) {
      for (      Ability ability : entry.getValue()) {
        MageObject object=game.getObject(ability.getSourceId());
        if (object != null) {
          texts.put(ability.getId().toString() + "String_Node_Str" + entry.getKey().getId().toString(),object.getName() + "String_Node_Str" + ability.getRule(object.getName()));
        }
 else {
          texts.put(ability.getId().toString() + "String_Node_Str" + entry.getKey().getId().toString(),entry.getKey().getText(null));
        }
      }
    }
 else {
      logger.error("String_Node_Str" + entry.getKey().toString());
    }
  }
  return texts;
}

Fixed version (ground truth):
public Map<String,String> getReplacementEffectsTexts(HashMap<ReplacementEffect,HashSet<Ability>> rEffects,Game game){
  Map<String,String> texts=new LinkedHashMap<>();
  for (  Map.Entry<ReplacementEffect,HashSet<Ability>> entry : rEffects.entrySet()) {
    if (entry.getValue() != null) {
      for (      Ability ability : entry.getValue()) {
        MageObject object=game.getObject(ability.getSourceId());
        if (object != null) {
          texts.put(ability.getId().toString() + "String_Node_Str" + entry.getKey().getId().toString(),object.getName() + "String_Node_Str" + ability.getRule(object.getName()));
        }
 else {
          texts.put(ability.getId().toString() + "String_Node_Str" + entry.getKey().getId().toString(),entry.getKey().getText(null));
        }
      }
    }
 else {
      LOGGER.error("String_Node_Str" + entry.getKey().toString());
    }
  }
  return texts;
}