nus-yam/ex-repair huggingface dataset:
Program: 158100
Project: 158100
Buggy source:
@Override public NecromanticSummoningEffect copy(){
  return new NecromanticSummoningEffect(this);
}

Fixed version (ground truth):
@Override public NecromanticSummoningReplacementEffect copy(){
  return new NecromanticSummoningReplacementEffect(this);
}
Program: 158101
Project: 158101
Buggy source:
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Permanent creature=((EntersTheBattlefieldEvent)event).getTarget();
  if (creature != null) {
    creature.addCounters(CounterType.P1P1.createInstance(),source,game);
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Permanent creature=((EntersTheBattlefieldEvent)event).getTarget();
  if (creature != null) {
    creature.addCounters(CounterType.P1P1.createInstance(),source,game,event.getAppliedEffects());
  }
  return false;
}
Program: 158102
Project: 158102
Buggy source:
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Permanent permanent=((EntersTheBattlefieldEvent)event).getTarget();
  if (permanent != null) {
    permanent.addCounters(CounterType.P1P1.createInstance(),source,game);
    discard();
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Permanent permanent=((EntersTheBattlefieldEvent)event).getTarget();
  if (permanent != null) {
    permanent.addCounters(CounterType.P1P1.createInstance(),source,game,event.getAppliedEffects());
    discard();
  }
  return false;
}
Program: 158103
Project: 158103
Buggy source:
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Permanent creature=((EntersTheBattlefieldEvent)event).getTarget();
  if (creature != null) {
    creature.addCounters(CounterType.P1P1.createInstance(),source,game);
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Permanent creature=((EntersTheBattlefieldEvent)event).getTarget();
  if (creature != null) {
    creature.addCounters(CounterType.P1P1.createInstance(),source,game,event.getAppliedEffects());
  }
  return false;
}
Program: 158104
Project: 158104
Buggy source:
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Permanent creature=((EntersTheBattlefieldEvent)event).getTarget();
  if (creature != null) {
    creature.addCounters(CounterType.P1P1.createInstance(),source,game);
  }
  discard();
  return false;
}

