nus-yam/ex-repair huggingface dataset:
Program: 158880
Project: 158880
Buggy source:
/** 
 * With a Soulfire Grand Master in play, Deflecting Palm doesn't gain the caster life.  It should as it has lifelink, and it's Deflecting Palm (an instant) dealing damage.  I was playing against a human in Standard Constructed.
 */
@Test public void testWithDeflectingPalm(){
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.HAND,playerA,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerB,"String_Node_Str",1);
  addCard(Zone.HAND,playerB,"String_Node_Str",1);
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerB,"String_Node_Str",playerA);
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str",null,"String_Node_Str");
  setChoice(playerA,"String_Node_Str");
  setStopAt(1,PhaseStep.BEGIN_COMBAT);
  execute();
  assertGraveyardCount(playerB,"String_Node_Str",1);
  assertGraveyardCount(playerA,"String_Node_Str",1);
  assertLife(playerB,17);
  assertLife(playerA,23);
}

Fixed version (ground truth):
/** 
 * With a Soulfire Grand Master in play, Deflecting Palm doesn't gain the caster life. It should as it has lifelink, and it's Deflecting Palm (an instant) dealing damage. I was playing against a human in Standard Constructed.
 */
@Test public void testWithDeflectingPalm(){
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.HAND,playerA,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerB,"String_Node_Str",1);
  addCard(Zone.HAND,playerB,"String_Node_Str",1);
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerB,"String_Node_Str",playerA);
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str",null,"String_Node_Str");
  setChoice(playerA,"String_Node_Str");
  setStopAt(1,PhaseStep.BEGIN_COMBAT);
  execute();
  assertGraveyardCount(playerB,"String_Node_Str",1);
  assertGraveyardCount(playerA,"String_Node_Str",1);
  assertLife(playerB,17);
  assertLife(playerA,23);
}
Program: 158881
Project: 158881
Buggy source:
/** 
 * Soulfire Grand Master Creature - Human Monk 2/2, 1W (2) Lifelink Instant and sorcery spells you control have lifelink. {2}{U/R}{U/R}: The next time you cast an instant or sorcery spell from  your hand this turn, put that card into your hand instead of into your  graveyard as it resolves.
 */
@Test public void testSpellsGainLifelink(){
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str");
  addCard(Zone.HAND,playerA,"String_Node_Str");
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str",playerB);
  setStopAt(1,PhaseStep.BEGIN_COMBAT);
  execute();
  assertGraveyardCount(playerA,"String_Node_Str",1);
  assertHandCount(playerA,"String_Node_Str",0);
  assertLife(playerB,17);
  assertLife(playerA,23);
}

Fixed version (ground truth):
/** 
 * Soulfire Grand Master Creature - Human Monk 2/2, 1W (2) Lifelink Instant and sorcery spells you control have lifelink. {2}{U/R}{U/R}: The next time you cast an instant or sorcery spell from your hand this turn, put that card into your hand instead of into your graveyard as it resolves.
 */
@Test public void testSpellsGainLifelink(){
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str");
  addCard(Zone.HAND,playerA,"String_Node_Str");
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str",playerB);
  setStopAt(1,PhaseStep.BEGIN_COMBAT);
  execute();
  assertGraveyardCount(playerA,"String_Node_Str",1);
  assertHandCount(playerA,"String_Node_Str",0);
  assertLife(playerB,17);
  assertLife(playerA,23);
}
Program: 158882
Project: 158882
Buggy source:
/** 
 * Test that if Soulfire Grand Master has left the battlefield  spell has no longer lifelink 
 */
@Test public void testSoulfireLeft(){
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.HAND,playerA,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.HAND,playerB,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerB,"String_Node_Str",1);
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str",playerB);
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerB,"String_Node_Str","String_Node_Str");
  setStopAt(1,PhaseStep.BEGIN_COMBAT);
  execute();
  assertGraveyardCount(playerA,"String_Node_Str",1);
  assertGraveyardCount(playerB,"String_Node_Str",1);
  assertGraveyardCount(playerA,"String_Node_Str",1);
  assertLife(playerB,17);
  assertLife(playerA,20);
}

Fixed version (ground truth):
/** 
 * Test that if Soulfire Grand Master has left the battlefield spell has no longer lifelink
 */
@Test public void testSoulfireLeft(){
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.HAND,playerA,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.HAND,playerB,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerB,"String_Node_Str",1);
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str",playerB);
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerB,"String_Node_Str","String_Node_Str");
  setStopAt(1,PhaseStep.BEGIN_COMBAT);
  execute();
  assertGraveyardCount(playerA,"String_Node_Str",1);
  assertGraveyardCount(playerB,"String_Node_Str",1);
  assertGraveyardCount(playerA,"String_Node_Str",1);
  assertLife(playerB,17);
  assertLife(playerA,20);
}
Program: 158883
Project: 158883
Buggy source:
/** 
 * Check if second ability resolved, the next spell that is counterer  won't go to hand back because it did not resolve
 */
