nus-yam/ex-repair huggingface dataset:
Program: 159840
Project: 159840
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Integer amountLifeGained=(Integer)this.getValue("String_Node_Str");
  if (amountLifeGained != null) {
    for (    UUID opponentId : game.getOpponents(source.getControllerId())) {
      Player opponent=game.getPlayer(opponentId);
      if (opponent != null) {
        opponent.damage(amountLifeGained,source.getSourceId(),game,false,true);
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Integer amountLifeGained=(Integer)this.getValue("String_Node_Str");
  if (amountLifeGained != null) {
    for (    UUID opponentId : game.getOpponents(source.getControllerId())) {
      Player opponent=game.getPlayer(opponentId);
      if (opponent != null) {
        opponent.loseLife(amountLifeGained,game);
      }
    }
  }
  return false;
}
Program: 159841
Project: 159841
Buggy source:
@Override public UlvenwaldTracker copy(){
  return new UlvenwaldTracker(this);
}

Fixed version (ground truth):
@Override public TargetOtherCreaturePermanent copy(){
  return new TargetOtherCreaturePermanent(this);
}
Program: 159842
Project: 159842
Buggy source:
@Override public BloodFeud copy(){
  return new BloodFeud(this);
}

Fixed version (ground truth):
@Override public TargetOtherCreaturePermanent copy(){
  return new TargetOtherCreaturePermanent(this);
}
Program: 159843
Project: 159843
Buggy source:
@Override public PitFight copy(){
  return new PitFight(this);
}

Fixed version (ground truth):
@Override public TargetOtherCreaturePermanent copy(){
  return new TargetOtherCreaturePermanent(this);
}
Program: 159844
Project: 159844
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Permanent creature1=game.getPermanent(source.getTargets().get(0).getFirstTarget());
  Permanent creature2=game.getPermanent(source.getTargets().get(1).getFirstTarget());
  if (creature1 != null && creature2 != null) {
    if (creature1.getCardType().contains(CardType.CREATURE) && creature2.getCardType().contains(CardType.CREATURE)) {
      creature1.damage(creature2.getPower().getValue(),creature2.getId(),game,true,false);
      creature2.damage(creature1.getPower().getValue(),creature1.getId(),game,true,false);
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Card card=game.getCard(source.getSourceId());
  if (card != null) {
    if (source.getTargets().get(0).isLegal(source,game) && source.getTargets().get(1).isLegal(source,game)) {
      Permanent creature1=game.getPermanent(source.getTargets().get(0).getFirstTarget());
      Permanent creature2=game.getPermanent(source.getTargets().get(1).getFirstTarget());
      if (creature1 != null && creature2 != null) {
        if (creature1.getCardType().contains(CardType.CREATURE) && creature2.getCardType().contains(CardType.CREATURE)) {
          creature1.damage(creature2.getPower().getValue(),creature2.getId(),game,true,false);
          creature2.damage(creature1.getPower().getValue(),creature1.getId(),game,true,false);
          return true;
        }
      }
    }
    game.informPlayers(card.getName() + "String_Node_Str");
  }
  return false;
}
Program: 159845
Project: 159845
Buggy source:
public Zone getZone(UUID id){
  if (id != null && zones.containsKey(id))   return zones.get(id);
  return null;
}

Fixed version (ground truth):
public Zone getZone(UUID id){
  if (id != null && zones.containsKey(id)) {
    return zones.get(id);
  }
  return null;
}
Program: 159846
Project: 159846
Buggy source:
public PlayerList getPlayerList(UUID playerId){
  PlayerList newPlayerList=new PlayerList();
  for (  Player player : players.values()) {
    if (!player.hasLeft() && !player.hasLost())     newPlayerList.add(player.getId());
  }
  newPlayerList.setCurrent(playerId);
  return newPlayerList;
}

Fixed version (ground truth):
public PlayerList getPlayerList(UUID playerId){
  PlayerList newPlayerList=new PlayerList();
  for (  Player player : players.values()) {
    if (!player.hasLeft() && !player.hasLost()) {
      newPlayerList.add(player.getId());
    }
  }
  newPlayerList.setCurrent(playerId);
  return newPlayerList;
}
Program: 159847
Project: 159847
Buggy source:
public List<TriggeredAbility> getTriggered(UUID controllerId){
  List<TriggeredAbility> triggereds=new ArrayList<TriggeredAbility>();
  for (  TriggeredAbility ability : triggered) {
    if (ability.getControllerId().equals(controllerId))     triggereds.add(ability);
  }
  return triggereds;
}

Fixed version (ground truth):
public List<TriggeredAbility> getTriggered(UUID controllerId){
  List<TriggeredAbility> triggereds=new ArrayList<TriggeredAbility>();
  for (  TriggeredAbility ability : triggered) {
    if (ability.getControllerId().equals(controllerId)) {
      triggereds.add(ability);
    }
  }
  return triggereds;
}
Program: 159848
Project: 159848
Buggy source:
public GameState(final GameState state){
  this.players=state.players.copy();
  this.playerList=state.playerList.copy();
  this.activePlayerId=state.activePlayerId;
  this.priorityPlayerId=state.priorityPlayerId;
  this.turn=state.turn.copy();
  this.stack=state.stack.copy();
  this.command=state.command.copy();
  this.exile=state.exile.copy();
  this.revealed=state.revealed.copy();
  this.lookedAt.putAll(state.lookedAt);
  this.battlefield=state.battlefield.copy();
  this.turnNum=state.turnNum;
  this.gameOver=state.gameOver;
  this.effects=state.effects.copy();
  for (  TriggeredAbility trigger : state.triggered) {
    this.triggered.add(trigger.copy());
  }
  this.triggers=state.triggers.copy();
  this.delayed=state.delayed.copy();
  this.specialActions=state.specialActions.copy();
  this.combat=state.combat.copy();
  this.turnMods=state.turnMods.copy();
  this.watchers=state.watchers.copy();
  this.values.putAll(state.values);
  this.zones.putAll(state.zones);
  for (  Map.Entry<UUID,Abilities<ActivatedAbility>> entry : state.otherAbilities.entrySet()) {
    otherAbilities.put(entry.getKey(),entry.getValue().copy());
  }
  this.paused=state.paused;
}

Fixed version (ground truth):
public GameState(final GameState state){
  this.players=state.players.copy();
  this.playerList=state.playerList.copy();
  this.activePlayerId=state.activePlayerId;
  this.priorityPlayerId=state.priorityPlayerId;
  this.turn=state.turn.copy();
  this.stack=state.stack.copy();
  this.command=state.command.copy();
  this.exile=state.exile.copy();
  this.revealed=state.revealed.copy();
  this.lookedAt.putAll(state.lookedAt);
  this.battlefield=state.battlefield.copy();
  this.turnNum=state.turnNum;
  this.gameOver=state.gameOver;
  this.effects=state.effects.copy();
  for (  TriggeredAbility trigger : state.triggered) {
    this.triggered.add(trigger.copy());
  }
  this.triggers=state.triggers.copy();
  this.delayed=state.delayed.copy();
  this.specialActions=state.specialActions.copy();
  this.combat=state.combat.copy();
  this.turnMods=state.turnMods.copy();
  this.watchers=state.watchers.copy();
  for (  Map.Entry<String,Object> entry : state.values.entrySet()) {
    if (entry.getValue() instanceof Boolean) {
      this.values.put(entry.getKey(),Boolean.valueOf(((Boolean)entry.getValue()).toString()));
    }
 else {
      this.values.put(entry.getKey(),entry.getValue());
    }
  }
  this.zones.putAll(state.zones);
  for (  Map.Entry<UUID,Abilities<ActivatedAbility>> entry : state.otherAbilities.entrySet()) {
    otherAbilities.put(entry.getKey(),entry.getValue().copy());
  }
  this.paused=state.paused;
}
Program: 159849
Project: 159849
Buggy source:
/** 
 * Try to attack alone
 */
@Test public void testCantAttackAlone(){
  addCard(Constants.Zone.BATTLEFIELD,playerB,"String_Node_Str");
  addCard(Constants.Zone.BATTLEFIELD,playerB,"String_Node_Str");
  attack(2,playerB,"String_Node_Str");
  setStopAt(2,Constants.PhaseStep.END_TURN);
  execute();
  assertLife(playerA,20);
  Permanent moggFlunkies=getPermanent("String_Node_Str",playerB.getId());
  Assert.assertTrue("String_Node_Str",moggFlunkies.isTapped());
}

Fixed version (ground truth):
/** 
 * Try to attack alone
 */
@Test public void testCantAttackAlone(){
  addCard(Constants.Zone.BATTLEFIELD,playerB,"String_Node_Str");
  addCard(Constants.Zone.BATTLEFIELD,playerB,"String_Node_Str");
  attack(2,playerB,"String_Node_Str");
  setStopAt(2,Constants.PhaseStep.END_TURN);
  execute();
  assertLife(playerA,20);
  Permanent moggFlunkies=getPermanent("String_Node_Str",playerB.getId());
  Assert.assertFalse("String_Node_Str",moggFlunkies.isTapped());
}
Program: 159851
Project: 159851
Buggy source:
public static synchronized String replaceSymbolsWithHTML(String value,Type type){
  value=value.replace("String_Node_Str","String_Node_Str");
  value=value.replace("String_Node_Str","String_Node_Str");
  String replaced=value;
  if (!manaImages.isEmpty()) {
    if (type.equals(Type.TOOLTIP)) {
      replaced=replaceSymbolsPattern.matcher(value).replaceAll("String_Node_Str");
    }
 else     if (type.equals(Type.CARD)) {
      value=value.replace("String_Node_Str","String_Node_Str");
      replaced=replaceSymbolsPattern.matcher(value).replaceAll("String_Node_Str");
    }
 else     if (type.equals(Type.PAY)) {
      value=value.replace("String_Node_Str","String_Node_Str");
      replaced=replaceSymbolsPattern.matcher(value).replaceAll("String_Node_Str");
    }
  }
  replaced=replaced.replace("String_Node_Str","String_Node_Str");
  replaced=replaced.replace("String_Node_Str","String_Node_Str");
  return replaced;
}

Fixed version (ground truth):
public static synchronized String replaceSymbolsWithHTML(String value,Type type){
  value=value.replace("String_Node_Str","String_Node_Str");
  value=value.replace("String_Node_Str","String_Node_Str");
  String replaced=value;
  if (!manaImages.isEmpty()) {
    if (type.equals(Type.TOOLTIP)) {
      replaced=replaceSymbolsPattern.matcher(value).replaceAll("String_Node_Str" + getSymbolsPath(true) + "String_Node_Str");
    }
 else     if (type.equals(Type.CARD)) {
      value=value.replace("String_Node_Str","String_Node_Str" + getSymbolsPath() + "String_Node_Str");
      replaced=replaceSymbolsPattern.matcher(value).replaceAll("String_Node_Str" + getSymbolsPath(true) + "String_Node_Str");
    }
 else     if (type.equals(Type.PAY)) {
      value=value.replace("String_Node_Str","String_Node_Str" + getSymbolsPath() + "String_Node_Str");
      replaced=replaceSymbolsPattern.matcher(value).replaceAll("String_Node_Str" + getSymbolsPath(true) + "String_Node_Str");
    }
  }
  replaced=replaced.replace("String_Node_Str","String_Node_Str");
  replaced=replaced.replace("String_Node_Str","String_Node_Str");
  System.out.println(replaced);
  return replaced;
}
Program: 159852
Project: 159852
Buggy source:
public static String replaceSetCodeWithHTML(String set,String rarity){
  String _set=set;
  if (setImagesExist.containsKey(_set)) {
    Integer width=setImagesExist.get(_set).width;
    Integer height=setImagesExist.get(_set).height;
    return "String_Node_Str" + _set + "String_Node_Str"+ rarity+ "String_Node_Str"+ rarity+ "String_Node_Str"+ width+ "String_Node_Str"+ height+ "String_Node_Str";
  }
 else {
    return set;
  }
}

Fixed version (ground truth):
public static String replaceSetCodeWithHTML(String set,String rarity){
  String _set=set;
  if (setImagesExist.containsKey(_set)) {
    Integer width=setImagesExist.get(_set).width;
    Integer height=setImagesExist.get(_set).height;
    return "String_Node_Str" + getSymbolsPath() + "String_Node_Str"+ _set+ "String_Node_Str"+ rarity+ "String_Node_Str"+ rarity+ "String_Node_Str"+ width+ "String_Node_Str"+ height+ "String_Node_Str";
  }
 else {
    return set;
  }
}
Program: 159854
Project: 159854
Buggy source:
@Override public String getText(){
  if (this.size() == 0)   return "String_Node_Str";
  StringBuilder sbText=new StringBuilder();
  for (  ManaCost cost : this) {
    sbText.append(cost.getText());
  }
  return sbText.toString();
}

Fixed version (ground truth):
@Override public String getText(){
  if (this.size() == 0)   return "String_Node_Str";
  StringBuilder sbText=new StringBuilder();
  for (  ManaCost cost : this) {
    if (cost instanceof GenericManaCost) {
      sbText.append(cost.getText());
    }
  }
  for (  ManaCost cost : this) {
    if (!(cost instanceof GenericManaCost)) {
      sbText.append(cost.getText());
    }
  }
  return sbText.toString();
}
Program: 159855
Project: 159855
Buggy source:
public void sizePlayer(boolean smallMode){
  this.playerPanel.sizePlayerPanel(smallMode);
  if (smallMode) {
    this.playerPanel.setPreferredSize(new Dimension(92,PANEL_HEIGHT_SMALL));
    this.battlefieldPanel.setPreferredSize(new Dimension(160,PANEL_HEIGHT_SMALL));
  }
 else {
    this.playerPanel.setPreferredSize(new Dimension(92,PANEL_HEIGHT));
    this.battlefieldPanel.setPreferredSize(new Dimension(160,PANEL_HEIGHT));
  }
}

Fixed version (ground truth):
public void sizePlayer(boolean smallMode){
  this.playerPanel.sizePlayerPanel(smallMode);
  this.smallMode=smallMode;
  if (smallMode) {
    this.playerPanel.setPreferredSize(new Dimension(92,PANEL_HEIGHT_SMALL));
    this.battlefieldPanel.setPreferredSize(new Dimension(160,PANEL_HEIGHT_SMALL));
  }
 else {
    this.playerPanel.setPreferredSize(new Dimension(92,PANEL_HEIGHT));
    this.battlefieldPanel.setPreferredSize(new Dimension(160,PANEL_HEIGHT));
  }
}
Program: 159856
Project: 159856
Buggy source:
public void sizePlayerPanel(boolean smallMode){
  if (smallMode) {
    avatar.setVisible(false);
    btnPlayer.setVisible(true);
    panelBackground.setPreferredSize(new Dimension(PANEL_WIDTH - 2,PANEL_HEIGHT_SMALL));
    panelBackground.setBounds(0,0,PANEL_WIDTH - 2,PANEL_HEIGHT_SMALL);
  }
 else {
    avatar.setVisible(true);
    btnPlayer.setVisible(false);
    panelBackground.setPreferredSize(new Dimension(PANEL_WIDTH - 2,PANEL_HEIGHT));
    panelBackground.setBounds(0,0,PANEL_WIDTH - 2,PANEL_HEIGHT);
  }
}

Fixed version (ground truth):
protected void sizePlayerPanel(boolean smallMode){
  if (smallMode) {
    avatar.setVisible(false);
    btnPlayer.setVisible(true);
    panelBackground.setPreferredSize(new Dimension(PANEL_WIDTH - 2,PANEL_HEIGHT_SMALL));
    panelBackground.setBounds(0,0,PANEL_WIDTH - 2,PANEL_HEIGHT_SMALL);
  }
 else {
    avatar.setVisible(true);
    btnPlayer.setVisible(false);
    panelBackground.setPreferredSize(new Dimension(PANEL_WIDTH - 2,PANEL_HEIGHT));
    panelBackground.setBounds(0,0,PANEL_WIDTH - 2,PANEL_HEIGHT);
  }
}
Program: 159859
Project: 159859
Buggy source:
public StackAbilityView(StackAbility ability,String sourceName,CardView sourceCard){
  this.id=ability.getId();
  this.name="String_Node_Str";
  this.sourceName=sourceName;
  this.sourceCard=sourceCard;
  this.rules=new ArrayList<String>();
  rules.add(ability.getRule(sourceName));
  this.power=ability.getPower().toString();
  this.toughness=ability.getToughness().toString();
  this.loyalty="String_Node_Str";
  this.cardTypes=ability.getCardType();
  this.subTypes=ability.getSubtype();
  this.superTypes=ability.getSupertype();
  this.color=ability.getColor();
  this.manaCost=ability.getManaCost().getSymbols();
  updateTargets(ability);
}

Fixed version (ground truth):
public StackAbilityView(Game game,StackAbility ability,String sourceName,CardView sourceCard){
  this.id=ability.getId();
  this.name="String_Node_Str";
  this.sourceName=sourceName;
  this.sourceCard=sourceCard;
  this.rules=new ArrayList<String>();
  rules.add(ability.getRule(sourceName));
  this.power=ability.getPower().toString();
  this.toughness=ability.getToughness().toString();
  this.loyalty="String_Node_Str";
  this.cardTypes=ability.getCardType();
  this.subTypes=ability.getSubtype();
  this.superTypes=ability.getSupertype();
  this.color=ability.getColor();
  this.manaCost=ability.getManaCost().getSymbols();
  updateTargets(game,ability);
}
Program: 159860
Project: 159860
Buggy source:
private void updateTargets(StackAbility ability){
  if (ability.getTargets().size() > 0) {
    setTargets(ability.getTargets());
  }
 else {
    List<UUID> targetList=new ArrayList<UUID>();
    for (    Effect effect : ability.getEffects()) {
      TargetPointer targetPointer=effect.getTargetPointer();
      if (targetPointer instanceof FixedTarget) {
        targetList.add(((FixedTarget)targetPointer).getTarget());
      }
    }
    if (targetList.size() > 0) {
      overrideTargets(targetList);
    }
  }
}

Fixed version (ground truth):
private void updateTargets(Game game,StackAbility ability){
  if (ability.getTargets().size() > 0) {
    setTargets(ability.getTargets());
  }
 else {
    List<UUID> targetList=new ArrayList<UUID>();
    for (    Effect effect : ability.getEffects()) {
      TargetPointer targetPointer=effect.getTargetPointer();
      if (targetPointer instanceof FixedTarget) {
        targetList.add(((FixedTarget)targetPointer).getTarget());
      }
    }
    if (targetList.size() > 0) {
      overrideTargets(targetList);
      List<String> names=new ArrayList<String>();
      for (      UUID uuid : targetList) {
        MageObject mageObject=game.getObject(uuid);
        if (mageObject != null) {
          names.add(mageObject.getName());
        }
      }
      if (!names.isEmpty()) {
        getRules().add("String_Node_Str" + names.toString() + "String_Node_Str");
      }
    }
  }
}
Program: 159861
Project: 159861
Buggy source:
@Override public boolean applies(UUID sourceId,Ability source,Game game){
  Card card=game.getCard(sourceId);
  if (card != null) {
    if (!card.getCardType().contains(CardType.LAND) && card.getOwnerId().equals(source.getControllerId())) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(UUID sourceId,Ability source,Game game){
  Card card=game.getCard(sourceId);
  if (card != null) {
    if (!card.getCardType().contains(CardType.LAND) && card.getOwnerId().equals(source.getControllerId())) {
      return card.getSpellAbility().isInUseableZone(game,card,false);
    }
  }
  return false;
}
Program: 159863
Project: 159863
Buggy source:
@Override public boolean isInactive(Ability source,Game game){
  if (game.getPhase().getStep().getType() == Constants.PhaseStep.UNTAP && game.getStep().getStepPart() == Step.StepPart.PRE) {
    if (game.getActivePlayerId().equals(source.getControllerId())) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean isInactive(Ability source,Game game){
  if (game.getPhase().getStep().getType() == PhaseStep.UNTAP && game.getStep().getStepPart() == Step.StepPart.PRE) {
    if (game.getActivePlayerId().equals(source.getControllerId())) {
      return true;
    }
  }
  return false;
}
Program: 159864
Project: 159864
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED) {
    Permanent attacker=game.getPermanent(event.getSourceId());
    Player defender=game.getPlayer(event.getTargetId());
    Player you=game.getPlayer(controllerId);
    if (attacker.getControllerId() != you.getId() && defender == you) {
      for (      Effect effect : getEffects()) {
        effect.setTargetPointer(new FixedTarget(attacker.getId()));
      }
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED) {
    if (game.getOpponents(getControllerId()).contains(event.getPlayerId())) {
      for (      Effect effect : getEffects()) {
        effect.setTargetPointer(new FixedTarget(event.getSourceId()));
      }
      return true;
    }
  }
  return false;
}
Program: 159865
Project: 159865
Buggy source:
public AureliasFuryDamagedByWatcher(final AureliasFuryDamagedByWatcher watcher){
  super(watcher);
  this.damagedCreatures=watcher.damagedCreatures;
  this.damagedPlayers=watcher.damagedPlayers;
}

Fixed version (ground truth):
public AureliasFuryDamagedByWatcher(final AureliasFuryDamagedByWatcher watcher){
  super(watcher);
  this.damagedCreatures.addAll(watcher.damagedCreatures);
  this.damagedPlayers.addAll(watcher.damagedPlayers);
}
Program: 159866
Project: 159866
Buggy source:
public BlockedByWatcher(final BlockedByWatcher watcher){
  super(watcher);
  this.blockedByWatcher=watcher.blockedByWatcher;
}

Fixed version (ground truth):
public BlockedByWatcher(final BlockedByWatcher watcher){
  super(watcher);
  this.blockedByWatcher.addAll(watcher.blockedByWatcher);
}
Program: 159867
Project: 159867
Buggy source:
public FaithsRewardWatcher(final FaithsRewardWatcher watcher){
  super(watcher);
  this.cards=(ArrayList<UUID>)watcher.cards.clone();
}

Fixed version (ground truth):
public FaithsRewardWatcher(final FaithsRewardWatcher watcher){
  super(watcher);
  this.cards.addAll(watcher.cards);
}
Program: 159868
Project: 159868
Buggy source:
public CathedralMembraneWatcher(final CathedralMembraneWatcher watcher){
  super(watcher);
  this.blockedCreatures=watcher.blockedCreatures;
}

Fixed version (ground truth):
public CathedralMembraneWatcher(final CathedralMembraneWatcher watcher){
  super(watcher);
  this.blockedCreatures.addAll(watcher.blockedCreatures);
}
Program: 159869
Project: 159869
Buggy source:
public SteelHellkiteWatcher(final SteelHellkiteWatcher watcher){
  super(watcher);
  for (  UUID playerId : watcher.damagedPlayers) {
    damagedPlayers.add(playerId);
  }
}

Fixed version (ground truth):
public SteelHellkiteWatcher(final SteelHellkiteWatcher watcher){
  super(watcher);
  damagedPlayers.addAll(watcher.damagedPlayers);
}
Program: 159870
Project: 159870
Buggy source:
public CardsDrawnControllerWatcher(final CardsDrawnControllerWatcher watcher){
  super(watcher);
}

Fixed version (ground truth):
public CardsDrawnControllerWatcher(final CardsDrawnControllerWatcher watcher){
  super(watcher);
  this.cardsDrawn=watcher.cardsDrawn;
}
Program: 159871
Project: 159871
Buggy source:
public BlockedByWatcher(final BlockedByWatcher watcher){
  super(watcher);
  this.blockedByWatcher=watcher.blockedByWatcher;
}

Fixed version (ground truth):
public BlockedByWatcher(final BlockedByWatcher watcher){
  super(watcher);
  this.blockedByWatcher.addAll(watcher.blockedByWatcher);
}
Program: 159872
Project: 159872
Buggy source:
public CardsDrawnOpponentWatcher(final CardsDrawnOpponentWatcher watcher){
  super(watcher);
}

Fixed version (ground truth):
public CardsDrawnOpponentWatcher(final CardsDrawnOpponentWatcher watcher){
  super(watcher);
  this.cardsDrawn=watcher.cardsDrawn;
}
Program: 159873
Project: 159873
Buggy source:
public AttackedThisTurnWatcher(final AttackedThisTurnWatcher watcher){
  super(watcher);
  this.attackedThisTurnCreatures=watcher.attackedThisTurnCreatures;
}

Fixed version (ground truth):
public AttackedThisTurnWatcher(final AttackedThisTurnWatcher watcher){
  super(watcher);
  this.attackedThisTurnCreatures.addAll(watcher.attackedThisTurnCreatures);
}
Program: 159874
Project: 159874
Buggy source:
public DamagedByWatcher(final DamagedByWatcher watcher){
  super(watcher);
  this.damagedCreatures=watcher.damagedCreatures;
}

Fixed version (ground truth):
public DamagedByWatcher(final DamagedByWatcher watcher){
  super(watcher);
  this.damagedCreatures.addAll(watcher.damagedCreatures);
}
Program: 159875
Project: 159875
Buggy source:
public PlayerDamagedBySourceWatcher(final PlayerDamagedBySourceWatcher watcher){
  super(watcher);
  this.damageSources=watcher.damageSources;
}

Fixed version (ground truth):
public PlayerDamagedBySourceWatcher(final PlayerDamagedBySourceWatcher watcher){
  super(watcher);
  this.damageSources.addAll(watcher.damageSources);
}
Program: 159876
Project: 159876
Buggy source:
public SourceDidDamageWatcher(final SourceDidDamageWatcher watcher){
  super(watcher);
  this.damageSources=watcher.damageSources;
}

Fixed version (ground truth):
public SourceDidDamageWatcher(final SourceDidDamageWatcher watcher){
  super(watcher);
  this.damageSources.addAll(watcher.damageSources);
}
Program: 159877
Project: 159877
Buggy source:
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Permanent target=game.getPermanent(event.getTargetId());
  if (target != null) {
    target.setTapped(true);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Permanent target=game.getPermanent(event.getTargetId());
  if (target != null) {
    target.setTapped(true);
  }
  return false;
}
Program: 159879
Project: 159879
Buggy source:
@Override public void addCounters(Counter counter,Game game,ArrayList<UUID> appliedEffects){
  GameEvent event=GameEvent.getEvent(GameEvent.EventType.ADD_COUNTER,objectId,ownerId,counter.getName(),counter.getCount());
  event.setAppliedEffects(appliedEffects);
  if (!game.replaceEvent(event)) {
    counters.addCounter(counter);
    game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER_ADDED,objectId,ownerId,counter.getName(),counter.getCount()));
  }
}

Fixed version (ground truth):
@Override public void addCounters(Counter counter,Game game,ArrayList<UUID> appliedEffects){
  int amount=counter.getCount();
  for (int i=0; i < amount; i++) {
    Counter eventCounter=counter.copy();
    eventCounter.remove(amount - 1);
    GameEvent event=GameEvent.getEvent(GameEvent.EventType.ADD_COUNTER,objectId,ownerId,counter.getName(),counter.getCount());
    event.setAppliedEffects(appliedEffects);
    if (!game.replaceEvent(event)) {
      counters.addCounter(eventCounter);
      game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER_ADDED,objectId,ownerId,counter.getName(),counter.getCount()));
    }
  }
}
Program: 159880
Project: 159880
Buggy source:
@Override public void addCounters(Counter counter,Game game,ArrayList<UUID> appliedEffects){
  GameEvent event=GameEvent.getEvent(GameEvent.EventType.ADD_COUNTER,objectId,controllerId,counter.getName(),counter.getCount());
  event.setAppliedEffects(appliedEffects);
  if (!game.replaceEvent(event)) {
    counters.addCounter(counter);
    game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER_ADDED,objectId,controllerId,counter.getName(),counter.getCount()));
  }
}