Fixed version (ground truth):
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Permanent creature=((EntersTheBattlefieldEvent)event).getTarget();
  if (creature != null) {
    creature.addCounters(CounterType.P1P1.createInstance(),source,game,event.getAppliedEffects());
  }
  discard();
  return false;
}
Program: 158106
Project: 158106
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(getTargetPointer().getFirst(game,source));
  Object object=(String)game.getState().getValue(source.getSourceId().toString() + NameACardEffect.INFO_KEY);
  if (player != null && object instanceof String) {
    String namedCard=(String)object;
    for (    Card card : player.getHand().getCards(game)) {
      if (card != null && card.getName().equals(namedCard)) {
        return new SearchLibraryPutInHandEffect(new TargetCardInLibrary(filter),true,true).apply(game,source);
      }
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(getTargetPointer().getFirst(game,source));
  Object object=(String)game.getState().getValue(source.getSourceId().toString() + NameACardEffect.INFO_KEY);
  if (player != null && object instanceof String) {
    player.revealCards(player.getLogName() + "String_Node_Str",player.getHand(),game,true);
    String namedCard=(String)object;
    for (    Card card : player.getHand().getCards(game)) {
      if (card != null && card.getName().equals(namedCard)) {
        return new SearchLibraryPutInHandEffect(new TargetCardInLibrary(filter),true,true).apply(game,source);
      }
    }
    return true;
  }
  return false;
}
Program: 158107
Project: 158107
Buggy source:
@Override public TargetCreaturePermanentSameController copy(){
  return new TargetCreaturePermanentSameController(this);
}

Fixed version (ground truth):
@Override public CannibalizeEffect copy(){
  return new CannibalizeEffect(this);
}
Program: 158109
Project: 158109
Buggy source:
@Override public boolean canTarget(UUID controllerId,UUID id,Ability source,Game game){
  if (super.canTarget(controllerId,id,source,game)) {
    Permanent firstTargetPermanent=game.getPermanent(id);
    if (firstTargetPermanent != null) {
      for (      Object object : getTargets()) {
        UUID targetId=(UUID)object;
        Permanent targetPermanent=game.getPermanent(targetId);
        if (targetPermanent != null) {
          if (firstTargetPermanent.getId() != targetPermanent.getId()) {
            if (!firstTargetPermanent.getControllerId().equals(targetPermanent.getOwnerId())) {
              return false;
            }
          }
        }
      }
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean canTarget(UUID controllerId,UUID id,Ability source,Game game){
  if (super.canTarget(controllerId,id,source,game)) {
    Permanent firstTargetPermanent=game.getPermanent(id);
    if (firstTargetPermanent != null) {
      for (      Object object : getTargets()) {
        UUID targetId=(UUID)object;
        Permanent targetPermanent=game.getPermanent(targetId);
        if (targetPermanent != null) {
          if (!firstTargetPermanent.getId().equals(targetPermanent.getId())) {
            if (!firstTargetPermanent.getControllerId().equals(targetPermanent.getOwnerId())) {
              return false;
            }
          }
        }
      }
      return true;
    }
  }
  return false;
}
Program: 158110
Project: 158110
Buggy source:
@Override public boolean canTarget(UUID controllerId,UUID id,Ability source,Game game){
  if (super.canTarget(controllerId,id,source,game)) {
    Permanent creature=game.getPermanent(id);
    if (creature != null) {
      for (      Object object : getTargets()) {
        UUID targetId=(UUID)object;
        Permanent selectedCreature=game.getPermanent(targetId);
        if (creature.getId() != selectedCreature.getId()) {
          if (CardUtil.shareSubtypes(creature,selectedCreature,game)) {
            return false;
          }
        }
      }
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean canTarget(UUID controllerId,UUID id,Ability source,Game game){
  if (super.canTarget(controllerId,id,source,game)) {
    Permanent creature=game.getPermanent(id);
    if (creature != null) {
      for (      Object object : getTargets()) {
        UUID targetId=(UUID)object;
        Permanent selectedCreature=game.getPermanent(targetId);
        if (!creature.getId().equals(selectedCreature.getId())) {
          if (CardUtil.shareSubtypes(creature,selectedCreature,game)) {
            return false;
          }
        }
      }
      return true;
    }
  }
  return false;
}
Program: 158111
Project: 158111
Buggy source:
@Override public boolean applies(UUID sourceId,Ability source,UUID affectedControllerId,Game game){
  if (sourceId.equals(source.getSourceId())) {
    Card card=game.getCard(source.getSourceId());
    if (card != null && card.getOwnerId().equals(source.getControllerId()) && game.getState().getZone(source.getSourceId()) == Zone.EXILED) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(UUID sourceId,Ability source,UUID affectedControllerId,Game game){
  if (sourceId.equals(source.getSourceId())) {
    Card card=game.getCard(source.getSourceId());
    if (card != null && card.getOwnerId().equals(affectedControllerId) && game.getState().getZone(source.getSourceId()) == Zone.EXILED) {
      return true;
    }
  }
  return false;
}
Program: 158112
Project: 158112
Buggy source:
@Override public boolean sacrifice(UUID sourceId,Game game){
  if (isPhasedIn() && !game.replaceEvent(GameEvent.getEvent(EventType.SACRIFICE_PERMANENT,objectId,sourceId,controllerId))) {
    moveToZone(Zone.GRAVEYARD,sourceId,game,false);
    Player player=game.getPlayer(getControllerId());
    if (player != null && !game.isSimulation()) {
      game.informPlayers(player.getLogName() + "String_Node_Str" + this.getLogName());
    }
    game.fireEvent(GameEvent.getEvent(EventType.SACRIFICED_PERMANENT,objectId,sourceId,controllerId));
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean sacrifice(UUID sourceId,Game game){
  if (isPhasedIn() && !game.replaceEvent(GameEvent.getEvent(EventType.SACRIFICE_PERMANENT,objectId,sourceId,controllerId))) {
    moveToZone(Zone.GRAVEYARD,sourceId,game,false);
    Player player=game.getPlayer(getControllerId());
    if (player != null && !game.isSimulation()) {
      game.informPlayers(player.getLogName() + "String_Node_Str" + this.getLogName());
    }
    game.fireEvent(GameEvent.getEvent(EventType.SACRIFICED_PERMANENT,objectId,sourceId,controllerId));
    game.checkStateAndTriggered();
    return true;
  }
  return false;
}
Program: 158113
Project: 158113
Buggy source:
public static String getStringManaCost(List<String> manaCost){
  StringBuilder sb=new StringBuilder();
  for (  String s : manaCost) {
    sb.append(s);
  }
  return sb.toString().replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str").trim();
}

Fixed version (ground truth):
public static String getStringManaCost(List<String> manaCost){
  StringBuilder sb=new StringBuilder();
  for (  String s : manaCost) {
    sb.append(s);
  }
  return sb.toString().replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str").trim();
}
Program: 158114
Project: 158114
Buggy source:
/** 
 * Reported bug: "Silverfur Partisan and fellow wolves did not trigger off of copies of Strength of Arms made by Zada, Hedron Grinder.  Not sure about other spells, but I imagine similar results."
 */
@Test public void ZadaHedronSilverfurPartisan(){
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.HAND,playerA,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",3);
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",3);
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str","String_Node_Str");
  setStopAt(1,PhaseStep.BEGIN_COMBAT);
  execute();
  assertGraveyardCount(playerA,"String_Node_Str",1);
  assertPowerToughness(playerA,"String_Node_Str",5,5);
  assertPowerToughness(playerA,"String_Node_Str",6,6);
  assertPermanentCount(playerA,"String_Node_Str",1);
}

Fixed version (ground truth):
/** 
 * Reported bug: "Silverfur Partisan and fellow wolves did not trigger off of copies of Strength of Arms made by Zada, Hedron Grinder. Not sure about other spells, but I imagine similar results."
 */
@Test public void ZadaHedronSilverfurPartisan(){
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.HAND,playerA,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",3);
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",3);
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str","String_Node_Str");
  setStopAt(1,PhaseStep.BEGIN_COMBAT);
  execute();
  assertGraveyardCount(playerA,"String_Node_Str",1);
  assertPowerToughness(playerA,"String_Node_Str",5,5);
  assertPowerToughness(playerA,"String_Node_Str",6,6);
  assertPermanentCount(playerA,"String_Node_Str",1);
}
Program: 158115
Project: 158115
Buggy source:
/** 
 * {4}{U} Enchantment (Enchant Player) Whenever enchanted player casts an instant or sorcery spell, each other player may copy that spell  and may choose new targets for the copy he or she controls. Reported bug: "A player with Curse of Echoes attached to them played Bribery and the player who controlled the curse had control  of all 3 copies. This seems to be the case for all spells."
 */
@Test public void testCurseOfEchoes(){
  addCard(Zone.HAND,playerA,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",5);
  addCard(Zone.HAND,playerB,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerB,"String_Node_Str");
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str");
  addTarget(playerA,playerB);
  castSpell(2,PhaseStep.PRECOMBAT_MAIN,playerB,"String_Node_Str");
  addTarget(playerB,playerA);
  setChoice(playerA,"String_Node_Str");
  addTarget(playerA,playerB);
  setStopAt(2,PhaseStep.BEGIN_COMBAT);
  execute();
  assertGraveyardCount(playerB,"String_Node_Str",1);
  assertLife(playerA,17);
  assertLife(playerB,17);
}

Fixed version (ground truth):
/** 
 * {4}{U} Enchantment (Enchant Player) Whenever enchanted player casts an instant or sorcery spell, each other player may copy that spell and may choose new targets for the copy he or she controls. Reported bug: "A player with Curse of Echoes attached to them played Bribery and the player who controlled the curse had control of all 3 copies. This seems to be the case for all spells."
 */
@Test public void testCurseOfEchoes(){
  addCard(Zone.HAND,playerA,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",5);
  addCard(Zone.HAND,playerB,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerB,"String_Node_Str");
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str");
  addTarget(playerA,playerB);
  castSpell(2,PhaseStep.PRECOMBAT_MAIN,playerB,"String_Node_Str");
  addTarget(playerB,playerA);
  setChoice(playerA,"String_Node_Str");
  addTarget(playerA,playerB);
  setStopAt(2,PhaseStep.BEGIN_COMBAT);
  execute();
  assertGraveyardCount(playerB,"String_Node_Str",1);
  assertLife(playerA,17);
  assertLife(playerB,17);
}
Program: 158116
Project: 158116
Buggy source:
@Override public boolean addTargets(Ability ability,Game game){
  if (groupsForTargetHandling == null) {
    return true;
  }
  boolean result=true;
  for (int i=1; i < groupsForTargetHandling.length; i++) {
    String group=groupsForTargetHandling[i];
    if (group.startsWith("String_Node_Str") || group.startsWith("String_Node_Str") || group.startsWith("String_Node_Str")|| group.startsWith("String_Node_Str")|| group.startsWith("String_Node_Str")) {
      break;
    }
    if (ability instanceof SpellAbility && ((SpellAbility)ability).getSpellAbilityType().equals(SpellAbilityType.SPLIT_FUSED)) {
      if (group.contains("String_Node_Str")) {
        result=handleTargetString(group.substring(group.indexOf("String_Node_Str") + 9),ability,game);
      }
 else       if (group.startsWith("String_Node_Str")) {
        result=handleTargetString(group.substring(group.indexOf("String_Node_Str") + 10),ability,game);
      }
 else {
        result=false;
      }
    }
 else {
      result=handleTargetString(group,ability,game);
    }
  }
  return result;
}

Fixed version (ground truth):
@Override public boolean addTargets(Ability ability,Game game){
  if (groupsForTargetHandling == null) {
    return true;
  }
  boolean result=true;
  for (int i=1; i < groupsForTargetHandling.length; i++) {
    String group=groupsForTargetHandling[i];
    if (group.startsWith("String_Node_Str") || group.startsWith("String_Node_Str") || group.startsWith("String_Node_Str")|| group.startsWith("String_Node_Str")) {
      break;
    }
    if (ability instanceof SpellAbility && ((SpellAbility)ability).getSpellAbilityType().equals(SpellAbilityType.SPLIT_FUSED)) {
      if (group.contains("String_Node_Str")) {
        result=handleTargetString(group.substring(group.indexOf("String_Node_Str") + 9),ability,game);
      }
 else       if (group.startsWith("String_Node_Str")) {
        result=handleTargetString(group.substring(group.indexOf("String_Node_Str") + 10),ability,game);
      }
 else {
        result=false;
      }
    }
 else {
      result=handleTargetString(group,ability,game);
    }
  }
  return result;
}
Program: 158117
Project: 158117
Buggy source:
private boolean checkExecuteCondition(String[] groups,Game game){
  if (groups[2].startsWith("String_Node_Str")) {
    String spellOnStack=groups[2].substring(13);
    for (    StackObject stackObject : game.getStack()) {
      if (stackObject.getStackAbility().toString().contains(spellOnStack)) {
        return true;
      }
    }
    return false;
  }
 else   if (groups[2].startsWith("String_Node_Str")) {
    String spellNotOnStack=groups[2].substring(14);
    for (    StackObject stackObject : game.getStack()) {
      if (stackObject.getStackAbility().toString().contains(spellNotOnStack)) {
        return false;
      }
    }
    return true;
  }
 else   if (groups[2].startsWith("String_Node_Str")) {
    String spellOnTopOFStack=groups[2].substring(18);
    if (!game.getStack().isEmpty()) {
      StackObject stackObject=game.getStack().getFirst();
      if (stackObject != null && stackObject.getStackAbility().toString().contains(spellOnTopOFStack)) {
        return true;
      }
    }
    return false;
  }
 else   if (groups[2].startsWith("String_Node_Str")) {
    String manaInPool=groups[2].substring(11);
    int amountOfMana=Integer.parseInt(manaInPool);
    return computerPlayer.getManaPool().getMana().count() >= amountOfMana;
  }
  return true;
}

Fixed version (ground truth):
private boolean checkExecuteCondition(String[] groups,Game game){
  if (groups[2].startsWith("String_Node_Str")) {
    String spellOnStack=groups[2].substring(13);
    for (    StackObject stackObject : game.getStack()) {
      if (stackObject.getStackAbility().toString().contains(spellOnStack)) {
        return true;
      }
    }
    return false;
  }
 else   if (groups[2].startsWith("String_Node_Str")) {
    String spellOnStack=groups[2].substring(17);
    for (    StackObject stackObject : game.getStack()) {
      if (stackObject.getStackAbility().toString().contains(spellOnStack)) {
        if (stackObject.isCopy()) {
          return true;
        }
      }
    }
    return false;
  }
 else   if (groups[2].startsWith("String_Node_Str")) {
    String spellNotOnStack=groups[2].substring(14);
    for (    StackObject stackObject : game.getStack()) {
      if (stackObject.getStackAbility().toString().contains(spellNotOnStack)) {
        return false;
      }
    }
    return true;
  }
 else   if (groups[2].startsWith("String_Node_Str")) {
    String spellOnTopOFStack=groups[2].substring(18);
    if (!game.getStack().isEmpty()) {
      StackObject stackObject=game.getStack().getFirst();
      if (stackObject != null && stackObject.getStackAbility().toString().contains(spellOnTopOFStack)) {
        return true;
      }
    }
    return false;
  }
 else   if (groups[2].startsWith("String_Node_Str")) {
    String manaInPool=groups[2].substring(11);
    int amountOfMana=Integer.parseInt(manaInPool);
    return computerPlayer.getManaPool().getMana().count() >= amountOfMana;
  }
  return true;
}
Program: 158118
Project: 158118
Buggy source:
/** 
 * @param turnNum
 * @param step
 * @param player
 * @param ability
 * @param targetName if not target has to be defined use the constantNO_TARGET
 * @param spellOnStack
 */
public void activateAbility(int turnNum,PhaseStep step,TestPlayer player,String ability,String targetName,String spellOnStack,StackClause clause){
  StringBuilder sb=new StringBuilder("String_Node_Str").append(ability);
  if (targetName != null && !targetName.isEmpty()) {
    sb.append("String_Node_Str").append(targetName);
  }
  if (spellOnStack != null && !spellOnStack.isEmpty()) {
    sb.append('$').append(StackClause.WHILE_ON_STACK.equals(clause) ? "String_Node_Str" : "String_Node_Str").append("String_Node_Str").append(spellOnStack);
  }
  player.addAction(turnNum,step,sb.toString());
}

Fixed version (ground truth):
/** 
 * @param turnNum
 * @param step
 * @param player
 * @param ability
 * @param targetName if not target has to be defined use the constantNO_TARGET
 * @param spellOnStack
 * @param clause
 */
public void activateAbility(int turnNum,PhaseStep step,TestPlayer player,String ability,String targetName,String spellOnStack,StackClause clause){
  StringBuilder sb=new StringBuilder("String_Node_Str").append(ability);
  if (targetName != null && !targetName.isEmpty()) {
    sb.append("String_Node_Str").append(targetName);
  }
  if (spellOnStack != null && !spellOnStack.isEmpty()) {
    sb.append('$');
switch (clause) {
case WHILE_ON_STACK:
      sb.append("String_Node_Str");
    break;
case WHILE_NOT_ON_STACK:
  sb.append("String_Node_Str");
break;
case WHILE_COPY_ON_STACK:
sb.append("String_Node_Str");
break;
}
sb.append(spellOnStack);
}
player.addAction(turnNum,step,sb.toString());
}
Program: 158119
Project: 158119
Buggy source:
@Override public void counter(UUID sourceId,Game game,Zone zone,boolean owner,ZoneDetail zoneDetail){
  this.countered=true;
  if (!isCopiedSpell()) {
    Player player=game.getPlayer(game.getControllerId(sourceId));
    if (player == null) {
      player=game.getPlayer(getControllerId());
    }
    if (player != null) {
      Ability counteringAbility=null;
      MageObject counteringObject=game.getObject(sourceId);
      if (counteringObject instanceof StackObject) {
        counteringAbility=((StackObject)counteringObject).getStackAbility();
      }
      if (zone.equals(Zone.LIBRARY)) {
        if (zoneDetail.equals(ZoneDetail.CHOOSE)) {
          if (player.chooseUse(Outcome.Detriment,"String_Node_Str",counteringAbility,game)) {
            zoneDetail=ZoneDetail.TOP;
          }
 else {
            zoneDetail=ZoneDetail.BOTTOM;
          }
        }
        if (zoneDetail.equals(ZoneDetail.TOP)) {
          player.putCardsOnTopOfLibrary(new CardsImpl(card),game,counteringAbility,false);
        }
 else {
          player.putCardsOnBottomOfLibrary(new CardsImpl(card),game,counteringAbility,false);
        }
      }
 else {
        player.moveCards(card,zone,counteringAbility,game,false,false,owner,null);
      }
    }
  }
 else {
    card.removeFromZone(game,Zone.STACK,sourceId);
  }
}

Fixed version (ground truth):
@Override public void counter(UUID sourceId,Game game,Zone zone,boolean owner,ZoneDetail zoneDetail){
  this.countered=true;
  if (!isCopiedSpell()) {
    Player player=game.getPlayer(game.getControllerId(sourceId));
    if (player == null) {
      player=game.getPlayer(getControllerId());
    }
    if (player != null) {
      Ability counteringAbility=null;
      MageObject counteringObject=game.getObject(sourceId);
      if (counteringObject instanceof StackObject) {
        counteringAbility=((StackObject)counteringObject).getStackAbility();
      }
      if (zone.equals(Zone.LIBRARY)) {
        if (zoneDetail.equals(ZoneDetail.CHOOSE)) {
          if (player.chooseUse(Outcome.Detriment,"String_Node_Str",counteringAbility,game)) {
            zoneDetail=ZoneDetail.TOP;
          }
 else {
            zoneDetail=ZoneDetail.BOTTOM;
          }
        }
        if (zoneDetail.equals(ZoneDetail.TOP)) {
          player.putCardsOnTopOfLibrary(new CardsImpl(card),game,counteringAbility,false);
        }
 else {
          player.putCardsOnBottomOfLibrary(new CardsImpl(card),game,counteringAbility,false);
        }
      }
 else {
        player.moveCards(card,zone,counteringAbility,game,false,false,owner,null);
      }
    }
  }
 else {
    game.getStack().remove(this);
  }
}
Program: 158121
Project: 158121
Buggy source:
@Override public int chooseReplacementEffect(Map<String,String> rEffects,Game game){
  updateGameStatePriority("String_Node_Str",game);
  if (rEffects.size() == 1) {
    return 0;
  }
  if (!autoSelectReplacementEffects.isEmpty()) {
    for (    String autoKey : autoSelectReplacementEffects) {
      int count=0;
      for (      String effectKey : rEffects.keySet()) {
        if (effectKey.equals(autoKey)) {
          return count;
        }
        count++;
      }
    }
  }
  replacementEffectChoice.getChoices().clear();
  replacementEffectChoice.setKeyChoices(rEffects);
  while (!abort) {
    game.fireChooseChoiceEvent(playerId,replacementEffectChoice);
    waitForResponse(game);
    logger.debug("String_Node_Str" + response.getString());
    if (response.getString() != null) {
      if (response.getString().startsWith("String_Node_Str")) {
        autoSelectReplacementEffects.add(response.getString().substring(1));
        replacementEffectChoice.setChoiceByKey(response.getString().substring(1));
      }
 else {
        replacementEffectChoice.setChoiceByKey(response.getString());
      }
      if (replacementEffectChoice.getChoiceKey() != null) {
        int index=0;
        for (        String key : rEffects.keySet()) {
          if (replacementEffectChoice.getChoiceKey().equals(key)) {
            return index;
          }
          index++;
        }
      }
    }
  }
  return 0;
}

Fixed version (ground truth):
@Override public int chooseReplacementEffect(Map<String,String> rEffects,Game game){
  updateGameStatePriority("String_Node_Str",game);
  if (rEffects.size() <= 1) {
    return 0;
  }
  if (!autoSelectReplacementEffects.isEmpty()) {
    for (    String autoKey : autoSelectReplacementEffects) {
      int count=0;
      for (      String effectKey : rEffects.keySet()) {
        if (effectKey.equals(autoKey)) {
          return count;
        }
        count++;
      }
    }
  }
  replacementEffectChoice.getChoices().clear();
  replacementEffectChoice.setKeyChoices(rEffects);
  while (!abort) {
    game.fireChooseChoiceEvent(playerId,replacementEffectChoice);
    waitForResponse(game);
    logger.debug("String_Node_Str" + response.getString());
    if (response.getString() != null) {
      if (response.getString().startsWith("String_Node_Str")) {
        autoSelectReplacementEffects.add(response.getString().substring(1));
        replacementEffectChoice.setChoiceByKey(response.getString().substring(1));
      }
 else {
        replacementEffectChoice.setChoiceByKey(response.getString());
      }
      if (replacementEffectChoice.getChoiceKey() != null) {
        int index=0;
        for (        String key : rEffects.keySet()) {
          if (replacementEffectChoice.getChoiceKey().equals(key)) {
            return index;
          }
          index++;
        }
      }
    }
  }
  return 0;
}
Program: 158122
Project: 158122
Buggy source:
public FirstSpellCastThisTurnWatcher(final FirstSpellCastThisTurnWatcher watcher){
  super(watcher);
  playerFirstSpellCast.putAll(watcher.playerFirstSpellCast);
  playerFirstCastSpell.putAll(watcher.playerFirstSpellCast);
}

Fixed version (ground truth):
public FirstSpellCastThisTurnWatcher(final FirstSpellCastThisTurnWatcher watcher){
  super(watcher);
  playerFirstSpellCast.putAll(watcher.playerFirstSpellCast);
  playerFirstCastSpell.putAll(watcher.playerFirstCastSpell);
}
Program: 158123
Project: 158123
Buggy source:
@Override public ViewFactory getViewFactory(){
  return new HTMLFactory(){
    @Override public View create(    Element elem){
      Object o=elem.getAttributes().getAttribute(StyleConstants.NameAttribute);
      if (o instanceof HTML.Tag) {
        HTML.Tag kind=(HTML.Tag)o;
        if (kind == HTML.Tag.IMG) {
          return new ImageView(elem){
            @Override public URL getImageURL(){
              URL url=super.getImageURL();
              URI uri=null;
              try {
                uri=url.toURI();
              }
 catch (              URISyntaxException ex) {
              }
              if (uri != null && imageCache.get(uri) == null) {
                imageCache.put(uri,Toolkit.getDefaultToolkit().createImage(url));
              }
              return url;
            }
          }
;
        }
      }
      return super.create(elem);
    }
  }
;
}

Fixed version (ground truth):
@Override public ViewFactory getViewFactory(){
  return new HTMLFactory(){
    @Override public View create(    Element elem){
      Object o=elem.getAttributes().getAttribute(StyleConstants.NameAttribute);
      if (o instanceof HTML.Tag) {
        HTML.Tag kind=(HTML.Tag)o;
        if (Objects.equals(kind,HTML.Tag.IMG)) {
          return new ImageView(elem){
            @Override public URL getImageURL(){
              URL url=super.getImageURL();
              URI uri=null;
              try {
                uri=url.toURI();
              }
 catch (              URISyntaxException ex) {
              }
              if (uri != null && imageCache.get(uri) == null) {
                imageCache.put(uri,Toolkit.getDefaultToolkit().createImage(url));
              }
              return url;
            }
          }
;
        }
      }
      return super.create(elem);
    }
  }
;
}
Program: 158124
Project: 158124
Buggy source:
public static void setHTMLEditorKit(JEditorPane editorPane){
  editorPane.getDocument().putProperty("String_Node_Str",imageCache);
  editorPane.setEditorKit(new HTMLEditorKit(){
    private static final long serialVersionUID=-54602188235105448L;
    @Override public ViewFactory getViewFactory(){
      return new HTMLFactory(){
        @Override public View create(        Element elem){
          Object o=elem.getAttributes().getAttribute(StyleConstants.NameAttribute);
          if (o instanceof HTML.Tag) {
            HTML.Tag kind=(HTML.Tag)o;
            if (kind == HTML.Tag.IMG) {
              return new ImageView(elem){
                @Override public URL getImageURL(){
                  URL url=super.getImageURL();
                  URI uri=null;
                  try {
                    uri=url.toURI();
                  }
 catch (                  URISyntaxException ex) {
                  }
                  if (uri != null && imageCache.get(uri) == null) {
                    imageCache.put(uri,Toolkit.getDefaultToolkit().createImage(url));
                  }
                  return url;
                }
              }
;
            }
          }
          return super.create(elem);
        }
      }
;
    }
  }
);
}

Fixed version (ground truth):
public static void setHTMLEditorKit(JEditorPane editorPane){
  editorPane.getDocument().putProperty("String_Node_Str",imageCache);
  editorPane.setEditorKit(new HTMLEditorKit(){
    private static final long serialVersionUID=-54602188235105448L;
    @Override public ViewFactory getViewFactory(){
      return new HTMLFactory(){
        @Override public View create(        Element elem){
          Object o=elem.getAttributes().getAttribute(StyleConstants.NameAttribute);
          if (o instanceof HTML.Tag) {
            HTML.Tag kind=(HTML.Tag)o;
            if (Objects.equals(kind,HTML.Tag.IMG)) {
              return new ImageView(elem){
                @Override public URL getImageURL(){
                  URL url=super.getImageURL();
                  URI uri=null;
                  try {
                    uri=url.toURI();
                  }
 catch (                  URISyntaxException ex) {
                  }
                  if (uri != null && imageCache.get(uri) == null) {
                    imageCache.put(uri,Toolkit.getDefaultToolkit().createImage(url));
                  }
                  return url;
                }
              }
;
            }
          }
          return super.create(elem);
        }
      }
;
    }
  }
);
}
Program: 158125
Project: 158125
Buggy source:
@Override public View create(Element elem){
  Object o=elem.getAttributes().getAttribute(StyleConstants.NameAttribute);
  if (o instanceof HTML.Tag) {
    HTML.Tag kind=(HTML.Tag)o;
    if (kind == HTML.Tag.IMG) {
      return new ImageView(elem){
        @Override public URL getImageURL(){
          URL url=super.getImageURL();
          URI uri=null;
          try {
            uri=url.toURI();
          }
 catch (          URISyntaxException ex) {
          }
          if (uri != null && imageCache.get(uri) == null) {
            imageCache.put(uri,Toolkit.getDefaultToolkit().createImage(url));
          }
          return url;
        }
      }
;
    }
  }
  return super.create(elem);
}

Fixed version (ground truth):
@Override public View create(Element elem){
  Object o=elem.getAttributes().getAttribute(StyleConstants.NameAttribute);
  if (o instanceof HTML.Tag) {
    HTML.Tag kind=(HTML.Tag)o;
    if (Objects.equals(kind,HTML.Tag.IMG)) {
      return new ImageView(elem){
        @Override public URL getImageURL(){
          URL url=super.getImageURL();
          URI uri=null;
          try {
            uri=url.toURI();
          }
 catch (          URISyntaxException ex) {
          }
          if (uri != null && imageCache.get(uri) == null) {
            imageCache.put(uri,Toolkit.getDefaultToolkit().createImage(url));
          }
          return url;
        }
      }
;
    }
  }
  return super.create(elem);
}
Program: 158127
Project: 158127
Buggy source:
private boolean checkPassStep(Game game,HumanPlayer controllingPlayer){
  try {
    if (playerId.equals(game.getActivePlayerId())) {
      return !controllingPlayer.getUserData().getUserSkipPrioritySteps().getYourTurn().isPhaseStepSet(game.getStep().getType());
    }
 else {
      return !controllingPlayer.getUserData().getUserSkipPrioritySteps().getOpponentTurn().isPhaseStepSet(game.getStep().getType());
    }
  }
 catch (  NullPointerException ex) {
    logger.error("String_Node_Str" + userData == null ? "String_Node_Str" : "String_Node_Str");
  }
  return true;
}

Fixed version (ground truth):
private boolean checkPassStep(Game game,HumanPlayer controllingPlayer){
  try {
    if (playerId.equals(game.getActivePlayerId())) {
      return !controllingPlayer.getUserData().getUserSkipPrioritySteps().getYourTurn().isPhaseStepSet(game.getStep().getType());
    }
 else {
      return !controllingPlayer.getUserData().getUserSkipPrioritySteps().getOpponentTurn().isPhaseStepSet(game.getStep().getType());
    }
  }
 catch (  NullPointerException ex) {
    String isNull=userData == null ? "String_Node_Str" : "String_Node_Str";
    logger.error("String_Node_Str" + isNull);
  }
  return true;
}
Program: 158128
Project: 158128
Buggy source:
private static MatchType loadGameType(GamePlugin plugin){
  try {
    classLoader.addURL(new File(pluginFolder,plugin.getJar()).toURI().toURL());
    logger.debug("String_Node_Str" + plugin.getClassName());
    return (MatchType)Class.forName(plugin.getTypeName(),true,classLoader).newInstance();
  }
 catch (  ClassNotFoundException ex) {
    logger.warn("String_Node_Str" + plugin.getJar() + "String_Node_Str",ex);
  }
catch (  Exception ex) {
    logger.fatal("String_Node_Str" + plugin.getJar(),ex);
  }
  return null;
}

Fixed version (ground truth):
private static MatchType loadGameType(GamePlugin plugin){
  try {
    classLoader.addURL(new File(pluginFolder,plugin.getJar()).toURI().toURL());
    logger.debug("String_Node_Str" + plugin.getClassName());
    return (MatchType)Class.forName(plugin.getTypeName(),true,classLoader).getConstructor().newInstance();
  }
 catch (  ClassNotFoundException ex) {
    logger.warn("String_Node_Str" + plugin.getJar() + "String_Node_Str",ex);
  }
catch (  Exception ex) {
    logger.fatal("String_Node_Str" + plugin.getJar(),ex);
  }
  return null;
}
Program: 158129
Project: 158129
Buggy source:
private static TournamentType loadTournamentType(GamePlugin plugin){
  try {
    classLoader.addURL(new File(pluginFolder,plugin.getJar()).toURI().toURL());
    logger.debug("String_Node_Str" + plugin.getClassName());
    return (TournamentType)Class.forName(plugin.getTypeName(),true,classLoader).newInstance();
  }
 catch (  ClassNotFoundException ex) {
    logger.warn("String_Node_Str" + plugin.getName() + "String_Node_Str"+ plugin.getJar()+ "String_Node_Str",ex);
  }
catch (  Exception ex) {
    logger.fatal("String_Node_Str" + plugin.getJar(),ex);
  }
  return null;
}

Fixed version (ground truth):
private static TournamentType loadTournamentType(GamePlugin plugin){
  try {
    classLoader.addURL(new File(pluginFolder,plugin.getJar()).toURI().toURL());
    logger.debug("String_Node_Str" + plugin.getClassName());
    return (TournamentType)Class.forName(plugin.getTypeName(),true,classLoader).getConstructor().newInstance();
  }
 catch (  ClassNotFoundException ex) {
    logger.warn("String_Node_Str" + plugin.getName() + "String_Node_Str"+ plugin.getJar()+ "String_Node_Str",ex);
  }
catch (  Exception ex) {
    logger.fatal("String_Node_Str" + plugin.getJar(),ex);
  }
  return null;
}
Program: 158130
Project: 158130
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  MageObject mageObject=game.getObject(source.getSourceId());
  if (controller != null) {
    Set<Card> topCards=controller.getLibrary().getTopCards(game,5);
    Cards cardsFromLibrary=new CardsImpl();
    for (    Card card : topCards) {
      cardsFromLibrary.add(card);
    }
    controller.lookAtCards(mageObject.getIdName(),cardsFromLibrary,game);
    int max=0;
    for (    UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
      FilterCreaturePermanent filter=new FilterCreaturePermanent();
      filter.add(new ControllerIdPredicate(playerId));
      if (playerId != controller.getId()) {
        if (max < game.getBattlefield().countAll(filter,playerId,game)) {
          max=game.getBattlefield().countAll(filter,playerId,game);
        }
      }
    }
    boolean moreCreatures=game.getBattlefield().countAll(new FilterControlledCreaturePermanent(),controller.getId(),game) > max;
    TargetCard target=new TargetCard(moreCreatures ? 2 : 1,Zone.LIBRARY,new FilterCard());
    if (controller.choose(Outcome.DrawCard,cardsFromLibrary,target,game)) {
      cardsFromLibrary.removeAll(target.getTargets());
      controller.moveCards(new CardsImpl(target.getTargets()),Zone.HAND,source,game);
    }
    controller.putCardsOnBottomOfLibrary(cardsFromLibrary,game,source,true);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  MageObject mageObject=game.getObject(source.getSourceId());
  if (controller != null) {
    Set<Card> topCards=controller.getLibrary().getTopCards(game,5);
    Cards cardsFromLibrary=new CardsImpl();
    for (    Card card : topCards) {
      cardsFromLibrary.add(card);
    }
    controller.lookAtCards(mageObject.getIdName(),cardsFromLibrary,game);
    int max=0;
    for (    UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
      FilterCreaturePermanent filter=new FilterCreaturePermanent();
      filter.add(new ControllerIdPredicate(playerId));
      if (!Objects.equals(playerId,controller.getId())) {
        if (max < game.getBattlefield().countAll(filter,playerId,game)) {
          max=game.getBattlefield().countAll(filter,playerId,game);
        }
      }
    }
    boolean moreCreatures=game.getBattlefield().countAll(new FilterControlledCreaturePermanent(),controller.getId(),game) > max;
    TargetCard target=new TargetCard(moreCreatures ? 2 : 1,Zone.LIBRARY,new FilterCard());
    if (controller.choose(Outcome.DrawCard,cardsFromLibrary,target,game)) {
      cardsFromLibrary.removeAll(target.getTargets());
      controller.moveCards(new CardsImpl(target.getTargets()),Zone.HAND,source,game);
    }
    controller.putCardsOnBottomOfLibrary(cardsFromLibrary,game,source,true);
    return true;
  }
  return false;
}
Program: 158131
Project: 158131
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    Cards revealedCards=new CardsImpl();
    for (    UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
      if (playerId != controller.getId()) {
        Player opponent=game.getPlayer(playerId);
        if (opponent != null) {
          Cards cards=new CardsImpl(opponent.getHand());
          opponent.revealCards(opponent.getName() + "String_Node_Str",cards,game);
          revealedCards.addAll(cards);
        }
      }
    }
    TargetCard target=new TargetCard(Zone.HAND,new FilterNonlandCard("String_Node_Str"));
    controller.chooseTarget(Outcome.Benefit,revealedCards,target,source,game);
    Card card=game.getCard(target.getFirstTarget());
    if (card != null) {
      game.informPlayers("String_Node_Str" + GameLog.getColoredObjectName(card) + ']');
      Permanent sourcePermanent=game.getPermanent(source.getSourceId());
      if (sourcePermanent != null) {
        sourcePermanent.addInfo("String_Node_Str",CardUtil.addToolTipMarkTags("String_Node_Str" + card.getName()),game);
      }
      game.addEffect(new AlhammarretHighArbiterCantCastEffect(card.getName()),source);
    }
    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) {
    Cards revealedCards=new CardsImpl();
    for (    UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
      if (!Objects.equals(playerId,controller.getId())) {
        Player opponent=game.getPlayer(playerId);
        if (opponent != null) {
          Cards cards=new CardsImpl(opponent.getHand());
          opponent.revealCards(opponent.getName() + "String_Node_Str",cards,game);
          revealedCards.addAll(cards);
        }
      }
    }
    TargetCard target=new TargetCard(Zone.HAND,new FilterNonlandCard("String_Node_Str"));
    controller.chooseTarget(Outcome.Benefit,revealedCards,target,source,game);
    Card card=game.getCard(target.getFirstTarget());
    if (card != null) {
      game.informPlayers("String_Node_Str" + GameLog.getColoredObjectName(card) + ']');
      Permanent sourcePermanent=game.getPermanent(source.getSourceId());
      if (sourcePermanent != null) {
        sourcePermanent.addInfo("String_Node_Str",CardUtil.addToolTipMarkTags("String_Node_Str" + card.getName()),game);
      }
      game.addEffect(new AlhammarretHighArbiterCantCastEffect(card.getName()),source);
    }
    return true;
  }
  return false;
}
Program: 158132
Project: 158132
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 : 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;
}

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 (!Objects.equals(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: 158133
Project: 158133
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  Permanent blocker=game.getPermanent(event.getSourceId());
  Permanent blocked=game.getPermanent(event.getTargetId());
  Permanent arrogantBloodlord=game.getPermanent(sourceId);
  if (blocker != null && blocker != arrogantBloodlord && blocker.getPower().getValue() < 2 && blocked == arrogantBloodlord) {
    return true;
  }
  if (blocker != null && blocker == arrogantBloodlord && game.getPermanent(event.getTargetId()).getPower().getValue() < 2) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  Permanent blocker=game.getPermanent(event.getSourceId());
  Permanent blocked=game.getPermanent(event.getTargetId());
  Permanent arrogantBloodlord=game.getPermanent(sourceId);
  if (blocker != null && !Objects.equals(blocker,arrogantBloodlord) && blocker.getPower().getValue() < 2 && Objects.equals(blocked,arrogantBloodlord)) {
    return true;
  }
  if (blocker != null && Objects.equals(blocker,arrogantBloodlord) && game.getPermanent(event.getTargetId()).getPower().getValue() < 2) {
    return true;
  }
  return false;
}
Program: 158134
Project: 158134
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  Permanent permanent=game.getPermanent(getSourceId());
  if (permanent != null && permanent.isAttacking()) {
    UUID sourceDefenderId=game.getCombat().getDefenderId(permanent.getId());
    Player attackedPlayer=game.getPlayer(sourceDefenderId);
    if (attackedPlayer != null) {
      for (      UUID attacker : game.getCombat().getAttackers()) {
        if (attacker != permanent.getId()) {
          UUID defenderId=game.getCombat().getDefenderId(attacker);
          Player attackedPlayer2=game.getPlayer(defenderId);
          if (attackedPlayer2 != null && attackedPlayer.getId().equals(attackedPlayer2.getId())) {
            return true;
          }
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  Permanent permanent=game.getPermanent(getSourceId());
  if (permanent != null && permanent.isAttacking()) {
    UUID sourceDefenderId=game.getCombat().getDefenderId(permanent.getId());
    Player attackedPlayer=game.getPlayer(sourceDefenderId);
    if (attackedPlayer != null) {
      for (      UUID attacker : game.getCombat().getAttackers()) {
        if (!Objects.equals(attacker,permanent.getId())) {
          UUID defenderId=game.getCombat().getDefenderId(attacker);
          Player attackedPlayer2=game.getPlayer(defenderId);
          if (attackedPlayer2 != null && attackedPlayer.getId().equals(attackedPlayer2.getId())) {
            return true;
          }
        }
      }
    }
  }
  return false;
}
Program: 158135
Project: 158135
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  Permanent land=game.getPermanent(event.getTargetId());
  return land.getCardType().contains(CardType.LAND) && land.getControllerId().equals(this.controllerId) && event.getTargetId() != this.getSourceId();
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  Permanent land=game.getPermanent(event.getTargetId());
  return land.getCardType().contains(CardType.LAND) && land.getControllerId().equals(this.controllerId) && !Objects.equals(event.getTargetId(),this.getSourceId());
}