@Test public void testSoulfireCounteredSpellDontGoesBack(){
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",8);
  addCard(Zone.HAND,playerA,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerB,"String_Node_Str",2);
  addCard(Zone.HAND,playerB,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerB,"String_Node_Str",1);
  activateAbility(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str");
  castSpell(1,PhaseStep.POSTCOMBAT_MAIN,playerA,"String_Node_Str","String_Node_Str");
  castSpell(1,PhaseStep.POSTCOMBAT_MAIN,playerB,"String_Node_Str","String_Node_Str");
  setStopAt(1,PhaseStep.END_TURN);
  execute();
  assertGraveyardCount(playerB,"String_Node_Str",1);
  assertGraveyardCount(playerA,"String_Node_Str",1);
  assertLife(playerB,20);
  assertLife(playerA,20);
}

Fixed version (ground truth):
/** 
 * Check if second ability resolved, the next spell that is counterer won't go to hand back because it did not resolve
 */
@Test public void testSoulfireCounteredSpellDontGoesBack(){
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",8);
  addCard(Zone.HAND,playerA,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerB,"String_Node_Str",2);
  addCard(Zone.HAND,playerB,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerB,"String_Node_Str",1);
  activateAbility(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str");
  castSpell(1,PhaseStep.POSTCOMBAT_MAIN,playerA,"String_Node_Str","String_Node_Str");
  castSpell(1,PhaseStep.POSTCOMBAT_MAIN,playerB,"String_Node_Str","String_Node_Str");
  setStopAt(1,PhaseStep.END_TURN);
  execute();
  assertGraveyardCount(playerB,"String_Node_Str",1);
  assertGraveyardCount(playerA,"String_Node_Str",1);
  assertLife(playerB,20);
  assertLife(playerA,20);
}
Program: 158885
Project: 158885
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller == null) {
    return false;
  }
  StackObject spell=null;
  for (  StackObject object : game.getStack()) {
    if (object instanceof Spell && object.getSourceId().equals(source.getSourceId())) {
      spell=object;
    }
  }
  if (spell != null) {
    boolean destroyCreatures=true;
    for (    UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
      Player player=game.getPlayer(uuid);
      if (player != null && player.chooseUse(Outcome.Detriment,"String_Node_Str" + spell.getLogName() + "String_Node_Str",game)) {
        destroyCreatures=false;
        player.damage(6,source.getSourceId(),game,false,true);
        game.informPlayers(player.getLogName() + "String_Node_Str" + spell.getName()+ "String_Node_Str");
      }
    }
    if (destroyCreatures) {
      for (      Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent("String_Node_Str"),source.getControllerId(),source.getSourceId(),game)) {
        permanent.destroy(source.getSourceId(),game,true);
      }
    }
    return destroyCreatures;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller == null) {
    return false;
  }
  StackObject spell=null;
  for (  StackObject object : game.getStack()) {
    if (object instanceof Spell && object.getSourceId().equals(source.getSourceId())) {
      spell=object;
    }
  }
  if (spell != null) {
    boolean destroyCreatures=true;
    for (    UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
      Player player=game.getPlayer(playerId);
      if (player != null && player.chooseUse(Outcome.Detriment,"String_Node_Str" + spell.getLogName() + "String_Node_Str",game)) {
        destroyCreatures=false;
        player.damage(6,source.getSourceId(),game,false,true);
        game.informPlayers(player.getLogName() + "String_Node_Str" + spell.getName()+ "String_Node_Str");
      }
    }
    if (destroyCreatures) {
      for (      Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent("String_Node_Str"),source.getControllerId(),source.getSourceId(),game)) {
        permanent.destroy(source.getSourceId(),game,true);
      }
    }
    return destroyCreatures;
  }
  return false;
}
Program: 158886
Project: 158886
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller == null) {
    return false;
  }
  StackObject spell=null;
  for (  StackObject object : game.getStack()) {
    if (object instanceof Spell && object.getSourceId().equals(source.getSourceId())) {
      spell=object;
    }
  }
  if (spell != null) {
    boolean destroyCreatures=true;
    for (    UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
      Player player=game.getPlayer(playerId);
      if (player != null && player.chooseUse(Outcome.Detriment,"String_Node_Str" + spell.getLogName() + "String_Node_Str",game)) {
        destroyCreatures=false;
        player.damage(6,source.getSourceId(),game,false,true);
        game.informPlayers(player.getLogName() + "String_Node_Str" + spell.getName()+ "String_Node_Str");
      }
    }
    if (destroyCreatures) {
      for (      Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent("String_Node_Str"),source.getControllerId(),source.getSourceId(),game)) {
        permanent.destroy(source.getSourceId(),game,true);
      }
    }
    return destroyCreatures;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller == null) {
    return false;
  }
  StackObject spell=null;
  for (  StackObject object : game.getStack()) {
    if (object instanceof Spell && object.getSourceId().equals(source.getSourceId())) {
      spell=object;
    }
  }
  if (spell != null) {
    boolean destroyCreatures=true;
    for (    UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
      Player player=game.getPlayer(uuid);
      if (player != null && player.chooseUse(Outcome.Detriment,"String_Node_Str" + spell.getLogName() + "String_Node_Str",game)) {
        destroyCreatures=false;
        player.damage(6,source.getSourceId(),game,false,true);
        game.informPlayers(player.getLogName() + "String_Node_Str" + spell.getName()+ "String_Node_Str");
      }
    }
    if (destroyCreatures) {
      for (      Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent("String_Node_Str"),source.getControllerId(),source.getSourceId(),game)) {
        permanent.destroy(source.getSourceId(),game,true);
      }
    }
    return destroyCreatures;
  }
  return false;
}
Program: 158887
Project: 158887
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller == null) {
    return false;
  }
  StackObject spell=null;
  for (  StackObject object : game.getStack()) {
    if (object instanceof Spell && object.getSourceId().equals(source.getSourceId())) {
      spell=object;
    }
  }
  if (spell != null) {
    boolean destroyCreatures=true;
    for (    UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
      Player player=game.getPlayer(uuid);
      if (player != null && player.chooseUse(Outcome.Detriment,"String_Node_Str" + spell.getLogName() + "String_Node_Str",game)) {
        destroyCreatures=false;
        player.damage(6,source.getSourceId(),game,false,true);
        game.informPlayers(player.getLogName() + "String_Node_Str" + spell.getName()+ "String_Node_Str");
      }
    }
    if (destroyCreatures) {
      for (      Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent("String_Node_Str"),source.getControllerId(),source.getSourceId(),game)) {
        permanent.destroy(source.getSourceId(),game,true);
      }
    }
    return destroyCreatures;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller == null) {
    return false;
  }
  StackObject spell=null;
  for (  StackObject object : game.getStack()) {
    if (object instanceof Spell && object.getSourceId().equals(source.getSourceId())) {
      spell=object;
    }
  }
  if (spell != null) {
    boolean destroyCreatures=true;
    for (    UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
      Player player=game.getPlayer(playerId);
      if (player != null && player.chooseUse(Outcome.Detriment,"String_Node_Str" + spell.getLogName() + "String_Node_Str",game)) {
        destroyCreatures=false;
        player.damage(6,source.getSourceId(),game,false,true);
        game.informPlayers(player.getLogName() + "String_Node_Str" + spell.getName()+ "String_Node_Str");
      }
    }
    if (destroyCreatures) {
      for (      Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent("String_Node_Str"),source.getControllerId(),source.getSourceId(),game)) {
        permanent.destroy(source.getSourceId(),game,true);
      }
    }
    return destroyCreatures;
  }
  return false;
}
Program: 158888
Project: 158888
Buggy source:
@Override public boolean destroy(UUID sourceId,Game game,boolean noRegen){
  if (abilities.containsKey(IndestructibleAbility.getInstance().getId())) {
    return false;
  }
  if (!game.replaceEvent(GameEvent.getEvent(EventType.DESTROY_PERMANENT,objectId,sourceId,controllerId,noRegen ? 1 : 0))) {
    if (moveToZone(Zone.GRAVEYARD,sourceId,game,false)) {
      if (!game.isSimulation()) {
        String logName;
        Card card=game.getCard(this.getId());
        if (card != null) {
          logName=card.getLogName();
        }
 else {
          logName=this.getLogName();
        }
        if (this.getCardType().contains(CardType.CREATURE)) {
          game.informPlayers(logName + "String_Node_Str");
        }
 else {
          game.informPlayers(logName + "String_Node_Str");
        }
      }
      game.fireEvent(GameEvent.getEvent(EventType.DESTROYED_PERMANENT,objectId,sourceId,controllerId));
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean destroy(UUID sourceId,Game game,boolean noRegen){
  if (abilities.containsKey(IndestructibleAbility.getInstance().getId())) {
    return false;
  }
  if (!game.replaceEvent(GameEvent.getEvent(EventType.DESTROY_PERMANENT,objectId,sourceId,controllerId,noRegen ? 1 : 0))) {
    if (moveToZone(Zone.GRAVEYARD,sourceId,game,false)) {
      if (!game.isSimulation()) {
        String logName;
        Card card=game.getCard(this.getId());
        if (card != null) {
          logName=card.getLogName();
        }
 else {
          logName=this.getLogName();
        }
        if (this.getCardType().contains(CardType.CREATURE)) {
          game.informPlayers(logName + "String_Node_Str");
        }
 else {
          game.informPlayers(logName + "String_Node_Str");
        }
      }
      game.fireEvent(GameEvent.getEvent(EventType.DESTROYED_PERMANENT,objectId,sourceId,controllerId));
    }
    return true;
  }
  return false;
}
Program: 158890
Project: 158890
Buggy source:
@Override public boolean phaseOut(Game game){
  if (phasedIn) {
    if (!replaceEvent(EventType.PHASE_OUT,game)) {
      this.phasedIn=false;
      if (!game.isSimulation())       game.informPlayers(getLogName() + "String_Node_Str");
      fireEvent(EventType.PHASED_OUT,game);
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean phaseOut(Game game){
  if (phasedIn) {
    if (!replaceEvent(EventType.PHASE_OUT,game)) {
      this.phasedIn=false;
      if (!game.isSimulation()) {
        game.informPlayers(getLogName() + "String_Node_Str");
      }
      fireEvent(EventType.PHASED_OUT,game);
      return true;
    }
  }
  return false;
}
Program: 158892
Project: 158892
Buggy source:
protected Card pickTarget(List<Card> cards,Outcome outcome,Target target,Ability source,Game game){
  Card card;
  while (!cards.isEmpty()) {
    if (outcome.isGood()) {
      card=pickBestCard(cards,null,target,source,game);
    }
 else {
      card=pickWorstCard(cards,null,target,source,game);
    }
    if (source != null) {
      if (target.canTarget(this.getId(),card.getId(),source,game)) {
        return card;
      }
    }
 else {
      return card;
    }
    cards.remove(card);
  }
  return null;
}

Fixed version (ground truth):
protected Card pickTarget(List<Card> cards,Outcome outcome,Target target,Ability source,Game game){
  Card card;
  while (!cards.isEmpty()) {
    if (outcome.isGood()) {
      card=pickBestCard(cards,null,target,source,game);
    }
 else {
      card=pickWorstCard(cards,null,target,source,game);
    }
    if (source != null) {
      if (target.canTarget(getId(),card.getId(),source,game)) {
        return card;
      }
    }
 else {
      return card;
    }
    cards.remove(card);
  }
  return null;
}
Program: 158893
Project: 158893
Buggy source:
public Card pickBestCard(List<Card> cards,List<ColoredManaSymbol> chosenColors,Target target,Ability source,Game game){
  if (cards.isEmpty()) {
    return null;
  }
  Card bestCard=null;
  int maxScore=0;
  for (  Card card : cards) {
    int score=RateCard.rateCard(card,chosenColors);
    boolean betterCard=false;
    if (bestCard == null) {
      betterCard=true;
    }
 else     if (score > maxScore) {
      if (target != null && source != null && game != null) {
        betterCard=target.canTarget(card.getId(),source,game);
      }
 else {
        betterCard=true;
      }
    }
    if (betterCard) {
      maxScore=score;
      bestCard=card;
    }
  }
  return bestCard;
}

Fixed version (ground truth):
public Card pickBestCard(List<Card> cards,List<ColoredManaSymbol> chosenColors,Target target,Ability source,Game game){
  if (cards.isEmpty()) {
    return null;
  }
  Card bestCard=null;
  int maxScore=0;
  for (  Card card : cards) {
    int score=RateCard.rateCard(card,chosenColors);
    boolean betterCard=false;
    if (bestCard == null) {
      betterCard=true;
    }
 else     if (score > maxScore) {
      if (target != null && source != null && game != null) {
        betterCard=target.canTarget(getId(),card.getId(),source,game);
      }
 else {
        betterCard=true;
      }
    }
    if (betterCard) {
      maxScore=score;
      bestCard=card;
    }
  }
  return bestCard;
}
Program: 158894
Project: 158894
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller == null) {
    return false;
  }
  List<Card> cardsToPutIntoPlay=new ArrayList<>();
  TargetCardInHand target=new TargetCardInHand(filter);
  PlayerList playerList=game.getPlayerList().copy();
  playerList.setCurrent(game.getActivePlayerId());
  Player player=game.getPlayer(game.getActivePlayerId());
  do {
    if (player.chooseUse(outcome,"String_Node_Str",game)) {
      target.clearChosen();
      if (player.chooseTarget(outcome,target,source,game)) {
        Card card=game.getCard(target.getFirstTarget());
        if (card != null) {
          cardsToPutIntoPlay.add(card);
        }
      }
    }
    player=playerList.getNextInRange(controller,game);
  }
 while (!player.getId().equals(game.getActivePlayerId()));
  for (  Card card : cardsToPutIntoPlay) {
    player=game.getPlayer(card.getOwnerId());
    if (player != null) {
      player.putOntoBattlefieldWithInfo(card,game,Zone.HAND,source.getSourceId());
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller == null) {
    return false;
  }
  List<Card> cardsToPutIntoPlay=new ArrayList<>();
  TargetCardInHand target=new TargetCardInHand(filter);
  for (  UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
    Player player=game.getPlayer(playerId);
    if (player != null) {
      if (player.chooseUse(outcome,"String_Node_Str",game)) {
        target.clearChosen();
        if (player.chooseTarget(outcome,target,source,game)) {
          Card card=game.getCard(target.getFirstTarget());
          if (card != null) {
            cardsToPutIntoPlay.add(card);
          }
        }
      }
    }
  }
  for (  Card card : cardsToPutIntoPlay) {
    Player player=game.getPlayer(card.getOwnerId());
    if (player != null) {
      player.putOntoBattlefieldWithInfo(card,game,Zone.HAND,source.getSourceId());
    }
  }
  return true;
}
Program: 158896
Project: 158896
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);
    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);
    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: 158897
Project: 158897
Buggy source:
private ImageIcon getCountryFlagIcon(String countryCode){
  ImageIcon flagIcon=flagIconCache.get(countryCode);
  if (flagIcon == null) {
    flagIcon=new javax.swing.ImageIcon(getClass().getResource("String_Node_Str" + countryCode + "String_Node_Str"));
    if (flagIcon.getImage() == null) {
      logger.warn("String_Node_Str" + countryCode);
    }
 else {
      flagIconCache.put(countryCode,flagIcon);
    }
  }
  return flagIcon;
}

Fixed version (ground truth):
private ImageIcon getCountryFlagIcon(String countryCode){
  ImageIcon flagIcon=flagIconCache.get(countryCode);
  if (flagIcon == null) {
    flagIcon=new javax.swing.ImageIcon(getClass().getResource("String_Node_Str" + countryCode + (countryCode.endsWith("String_Node_Str") ? "String_Node_Str" : "String_Node_Str")));
    if (flagIcon.getImage() == null) {
      logger.warn("String_Node_Str" + countryCode);
    }
 else {
      flagIconCache.put(countryCode,flagIcon);
    }
  }
  return flagIcon;
}
Program: 158898
Project: 158898
Buggy source:
@Override public boolean isAvailable(Game game,Ability source){
  RefractionTrapWatcher watcher=(RefractionTrapWatcher)game.getState().getWatchers().get("String_Node_Str");
  if (watcher != null && watcher.conditionMet()) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean isAvailable(Game game,Ability source){
  RefractionTrapWatcher watcher=(RefractionTrapWatcher)game.getState().getWatchers().get("String_Node_Str");
  return watcher != null && watcher.conditionMetForAnOpponent(source.getControllerId(),game);
}
Program: 158899
Project: 158899
Buggy source:
@Override public boolean applies(GameEvent event,Ability source,Game game){
  if (!this.used && super.applies(event,source,game)) {
    MageObject object=game.getObject(event.getSourceId());
    if (object == null) {
      game.informPlayers("String_Node_Str");
      return false;
    }
    if (!object.getId().equals(source.getFirstTarget())) {
      return false;
    }
    Permanent permanent=game.getPermanent(event.getTargetId());
    if (permanent != null) {
      if (permanent.getControllerId().equals(source.getControllerId())) {
        return true;
      }
    }
    Player player=game.getPlayer(event.getTargetId());
    if (player != null) {
      if (player.getId().equals(source.getControllerId())) {
        return true;
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(GameEvent event,Ability source,Game game){
  if (!this.used && super.applies(event,source,game)) {
    MageObject object=game.getObject(event.getSourceId());
    if (object == null) {
      game.informPlayers("String_Node_Str");
      return false;
    }
    if (!object.getId().equals(target.getFirstTarget()) && !((object instanceof StackObject) && ((StackObject)object).getSourceId().equals(target.getFirstTarget()))) {
      return false;
    }
    Permanent permanent=game.getPermanent(event.getTargetId());
    if (permanent != null) {
      if (permanent.getControllerId().equals(source.getControllerId())) {
        return true;
      }
    }
    Player player=game.getPlayer(event.getTargetId());
    if (player != null) {
      if (player.getId().equals(source.getControllerId())) {
        return true;
      }
    }
  }
  return false;
}
Program: 158900
Project: 158900
Buggy source:
@Override public void watch(GameEvent event,Game game){
  if (condition == true) {
    return;
  }
  if (event.getType() == GameEvent.EventType.SPELL_CAST && game.getOpponents(controllerId).contains(event.getPlayerId())) {
    Spell spell=game.getStack().getSpell(event.getTargetId());
    if (spell.getColor(game).isRed()) {
      if (spell.getCardType().contains(CardType.INSTANT) || spell.getCardType().contains(CardType.SORCERY)) {
        condition=true;
      }
    }
  }
}

Fixed version (ground truth):
@Override public void watch(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.SPELL_CAST) {
    Spell spell=game.getStack().getSpell(event.getTargetId());
    if (spell.getColor(game).isRed()) {
      if (spell.getCardType().contains(CardType.INSTANT) || spell.getCardType().contains(CardType.SORCERY)) {
        playersMetCondition.add(event.getPlayerId());
      }
    }
  }
}
Program: 158901
Project: 158901
Buggy source:
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  GameEvent preventEvent=new GameEvent(GameEvent.EventType.PREVENT_DAMAGE,source.getFirstTarget(),source.getSourceId(),source.getControllerId(),event.getAmount(),false);
  if (!game.replaceEvent(preventEvent)) {
    int prevented=0;
    if (event.getAmount() >= this.amount) {
      int damage=amount;
      event.setAmount(event.getAmount() - amount);
      this.used=true;
      game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE,source.getFirstTarget(),source.getSourceId(),source.getControllerId(),damage));
      prevented=damage;
    }
 else {
      int damage=event.getAmount();
      event.setAmount(0);
      amount-=damage;
      game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE,source.getFirstTarget(),source.getSourceId(),source.getControllerId(),damage));
      prevented=damage;
    }
    if (prevented > 0) {
      UUID damageTarget=source.getTargets().get(1).getFirstTarget();
      Permanent target=game.getPermanent(damageTarget);
      if (target != null) {
        game.informPlayers("String_Node_Str" + prevented + "String_Node_Str"+ target.getName());
        target.damage(prevented,source.getSourceId(),game,false,true);
      }
      Player player=game.getPlayer(damageTarget);
      if (player != null) {
        game.informPlayers("String_Node_Str" + prevented + "String_Node_Str"+ player.getLogName());
        player.damage(prevented,source.getSourceId(),game,true,false);
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  PreventionEffectData preventionData=preventDamageAction(event,source,game);
  this.used=true;
  this.discard();
  if (preventionData.getPreventedDamage() > 0) {
    UUID damageTarget=getTargetPointer().getFirst(game,source);
    Permanent permanent=game.getPermanent(damageTarget);
    if (permanent != null) {
      game.informPlayers("String_Node_Str" + preventionData.getPreventedDamage() + "String_Node_Str"+ permanent.getLogName());
      permanent.damage(preventionData.getPreventedDamage(),source.getSourceId(),game,false,true);
    }
    Player player=game.getPlayer(damageTarget);
    if (player != null) {
      game.informPlayers("String_Node_Str" + preventionData.getPreventedDamage() + "String_Node_Str"+ player.getLogName());
      player.damage(preventionData.getPreventedDamage(),source.getSourceId(),game,true,false);
    }
  }
  return false;
}
Program: 158902
Project: 158902
Buggy source:
@Override public void reset(){
  super.reset();
  condition=false;
}

Fixed version (ground truth):
@Override public void reset(){
  playersMetCondition.clear();
  super.reset();
}
Program: 158903
Project: 158903
Buggy source:
public RefractionTrapPreventDamageEffect(final RefractionTrapPreventDamageEffect effect){
  super(effect);
  this.amount=effect.amount;
}

Fixed version (ground truth):
public RefractionTrapPreventDamageEffect(final RefractionTrapPreventDamageEffect effect){
  super(effect);
  this.amount=effect.amount;
  this.target=effect.target.copy();
}
Program: 158904
Project: 158904
Buggy source:
public RefractionTrapWatcher(final RefractionTrapWatcher watcher){
  super(watcher);
}

Fixed version (ground truth):
public RefractionTrapWatcher(final RefractionTrapWatcher watcher){
  super(watcher);
  this.playersMetCondition.addAll(watcher.playersMetCondition);
}
Program: 158905
Project: 158905
Buggy source:
@Override public boolean apply(MageObject input,Game game){
  Abilities<Ability> abilities=input.getAbilities();
  for (int i=0; i < abilities.size(); i++) {
    if (abilityClass.equals(abilities.get(i).getClass())) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(MageObject input,Game game){
  Abilities<Ability> abilities;
  if (input instanceof Card) {
    abilities=((Card)input).getAbilities(game);
  }
 else {
    abilities=input.getAbilities();
  }
  for (  Ability ability : abilities) {
    if (abilityClass.equals(ability.getClass())) {
      return true;
    }
  }
  return false;
}
Program: 158907
Project: 158907
Buggy source:
boolean removeAttachment(UUID permanentId,Game game);

Fixed version (ground truth):
boolean removeAttachment(Permanent permanent,Game game);
Program: 158908
Project: 158908
Buggy source:
@Override public boolean removeAttachment(UUID permanentId,Game game){
  if (this.attachments.contains(permanentId)) {
    Permanent aura=game.getPermanent(permanentId);
    if (aura != null) {
      if (!game.replaceEvent(new GameEvent(GameEvent.EventType.UNATTACH,playerId,permanentId,aura.getControllerId()))) {
        this.attachments.remove(permanentId);
        aura.attachTo(null,game);
      }
      game.fireEvent(new GameEvent(GameEvent.EventType.UNATTACHED,playerId,permanentId,aura.getControllerId()));
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean removeAttachment(Permanent attachment,Game game){
  if (this.attachments.contains(attachment.getId())) {
    if (!game.replaceEvent(new GameEvent(GameEvent.EventType.UNATTACH,playerId,attachment.getId(),attachment.getControllerId()))) {
      this.attachments.remove(attachment.getId());
      attachment.attachTo(null,game);
      game.fireEvent(new GameEvent(GameEvent.EventType.UNATTACHED,playerId,attachment.getId(),attachment.getControllerId()));
      return true;
    }
  }
  return false;
}
Program: 158909
Project: 158909
Buggy source:
@Override public boolean removeFromBattlefield(Permanent permanent,Game game){
  permanent.removeFromCombat(game,false);
  if (permanent.getAttachedTo() != null) {
    Permanent attachedTo=game.getPermanent(permanent.getAttachedTo());
    if (attachedTo != null) {
      attachedTo.removeAttachment(permanent.getId(),game);
    }
 else {
      Player attachedToPlayer=game.getPlayer(permanent.getAttachedTo());
      if (attachedToPlayer != null) {
        attachedToPlayer.removeAttachment(permanent.getId(),game);
      }
    }
  }
  if (permanent.getPairedCard() != null) {
    Permanent pairedCard=game.getPermanent(permanent.getPairedCard());
    if (pairedCard != null) {
      pairedCard.clearPairedCard();
    }
  }
  game.getBattlefield().removePermanent(permanent.getId());
  return true;
}

Fixed version (ground truth):
@Override public boolean removeFromBattlefield(Permanent permanent,Game game){
  permanent.removeFromCombat(game,false);
  game.getBattlefield().removePermanent(permanent.getId());
  if (permanent.getAttachedTo() != null) {
    Permanent attachedTo=game.getPermanent(permanent.getAttachedTo());
    if (attachedTo != null) {
      attachedTo.removeAttachment(permanent.getId(),game);
    }
 else {
      Player attachedToPlayer=game.getPlayer(permanent.getAttachedTo());
      if (attachedToPlayer != null) {
        attachedToPlayer.removeAttachment(permanent,game);
      }
    }
  }
  if (permanent.getPairedCard() != null) {
    Permanent pairedCard=game.getPermanent(permanent.getPairedCard());
    if (pairedCard != null) {
      pairedCard.clearPairedCard();
    }
  }
  return true;
}
Program: 158910
Project: 158910
Buggy source:
@Override public boolean applies(GameEvent event,Ability source,Game game){
  if (event.getType() == EventType.CAST_SPELL && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(GameEvent event,Ability source,Game game){
  return game.getOpponents(source.getControllerId()).contains(event.getPlayerId());
}
Program: 158911
Project: 158911
Buggy source:
private boolean checkAbilityStillExists(Ability ability,ContinuousEffect effect,GameEvent event,Game game){
  if (effect.getDuration().equals(Duration.OneUse) || effect.getDuration().equals(Duration.Custom) || 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: 158912
Project: 158912
Buggy source:
public void clear(){
  battlefield.clear();
  effects.clear();
  triggers.clear();
  delayed.clear();
  triggered.clear();
  stack.clear();
  exile.clear();
  command.clear();
  revealed.clear();
  lookedAt.clear();
  turnNum=0;
  stepNum=0;
  extraTurn=false;
  legendaryRuleActive=true;
  gameOver=false;
  specialActions.clear();
  cardState.clear();
  combat.clear();
  turnMods.clear();
  watchers.clear();
  values.clear();
  zones.clear();
  simultaneousEvents.clear();
  permanentOrderNumber=0;
}

Fixed version (ground truth):
public void clear(){
  battlefield.clear();
  effects.clear();
  triggers.clear();
  delayed.clear();
  triggered.clear();
  stack.clear();
  exile.clear();
  command.clear();
  revealed.clear();
  lookedAt.clear();
  turnNum=0;
  stepNum=0;
  extraTurn=false;
  legendaryRuleActive=true;
  gameOver=false;
  specialActions.clear();
  cardState.clear();
  combat.clear();
  turnMods.clear();
  watchers.clear();
  values.clear();
  zones.clear();
  simultaneousEvents.clear();
  copiedCards.clear();
  permanentOrderNumber=0;
}
Program: 158913
Project: 158913
Buggy source:
public ManaAbility(final ManaAbility ability){
  super(ability);
  this.netMana.addAll(ability.netMana);
}

Fixed version (ground truth):
public ManaAbility(final ManaAbility ability){
  super(ability);
  this.netMana.addAll(ability.netMana);
  this.undoPossible=ability.undoPossible;
}
Program: 158914
Project: 158914
Buggy source:
@Override public void pickCard(List<Card> cards,Deck deck,Draft draft){
  if (cards.isEmpty()) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  try {
    Card bestCard=pickBestCard(cards,chosenColors);
    int maxScore=RateCard.rateCard(bestCard,chosenColors);
    int pickedCardRate=RateCard.getCardRating(bestCard);
    if (pickedCardRate <= 3) {
      Card counterPick=pickBestCard(cards,null);
      int counterPickScore=RateCard.getCardRating(counterPick);
      if (counterPickScore >= 8) {
        bestCard=counterPick;
        maxScore=RateCard.rateCard(bestCard,chosenColors);
      }
    }
    String colors="String_Node_Str";
    if (chosenColors == null) {
      rememberPick(bestCard,maxScore);
      chosenColors=chooseDeckColorsIfPossible();
    }
    if (chosenColors != null) {
      colors="String_Node_Str";
      for (      ColoredManaSymbol symbol : chosenColors) {
        colors+=symbol.toString();
      }
    }
    log.debug("String_Node_Str" + bestCard.getName() + "String_Node_Str"+ maxScore+ "String_Node_Str"+ colors);
    draft.addPick(playerId,bestCard.getId(),null);
  }
 catch (  Exception e) {
    e.printStackTrace();
    draft.addPick(playerId,cards.get(0).getId(),null);
  }
}

Fixed version (ground truth):
@Override public void pickCard(List<Card> cards,Deck deck,Draft draft){
  if (cards.isEmpty()) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  try {
    Card bestCard=pickBestCard(cards,chosenColors);
    int maxScore=RateCard.rateCard(bestCard,chosenColors);
    int pickedCardRate=RateCard.getCardRating(bestCard);
    if (pickedCardRate <= 3) {
      Card counterPick=pickBestCard(cards,null);
      int counterPickScore=RateCard.getCardRating(counterPick);
      if (counterPickScore >= 8) {
        bestCard=counterPick;
        maxScore=RateCard.rateCard(bestCard,chosenColors);
      }
    }
    String colors="String_Node_Str";
    if (chosenColors == null) {
      rememberPick(bestCard,maxScore);
      chosenColors=chooseDeckColorsIfPossible();
    }
    if (chosenColors != null) {
      colors="String_Node_Str";
      for (      ColoredManaSymbol symbol : chosenColors) {
        colors+=symbol.toString();
      }
    }
    log.debug("String_Node_Str" + bestCard.getName() + "String_Node_Str"+ maxScore+ "String_Node_Str"+ colors);
    draft.addPick(playerId,bestCard.getId(),null);
  }
 catch (  Exception e) {
    log.debug("String_Node_Str" + getId());
    draft.addPick(playerId,cards.get(0).getId(),null);
  }
}
Program: 158915
Project: 158915
Buggy source:
@Override public boolean playMana(ManaCost unpaid,String promptText,Game game){
  payManaMode=true;
  boolean result=playManaHandling(unpaid,game);
  payManaMode=false;
  return result;
}

Fixed version (ground truth):
@Override public boolean playMana(ManaCost unpaid,String promptText,Game game){
  payManaMode=true;
  currentUnpaidMana=unpaid;
  boolean result=playManaHandling(unpaid,game);
  currentUnpaidMana=null;
  payManaMode=false;
  return result;
}
Program: 158916
Project: 158916
Buggy source:
@Override public boolean chooseTarget(Outcome outcome,Cards cards,TargetCard target,Ability source,Game game){
  log.debug("String_Node_Str");
  if (cards == null || cards.isEmpty()) {
    if (!target.isRequired(source)) {
      return false;
    }
    return true;
  }
  ArrayList<Card> cardChoices=new ArrayList<>(cards.getCards(target.getFilter(),game));
  while (!target.doneChosing()) {
    Card card=pickTarget(cardChoices,outcome,target,source,game);
    if (card != null) {
      target.addTarget(card.getId(),source,game);
      cardChoices.remove(card);
    }
 else {
      return target.getTargets().size() < target.getNumberOfTargets();
    }
    if (outcome.equals(Outcome.Neutral) && target.getTargets().size() > target.getNumberOfTargets() + (target.getMaxNumberOfTargets() - target.getNumberOfTargets()) / 2) {
      return true;
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean chooseTarget(Outcome outcome,Cards cards,TargetCard target,Ability source,Game game){
  log.debug("String_Node_Str");
  if (cards == null || cards.isEmpty()) {
    return target.isRequired(source);
  }
  ArrayList<Card> cardChoices=new ArrayList<>(cards.getCards(target.getFilter(),game));
  while (!target.doneChosing()) {
    Card card=pickTarget(cardChoices,outcome,target,source,game);
    if (card != null) {
      target.addTarget(card.getId(),source,game);
      cardChoices.remove(card);
    }
 else {
      return target.getTargets().size() < target.getNumberOfTargets();
    }
    if (outcome.equals(Outcome.Neutral) && target.getTargets().size() > target.getNumberOfTargets() + (target.getMaxNumberOfTargets() - target.getNumberOfTargets()) / 2) {
      return true;
    }
  }
  return true;
}
Program: 158918
Project: 158918
Buggy source:
protected void resolve(){
  StackObject top=null;
  try {
    top=state.getStack().peek();
    top.resolve(this);
  }
  finally {
    if (top != null) {
      state.getStack().remove(top);
      rememberLKI(top.getSourceId(),Zone.STACK,top);
      if (!getTurn().isEndTurnRequested()) {
        while (state.hasSimultaneousEvents()) {
          state.handleSimultaneousEvent(this);
          checkTriggered();
        }
      }
    }
  }
}

Fixed version (ground truth):
protected void resolve(){
  StackObject top=null;
  try {
    top=state.getStack().peek();
    top.resolve(this);
  }
  finally {
    if (top != null) {
      state.getStack().remove(top);
      rememberLKI(top.getSourceId(),Zone.STACK,top);
      if (!getTurn().isEndTurnRequested()) {
        while (state.hasSimultaneousEvents()) {
          state.handleSimultaneousEvent(this);
        }
      }
    }
  }
}
Program: 158919
Project: 158919
Buggy source:
@Override public boolean checkStateAndTriggered(){
  boolean trigger=!getTurn().isEndTurnRequested();
  boolean somethingHappened=false;
  while (!isPaused() && !gameOver(null)) {
    if (!checkStateBasedActions()) {
      if (trigger) {
        state.handleSimultaneousEvent(this);
      }
      if (isPaused() || gameOver(null) || !trigger|| !checkTriggered()) {
        break;
      }
    }
    applyEffects();
    somethingHappened=true;
  }
  return somethingHappened;
}

Fixed version (ground truth):
/** 
 * 116.5. Each time a player would get priority, the game first performs all applicable state-based actions as a single event (see rule 704, “State-Based Actions”), then repeats this process until no state-based actions are performed. Then triggered abilities are put on the stack (see rule 603, “Handling Triggered Abilities”). These steps repeat in order until no further state-based actions are performed and no abilities trigger. Then the player who would have received priority does so. 
 * @return 
 */
@Override public boolean checkStateAndTriggered(){
  boolean trigger=!getTurn().isEndTurnRequested();
  boolean somethingHappened=false;
  while (!isPaused() && !gameOver(null)) {
    if (!checkStateBasedActions()) {
      if (trigger) {
        state.handleSimultaneousEvent(this);
      }
      if (isPaused() || gameOver(null) || !trigger|| !checkTriggered()) {
        break;
      }
    }
    applyEffects();
    somethingHappened=true;
  }
  return somethingHappened;
}