Fixed version (ground truth):
@Override public void addCounters(Counter counter,Game game,ArrayList<UUID> appliedEffects){
  int amount=counter.getCount();
  for (int i=0; i < amount; i++) {
    Counter eventCounter=counter.copy();
    eventCounter.remove(amount - 1);
    GameEvent event=GameEvent.getEvent(GameEvent.EventType.ADD_COUNTER,objectId,controllerId,counter.getName(),1);
    event.setAppliedEffects(appliedEffects);
    if (!game.replaceEvent(event)) {
      counters.addCounter(eventCounter);
      game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER_ADDED,objectId,controllerId,counter.getName(),1));
    }
  }
}
Program: 159881
Project: 159881
Buggy source:
@Override public void addCounters(Counter counter,Game game){
  if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.ADD_COUNTER,playerId,playerId,counter.getName(),counter.getCount()))) {
    counters.addCounter(counter);
    game.fireEvent(GameEvent.getEvent(EventType.COUNTER_ADDED,playerId,playerId,counter.getName(),counter.getCount()));
  }
}

Fixed version (ground truth):
@Override public void addCounters(Counter counter,Game game){
  int amount=counter.getCount();
  for (int i=0; i < amount; i++) {
    Counter eventCounter=counter.copy();
    eventCounter.remove(amount - 1);
    if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.ADD_COUNTER,playerId,playerId,counter.getName(),counter.getCount()))) {
      counters.addCounter(eventCounter);
      game.fireEvent(GameEvent.getEvent(EventType.COUNTER_ADDED,playerId,playerId,counter.getName(),counter.getCount()));
    }
  }
}
Program: 159882
Project: 159882
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Permanent permanent=game.getPermanent(this.sourceId);
  if (permanent == null) {
    return false;
  }
  permanent.setName(target.getName());
  permanent.getColor().setColor(target.getColor());
  permanent.getManaCost().clear();
  permanent.getManaCost().add(target.getManaCost());
  permanent.getCardType().clear();
  for (  CardType type : target.getCardType()) {
    permanent.getCardType().add(type);
  }
  permanent.getSubtype().clear();
  for (  String type : target.getSubtype()) {
    permanent.getSubtype().add(type);
  }
  permanent.getSupertype().clear();
  for (  String type : target.getSupertype()) {
    permanent.getSupertype().add(type);
  }
  permanent.getAbilities().clear();
  for (  Ability ability : target.getAbilities()) {
    permanent.addAbility(ability,game);
  }
  permanent.getPower().setValue(target.getPower().getValue());
  permanent.getToughness().setValue(target.getToughness().getValue());
  if (target instanceof Permanent) {
    permanent.setTransformed(((Permanent)target).isTransformed());
    permanent.setSecondCardFace(((Permanent)target).getSecondCardFace());
  }
  permanent.setCopy(true);
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Permanent permanent=game.getPermanent(this.sourceId);
  if (permanent == null) {
    return false;
  }
  permanent.setName(target.getName());
  permanent.getColor().setColor(target.getColor());
  permanent.getManaCost().clear();
  permanent.getManaCost().add(target.getManaCost());
  permanent.getCardType().clear();
  for (  CardType type : target.getCardType()) {
    permanent.getCardType().add(type);
  }
  permanent.getSubtype().clear();
  for (  String type : target.getSubtype()) {
    permanent.getSubtype().add(type);
  }
  permanent.getSupertype().clear();
  for (  String type : target.getSupertype()) {
    permanent.getSupertype().add(type);
  }
  permanent.removeAllAbilities(source.getSourceId(),game);
  for (  Ability ability : target.getAbilities()) {
    permanent.addAbility(ability,game);
  }
  permanent.getPower().setValue(target.getPower().getValue());
  permanent.getToughness().setValue(target.getToughness().getValue());
  if (target instanceof Permanent) {
    permanent.setTransformed(((Permanent)target).isTransformed());
    permanent.setSecondCardFace(((Permanent)target).getSecondCardFace());
  }
  permanent.setCopy(true);
  return true;
}
Program: 159883
Project: 159883
Buggy source:
@Override public DynamicValue copy(){
  return new CardsInAllGraveyardsCount(this);
}

Fixed version (ground truth):
@Override public DynamicValue copy(){
  return new CardsInOpponentGraveyardsCount(this);
}
Program: 159884
Project: 159884
Buggy source:
@Override public int calculate(Game game,Ability sourceAbility){
  int amount=0;
  PlayerList playerList=game.getPlayerList();
  for (  UUID playerUUID : playerList) {
    Player player=game.getPlayer(playerUUID);
    if (player != null) {
      amount+=player.getGraveyard().count(filter,game);
    }
  }
  return amount;
}

Fixed version (ground truth):
@Override public int calculate(Game game,Ability sourceAbility){
  int amount=0;
  for (  UUID playerUUID : game.getOpponents(sourceAbility.getControllerId())) {
    Player player=game.getPlayer(playerUUID);
    if (player != null) {
      amount+=player.getGraveyard().count(filter,sourceAbility.getSourceId(),sourceAbility.getControllerId(),game);
    }
  }
  return amount;
}
Program: 159885
Project: 159885
Buggy source:
@Override public int calculate(Game game,Ability sourceAbility){
  int amount=0;
  PlayerList playerList=game.getPlayerList();
  for (  UUID playerUUID : playerList) {
    Player player=game.getPlayer(playerUUID);
    if (player != null) {
      amount+=player.getGraveyard().count(filter,game);
    }
  }
  return amount;
}

Fixed version (ground truth):
@Override public int calculate(Game game,Ability sourceAbility){
  int amount=0;
  PlayerList playerList=game.getPlayerList();
  for (  UUID playerUUID : playerList) {
    Player player=game.getPlayer(playerUUID);
    if (player != null) {
      amount+=player.getGraveyard().count(filter,sourceAbility.getSourceId(),sourceAbility.getControllerId(),game);
    }
  }
  return amount;
}
Program: 159886
Project: 159886
Buggy source:
/** 
 * Tests third level that gives both Lifelink and Indestructible as well as 9/9
 */
@Test public void testThirdLevel(){
  addCard(Constants.Zone.BATTLEFIELD,playerA,"String_Node_Str");
  addCard(Constants.Zone.BATTLEFIELD,playerA,"String_Node_Str",15);
  for (int i=0; i < 12; i++) {
    activateAbility(1,Constants.PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str");
  }
  setStopAt(2,Constants.PhaseStep.END_TURN);
  execute();
  Permanent master=getPermanent("String_Node_Str",playerA.getId());
  Assert.assertEquals(12,master.getCounters().getCount(CounterType.LEVEL));
  Assert.assertEquals("String_Node_Str",9,master.getPower().getValue());
  Assert.assertEquals("String_Node_Str",9,master.getToughness().getValue());
  Assert.assertTrue(master.getAbilities().contains(LifelinkAbility.getInstance()));
  Assert.assertTrue(master.getAbilities().contains(new IndestructibleAbility()));
}

Fixed version (ground truth):
/** 
 * Tests third level that gives both Lifelink and Indestructible as well as 9/9
 */
@Test public void testThirdLevel(){
  addCard(Constants.Zone.BATTLEFIELD,playerA,"String_Node_Str");
  addCard(Constants.Zone.BATTLEFIELD,playerA,"String_Node_Str",15);
  for (int i=0; i < 12; i++) {
    activateAbility(1,Constants.PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str");
  }
  setStopAt(2,Constants.PhaseStep.END_TURN);
  execute();
  Permanent master=getPermanent("String_Node_Str",playerA.getId());
  Assert.assertEquals(12,master.getCounters().getCount(CounterType.LEVEL));
  Assert.assertEquals("String_Node_Str",9,master.getPower().getValue());
  Assert.assertEquals("String_Node_Str",9,master.getToughness().getValue());
  Assert.assertTrue(master.getAbilities().contains(LifelinkAbility.getInstance()));
  Assert.assertTrue(master.getAbilities().containsRule(new IndestructibleAbility()));
}
Program: 159887
Project: 159887
Buggy source:
/** 
 * Tests that extra counters won't make any effect over third level
 */
@Test public void testExtraCounters(){
  addCard(Constants.Zone.BATTLEFIELD,playerA,"String_Node_Str");
  addCard(Constants.Zone.BATTLEFIELD,playerA,"String_Node_Str",15);
  for (int i=0; i < 15; i++) {
    activateAbility(1,Constants.PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str");
  }
  setStopAt(2,Constants.PhaseStep.END_TURN);
  execute();
  Permanent master=getPermanent("String_Node_Str",playerA.getId());
  Assert.assertEquals(15,master.getCounters().getCount(CounterType.LEVEL));
  Assert.assertEquals("String_Node_Str",9,master.getPower().getValue());
  Assert.assertEquals("String_Node_Str",9,master.getToughness().getValue());
  Assert.assertTrue(master.getAbilities().contains(LifelinkAbility.getInstance()));
  Assert.assertTrue(master.getAbilities().contains(new IndestructibleAbility()));
}

Fixed version (ground truth):
/** 
 * Tests that extra counters won't make any effect over third level
 */
@Test public void testExtraCounters(){
  addCard(Constants.Zone.BATTLEFIELD,playerA,"String_Node_Str");
  addCard(Constants.Zone.BATTLEFIELD,playerA,"String_Node_Str",15);
  for (int i=0; i < 15; i++) {
    activateAbility(1,Constants.PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str");
  }
  setStopAt(2,Constants.PhaseStep.END_TURN);
  execute();
  Permanent master=getPermanent("String_Node_Str",playerA.getId());
  Assert.assertEquals(15,master.getCounters().getCount(CounterType.LEVEL));
  Assert.assertEquals("String_Node_Str",9,master.getPower().getValue());
  Assert.assertEquals("String_Node_Str",9,master.getToughness().getValue());
  Assert.assertTrue(master.getAbilities().contains(LifelinkAbility.getInstance()));
  Assert.assertTrue(master.getAbilities().containsRule(new IndestructibleAbility()));
}
Program: 159889
Project: 159889
Buggy source:
/** 
 * @param player
 * @param cardName
 * @param ability
 * @param flag true if creature should contain ability, false if it should NOT contain it instead
 * @throws AssertionError
 */
public void assertAbility(Player player,String cardName,Ability ability,boolean flag) throws AssertionError {
  int count=0;
  Permanent found=null;
  for (  Permanent permanent : currentGame.getBattlefield().getAllActivePermanents(player.getId())) {
    if (permanent.getName().equals(cardName)) {
      found=permanent;
      count++;
    }
  }
  Assert.assertNotNull("String_Node_Str" + player.getName() + "String_Node_Str"+ cardName,found);
  Assert.assertTrue("String_Node_Str" + player.getName() + "String_Node_Str"+ cardName,count == 1);
  if (flag) {
    Assert.assertTrue("String_Node_Str" + ability.toString() + "String_Node_Str"+ player.getName()+ "String_Node_Str"+ cardName,found.getAbilities().contains(ability));
  }
 else {
    Assert.assertFalse("String_Node_Str" + ability.toString() + "String_Node_Str"+ player.getName()+ "String_Node_Str"+ cardName,found.getAbilities().contains(ability));
  }
}

Fixed version (ground truth):
/** 
 * @param player
 * @param cardName
 * @param ability
 * @param flag true if creature should contain ability, false if it should NOT contain it instead
 * @throws AssertionError
 */
public void assertAbility(Player player,String cardName,Ability ability,boolean flag) throws AssertionError {
  int count=0;
  Permanent found=null;
  for (  Permanent permanent : currentGame.getBattlefield().getAllActivePermanents(player.getId())) {
    if (permanent.getName().equals(cardName)) {
      found=permanent;
      count++;
    }
  }
  Assert.assertNotNull("String_Node_Str" + player.getName() + "String_Node_Str"+ cardName,found);
  Assert.assertTrue("String_Node_Str" + player.getName() + "String_Node_Str"+ cardName,count == 1);
  if (flag) {
    Assert.assertTrue("String_Node_Str" + ability.toString() + "String_Node_Str"+ player.getName()+ "String_Node_Str"+ cardName,found.getAbilities().containsRule(ability));
  }
 else {
    Assert.assertFalse("String_Node_Str" + ability.toString() + "String_Node_Str"+ player.getName()+ "String_Node_Str"+ cardName,found.getAbilities().containsRule(ability));
  }
}
Program: 159890
Project: 159890
Buggy source:
public void actionPerformed(java.awt.event.ActionEvent evt){
  if (linkSpecial != null) {
{
      setState("String_Node_Str",false,"String_Node_Str",false);
      setSpecial("String_Node_Str",false);
      linkSpecial.doClick();
    }
  }
}

Fixed version (ground truth):
@Override public void actionPerformed(java.awt.event.ActionEvent evt){
  if (linkSpecial != null) {
{
      setState("String_Node_Str",false,"String_Node_Str",false);
      setSpecial("String_Node_Str",false);
      linkSpecial.doClick();
    }
  }
}
Program: 159891
Project: 159891
Buggy source:
public void requestFocus(){
  this.btnRight.requestFocus();
}

Fixed version (ground truth):
@Override public void requestFocus(){
  this.btnRight.requestFocus();
}
Program: 159892
Project: 159892
Buggy source:
public void setMessage(String message){
  if (message.startsWith("String_Node_Str")) {
    textArea.setText("String_Node_Str");
  }
 else   if (message.contains("String_Node_Str")) {
    textArea.setText("String_Node_Str");
  }
 else {
    textArea.setText(message);
  }
}

Fixed version (ground truth):
public void setMessage(String message){
  if (message.startsWith("String_Node_Str")) {
    textArea.setText("String_Node_Str");
  }
 else   if (message.length() > 30 && message.contains("String_Node_Str")) {
    textArea.setText("String_Node_Str");
  }
 else {
    textArea.setText(message);
  }
}
Program: 159894
Project: 159894
Buggy source:
private void checkMiracleAbility(GameEvent event,Game game){
  Card card=game.getCard(event.getTargetId());
  if (card != null) {
    for (    Ability ability : card.getAbilities()) {
      if (ability instanceof MiracleAbility) {
        Player controller=game.getPlayer(ability.getControllerId());
        game.getContinuousEffects().costModification(ability,game);
        ManaCosts<ManaCost> manaCostsToPay=ability.getManaCostsToPay();
        if (controller != null) {
          game.getStack().add(new StackAbility(ability,controller.getId()));
          Cards cards=new CardsImpl(Constants.Zone.PICK);
          cards.add(card);
          controller.lookAtCards("String_Node_Str",cards,game);
          if (controller.chooseUse(Constants.Outcome.Benefit,"String_Node_Str" + manaCostsToPay.getText() + "String_Node_Str",game)) {
            game.getStack().poll();
            controller.revealCards("String_Node_Str",cards,game);
            ManaCosts costRef=card.getSpellAbility().getManaCostsToPay();
            costRef.clear();
            for (            ManaCost manaCost : manaCostsToPay) {
              costRef.add(manaCost);
            }
            controller.cast(card.getSpellAbility(),game,false);
            break;
          }
 else {
            game.getStack().poll();
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
private void checkMiracleAbility(GameEvent event,Game game){
  Card card=game.getCard(event.getTargetId());
  if (card != null) {
    for (    Ability ability : card.getAbilities()) {
      if (ability instanceof MiracleAbility) {
        Player controller=game.getPlayer(ability.getControllerId());
        if (controller != null) {
          game.getContinuousEffects().costModification(ability,game);
          ManaCosts<ManaCost> manaCostsToPay=ability.getManaCostsToPay();
          Cards cards=new CardsImpl(Zone.PICK);
          cards.add(card);
          controller.lookAtCards("String_Node_Str",cards,game);
          if (controller.chooseUse(Outcome.Benefit,"String_Node_Str" + manaCostsToPay.getText() + "String_Node_Str",game)) {
            controller.revealCards("String_Node_Str",cards,game);
            ManaCosts costRef=card.getSpellAbility().getManaCostsToPay();
            costRef.clear();
            for (            ManaCost manaCost : manaCostsToPay) {
              costRef.add(manaCost);
            }
            controller.cast(card.getSpellAbility(),game,false);
            break;
          }
        }
      }
    }
  }
}
Program: 159895
Project: 159895
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getControllerId());
  Permanent permanent=game.getPermanent(source.getSourceId());
  if (player != null && permanent != null) {
    for (    Card card : player.getHand().getCards(CastThroughTime.filter,game)) {
      boolean found=false;
      for (      Ability ability : card.getAbilities()) {
        if (ability instanceof ReboundAbility) {
          found=true;
          break;
        }
      }
      if (!found) {
        card.addAbility(new AttachedReboundAbility());
        Ability ability=new AttachedReboundAbility();
        ability.setControllerId(source.getControllerId());
        ability.setSourceId(card.getId());
        game.getState().addAbility(ability,source.getSourceId(),card);
      }
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getControllerId());
  Permanent permanent=game.getPermanent(source.getSourceId());
  if (player != null && permanent != null) {
    for (    Card card : player.getHand().getCards(CastThroughTime.filter,game)) {
      boolean found=false;
      for (      Ability ability : card.getAbilities()) {
        if (ability instanceof ReboundAbility) {
          found=true;
          break;
        }
      }
      if (!found) {
        Ability ability=new AttachedReboundAbility();
        card.addAbility(ability);
        ability.setControllerId(source.getControllerId());
        ability.setSourceId(card.getId());
        game.getState().addAbility(ability,source.getSourceId(),card);
      }
    }
    return true;
  }
  return false;
}
Program: 159896
Project: 159896
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == EventType.ZONE_CHANGE) {
    UUID targetId=event.getTargetId();
    Permanent permanent=game.getPermanent(targetId);
    ZoneChangeEvent zEvent=(ZoneChangeEvent)event;
    if (zEvent.getToZone() == Zone.BATTLEFIELD && permanent.getControllerId().equals(this.controllerId) && (targetId.equals(this.getSourceId()) || (permanent.hasSubtype("String_Node_Str") && !targetId.equals(this.getSourceId())))) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == EventType.ENTERS_THE_BATTLEFIELD) {
    UUID targetId=event.getTargetId();
    Permanent permanent=game.getPermanent(targetId);
    if (permanent.getControllerId().equals(this.controllerId) && (targetId.equals(this.getSourceId()) || (permanent.hasSubtype("String_Node_Str") && !targetId.equals(this.getSourceId())))) {
      return true;
    }
  }
  return false;
}
Program: 159897
Project: 159897
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
    ZoneChangeEvent zEvent=(ZoneChangeEvent)event;
    if (zEvent.getToZone() == Constants.Zone.BATTLEFIELD && zEvent.getTarget().getCardType().contains(Constants.CardType.CREATURE) && zEvent.getTargetId() != this.getSourceId()) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD && event.getTargetId() != this.getSourceId()) {
    Permanent permanent=game.getPermanent(event.getTargetId());
    if (permanent.getCardType().contains(Constants.CardType.CREATURE)) {
      return true;
    }
  }
  return false;
}
Program: 159898
Project: 159898
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == EventType.ZONE_CHANGE) {
    Permanent permanent=game.getPermanent(event.getTargetId());
    if (((ZoneChangeEvent)event).getToZone() == Zone.BATTLEFIELD && filter.match(permanent,sourceId,controllerId,game) && (permanent.getControllerId().equals(this.controllerId) ^ opponentController)) {
      if (!this.getTargets().isEmpty()) {
        Target target=this.getTargets().get(0);
        if (target instanceof TargetPlayer) {
          target.add(permanent.getControllerId(),game);
        }
        if (target instanceof TargetCreaturePermanent) {
          target.add(event.getTargetId(),game);
        }
      }
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == EventType.ENTERS_THE_BATTLEFIELD) {
    Permanent permanent=game.getPermanent(event.getTargetId());
    if (filter.match(permanent,sourceId,controllerId,game) && (permanent.getControllerId().equals(this.controllerId) ^ opponentController)) {
      if (!this.getTargets().isEmpty()) {
        Target target=this.getTargets().get(0);
        if (target instanceof TargetPlayer) {
          target.add(permanent.getControllerId(),game);
        }
        if (target instanceof TargetCreaturePermanent) {
          target.add(event.getTargetId(),game);
        }
      }
      return true;
    }
  }
  return false;
}
Program: 159899
Project: 159899
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.ZONE_CHANGE && !event.getTargetId().equals(this.getSourceId())) {
    ZoneChangeEvent zEvent=(ZoneChangeEvent)event;
    if (zEvent.getToZone() == Constants.Zone.BATTLEFIELD) {
      Permanent permanent=game.getPermanent(event.getTargetId());
      if (permanent != null && permanent.getCardType().contains(Constants.CardType.CREATURE) && permanent.getControllerId().equals(this.getControllerId())) {
        return true;
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD && !event.getTargetId().equals(this.getSourceId())) {
    Permanent permanent=game.getPermanent(event.getTargetId());
    if (permanent != null && permanent.getCardType().contains(Constants.CardType.CREATURE) && permanent.getControllerId().equals(this.getControllerId())) {
      return true;
    }
  }
  return false;
}
Program: 159900
Project: 159900
Buggy source:
public EntersBattlefieldAllTriggeredAbility(EntersBattlefieldAllTriggeredAbility ability){
  super(ability);
}

Fixed version (ground truth):
public EntersBattlefieldAllTriggeredAbility(EntersBattlefieldAllTriggeredAbility ability){
  super(ability);
  this.filter=ability.filter;
  this.rule=ability.rule;
  this.controlled=ability.controlled;
}