nus-yam/ex-repair huggingface dataset:
Program: 159485
Project: 159485
Buggy source:
public void drawCards(SortSetting sortSetting){
  drawCards(sortSetting,false);
}

Fixed version (ground truth):
@Override public void drawCards(SortSetting sortSetting){
  int maxWidth=this.getParent().getWidth();
  int numColumns=maxWidth / Config.dimensions.frameWidth;
  int curColumn=0;
  int curRow=0;
  int landCount=0;
  int creatureCount=0;
  cardArea.removeAll();
  if (cards != null && cards.size() > 0) {
    Rectangle rectangle=new Rectangle(Config.dimensions.frameWidth,Config.dimensions.frameHeight);
    List<CardView> sortedCards=new ArrayList<CardView>(cards.values());
switch (sortSetting.getSortBy()) {
case NAME:
      Collections.sort(sortedCards,new CardViewNameComparator());
    break;
case RARITY:
  Collections.sort(sortedCards,new CardViewRarityComparator());
break;
case COLOR:
Collections.sort(sortedCards,new CardViewColorComparator());
break;
case COLOR_DETAILED:
Collections.sort(sortedCards,new CardViewColorDetailedComparator());
break;
case CASTING_COST:
Collections.sort(sortedCards,new CardViewCostComparator());
break;
}
CardView lastCard=null;
for (CardView card : sortedCards) {
if (sortSetting.isPilesToggle()) {
if (lastCard == null) {
lastCard=card;
}
switch (sortSetting.getSortBy()) {
case NAME:
if (!card.getName().equals(lastCard.getName())) {
curColumn++;
curRow=0;
}
break;
case RARITY:
if (!card.getRarity().equals(lastCard.getRarity())) {
curColumn++;
curRow=0;
}
break;
case COLOR:
if (card.getColor().compareTo(lastCard.getColor()) != 0) {
curColumn++;
curRow=0;
}
break;
case COLOR_DETAILED:
if (card.getColor().hashCode() != lastCard.getColor().hashCode()) {
curColumn++;
curRow=0;
}
break;
case CASTING_COST:
if (card.getConvertedManaCost() != lastCard.getConvertedManaCost()) {
curColumn++;
curRow=0;
}
break;
}
rectangle.setLocation(curColumn * Config.dimensions.frameWidth,curRow * 20);
addCard(card,bigCard,gameId,rectangle);
if (card.getCardTypes().contains(CardType.LAND)) {
landCount++;
}
if (card.getCardTypes().contains(CardType.CREATURE)) {
creatureCount++;
}
curRow++;
lastCard=card;
}
 else {
rectangle.setLocation(curColumn * Config.dimensions.frameWidth,curRow * 20);
addCard(card,bigCard,gameId,rectangle);
if (card.getCardTypes().contains(CardType.LAND)) {
landCount++;
}
if (card.getCardTypes().contains(CardType.CREATURE)) {
creatureCount++;
}
curColumn++;
if (curColumn == numColumns) {
curColumn=0;
curRow++;
}
}
}
}
int count=cards != null ? cards.size() : 0;
this.lblCount.setText("String_Node_Str" + Integer.toString(count));
this.lblCreatureCount.setText("String_Node_Str" + Integer.toString(creatureCount));
this.lblLandCount.setText("String_Node_Str" + Integer.toString(landCount));
cardArea.setPreferredSize(new Dimension(Config.dimensions.frameWidth,Config.dimensions.frameHeight + 200));
cardArea.revalidate();
this.revalidate();
this.repaint();
this.setVisible(true);
}
Program: 159486
Project: 159486
Buggy source:
@Override public void loadCards(CardsView showCards,SortSetting sortSetting,boolean piles,BigCard bigCard,UUID gameId,boolean merge){
  cards=showCards;
  this.bigCard=bigCard;
  this.gameId=gameId;
  drawCards(sortSetting);
}

Fixed version (ground truth):
@Override public void loadCards(CardsView showCards,SortSetting sortSetting,BigCard bigCard,UUID gameId,boolean merge){
  cards=showCards;
  this.bigCard=bigCard;
  this.gameId=gameId;
  drawCards(sortSetting);
}
Program: 159487
Project: 159487
Buggy source:
private void cbSortByActionPerformed(java.awt.event.ActionEvent evt){
  sortSetting.setSortBy((SortBy)cbSortBy.getSelectedItem());
  drawCards(sortSetting,chkPiles.isSelected());
}

Fixed version (ground truth):
private void cbSortByActionPerformed(java.awt.event.ActionEvent evt){
  sortSetting.setSortBy((SortBy)cbSortBy.getSelectedItem());
  drawCards(sortSetting);
}
Program: 159488
Project: 159488
Buggy source:
private void chkPilesActionPerformed(java.awt.event.ActionEvent evt){
  drawCards(sortSetting,chkPiles.isSelected());
  PreferencesDialog.saveValue(PreferencesDialog.KEY_DRAFT_PILES_TOGGLE,(chkPiles.isSelected() ? "String_Node_Str" : "String_Node_Str"));
}

Fixed version (ground truth):
private void chkPilesActionPerformed(java.awt.event.ActionEvent evt){
  sortSetting.setPilesToggle(chkPiles.isSelected());
  drawCards(sortSetting);
}
Program: 159489
Project: 159489
Buggy source:
void drawCards(SortSetting sortSetting,boolean piles);

Fixed version (ground truth):
void drawCards(SortSetting sortSetting);
Program: 159490
Project: 159490
Buggy source:
void loadCards(CardsView showCards,SortSetting sortSetting,boolean piles,BigCard bigCard,UUID gameId,boolean merge);

Fixed version (ground truth):
void loadCards(CardsView showCards,SortSetting sortSetting,BigCard bigCard,UUID gameId,boolean merge);
Program: 159491
Project: 159491
Buggy source:
@Override public void componentMoved(ComponentEvent e){
  if (cbSortBy.getSelectedItem() instanceof SortBy) {
    this.currentView.drawCards(sortSetting,chkPiles.isSelected());
  }
}

Fixed version (ground truth):
@Override public void componentMoved(ComponentEvent e){
  if (cbSortBy.getSelectedItem() instanceof SortBy) {
    this.currentView.drawCards(sortSetting);
  }
}
Program: 159492
Project: 159492
Buggy source:
@Override public void componentHidden(ComponentEvent e){
  if (cbSortBy.getSelectedItem() instanceof SortBy) {
    this.currentView.drawCards(sortSetting,chkPiles.isSelected());
  }
}

Fixed version (ground truth):
@Override public void componentHidden(ComponentEvent e){
  if (cbSortBy.getSelectedItem() instanceof SortBy) {
    this.currentView.drawCards(sortSetting);
  }
}
Program: 159493
Project: 159493
Buggy source:
private void chkPilesActionPerformed(java.awt.event.ActionEvent evt){
  if (cbSortBy.getSelectedItem() instanceof SortBy) {
    if (this.currentView != null) {
      this.currentView.drawCards(sortSetting,chkPiles.isSelected());
    }
  }
}

Fixed version (ground truth):
private void chkPilesActionPerformed(java.awt.event.ActionEvent evt){
  if (cbSortBy.getSelectedItem() instanceof SortBy) {
    if (this.currentView != null) {
      sortSetting.setPilesToggle(chkPiles.isSelected());
      this.currentView.drawCards(sortSetting);
    }
  }
}
Program: 159494
Project: 159494
Buggy source:
private void filterCards(){
  FilterCard filter=buildFilter();
  try {
    List<Card> filteredCards=new ArrayList<Card>();
    setCursor(new Cursor(Cursor.WAIT_CURSOR));
    if (limited) {
      for (      Card card : cards) {
        if (filter.match(card,null)) {
          filteredCards.add(card);
        }
      }
    }
 else {
      List<CardInfo> foundCards=CardRepository.instance.findCards(buildCriteria());
      for (      CardInfo cardInfo : foundCards) {
        Card card=cardInfo.getMockCard();
        if (filter.match(card,null)) {
          filteredCards.add(card);
        }
      }
    }
    if (currentView instanceof CardGrid && filteredCards.size() > CardGrid.MAX_IMAGES) {
      this.toggleViewMode();
    }
    this.currentView.loadCards(new CardsView(filteredCards),sortSetting,chkPiles.isSelected(),bigCard,null,false);
    this.cardCount.setText(String.valueOf(filteredCards.size()));
  }
  finally {
    setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
  }
}

Fixed version (ground truth):
private void filterCards(){
  FilterCard filter=buildFilter();
  try {
    List<Card> filteredCards=new ArrayList<Card>();
    setCursor(new Cursor(Cursor.WAIT_CURSOR));
    if (limited) {
      for (      Card card : cards) {
        if (filter.match(card,null)) {
          filteredCards.add(card);
        }
      }
    }
 else {
      List<CardInfo> foundCards=CardRepository.instance.findCards(buildCriteria());
      for (      CardInfo cardInfo : foundCards) {
        Card card=cardInfo.getMockCard();
        if (filter.match(card,null)) {
          filteredCards.add(card);
        }
      }
    }
    if (currentView instanceof CardGrid && filteredCards.size() > CardGrid.MAX_IMAGES) {
      this.toggleViewMode();
    }
    this.currentView.loadCards(new CardsView(filteredCards),sortSetting,bigCard,null,false);
    this.cardCount.setText(String.valueOf(filteredCards.size()));
  }
  finally {
    setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
  }
}
Program: 159495
Project: 159495
Buggy source:
@Override public void componentResized(ComponentEvent e){
  if (cbSortBy.getSelectedItem() instanceof SortBy) {
    this.currentView.drawCards(sortSetting,chkPiles.isSelected());
  }
}

Fixed version (ground truth):
@Override public void componentResized(ComponentEvent e){
  if (cbSortBy.getSelectedItem() instanceof SortBy) {
    this.currentView.drawCards(sortSetting);
  }
}
Program: 159496
Project: 159496
Buggy source:
public void switchToGrid(){
  jToggleListView.setSelected(false);
  jToggleCardView.setSelected(true);
  currentView=cardGrid;
  cardSelectorScrollPane.setViewportView(cardGrid);
  cbSortBy.setEnabled(true);
  chkPiles.setEnabled(true);
  jButtonAddToMain.setEnabled(false);
  jButtonAddToSideboard.setEnabled(false);
  filterCards();
  chkPiles.setSelected(true);
  this.currentView.drawCards(sortSetting,chkPiles.isSelected());
}

Fixed version (ground truth):
public void switchToGrid(){
  jToggleListView.setSelected(false);
  jToggleCardView.setSelected(true);
  currentView=cardGrid;
  cardSelectorScrollPane.setViewportView(cardGrid);
  cbSortBy.setEnabled(true);
  chkPiles.setEnabled(true);
  jButtonAddToMain.setEnabled(false);
  jButtonAddToSideboard.setEnabled(false);
  filterCards();
  chkPiles.setSelected(true);
  this.currentView.drawCards(sortSetting);
}
Program: 159497
Project: 159497
Buggy source:
private void cbSortByActionPerformed(java.awt.event.ActionEvent evt){
  if (cbSortBy.getSelectedItem() instanceof SortBy) {
    if (this.currentView != null) {
      sortSetting.setSortBy((SortBy)cbSortBy.getSelectedItem());
      this.currentView.drawCards(sortSetting,chkPiles.isSelected());
    }
  }
}

Fixed version (ground truth):
private void cbSortByActionPerformed(java.awt.event.ActionEvent evt){
  if (cbSortBy.getSelectedItem() instanceof SortBy) {
    if (this.currentView != null) {
      sortSetting.setSortBy((SortBy)cbSortBy.getSelectedItem());
      this.currentView.drawCards(sortSetting);
    }
  }
}
Program: 159498
Project: 159498
Buggy source:
@Override public void componentShown(ComponentEvent e){
  if (cbSortBy.getSelectedItem() instanceof SortBy) {
    this.currentView.drawCards(sortSetting,chkPiles.isSelected());
  }
}

Fixed version (ground truth):
@Override public void componentShown(ComponentEvent e){
  if (cbSortBy.getSelectedItem() instanceof SortBy) {
    this.currentView.drawCards(sortSetting);
  }
}
Program: 159499
Project: 159499
Buggy source:
public SortSetting(String prefSortBy,String prefSortIndex,String prefSortAscending){
  this.prefSortBy=prefSortBy;
  this.prefSortIndex=prefSortIndex;
  this.prefSortAscending=prefSortAscending;
  this.sortBy=SortBy.getByString(PreferencesDialog.getCachedValue(this.prefSortBy,"String_Node_Str"));
  this.sortIndex=Integer.parseInt(PreferencesDialog.getCachedValue(this.prefSortIndex,"String_Node_Str"));
  this.ascending=PreferencesDialog.getCachedValue(this.prefSortAscending,"String_Node_Str").equals("String_Node_Str");
}

Fixed version (ground truth):
public SortSetting(String prefSortBy,String prefSortIndex,String prefSortAscending,String prefPilesToggle){
  this.prefSortBy=prefSortBy;
  this.prefSortIndex=prefSortIndex;
  this.prefSortAscending=prefSortAscending;
  this.prefPilesToggle=prefPilesToggle;
  this.sortBy=SortBy.getByString(PreferencesDialog.getCachedValue(this.prefSortBy,"String_Node_Str"));
  this.sortIndex=Integer.parseInt(PreferencesDialog.getCachedValue(this.prefSortIndex,"String_Node_Str"));
  this.ascending=PreferencesDialog.getCachedValue(this.prefSortAscending,"String_Node_Str").equals("String_Node_Str");
  this.pilesToggle=PreferencesDialog.getCachedValue(this.prefPilesToggle,"String_Node_Str").equals("String_Node_Str");
}
Program: 159500
Project: 159500
Buggy source:
private SortSettingBase(){
  super(PreferencesDialog.KEY_BASE_SORT_BY,PreferencesDialog.KEY_BASE_SORT_INDEX,PreferencesDialog.KEY_BASE_SORT_ASCENDING);
}

Fixed version (ground truth):
private SortSettingBase(){
  super(PreferencesDialog.KEY_BASE_SORT_BY,PreferencesDialog.KEY_BASE_SORT_INDEX,PreferencesDialog.KEY_BASE_SORT_ASCENDING,PreferencesDialog.KEY_BASE_PILES_TOGGLE);
}
Program: 159501
Project: 159501
Buggy source:
private SortSettingDeck(){
  super(PreferencesDialog.KEY_DECK_SORT_BY,PreferencesDialog.KEY_DECK_SORT_INDEX,PreferencesDialog.KEY_DECK_SORT_ASCENDING);
}

Fixed version (ground truth):
private SortSettingDeck(){
  super(PreferencesDialog.KEY_DECK_SORT_BY,PreferencesDialog.KEY_DECK_SORT_INDEX,PreferencesDialog.KEY_DECK_SORT_ASCENDING,PreferencesDialog.KEY_DECK_PILES_TOGGLE);
}
Program: 159502
Project: 159502
Buggy source:
private SortSettingDraft(){
  super(PreferencesDialog.KEY_DRAFT_SORT_BY,PreferencesDialog.KEY_DRAFT_SORT_INDEX,PreferencesDialog.KEY_DRAFT_SORT_INDEX);
}

Fixed version (ground truth):
private SortSettingDraft(){
  super(PreferencesDialog.KEY_DRAFT_SORT_BY,PreferencesDialog.KEY_DRAFT_SORT_INDEX,PreferencesDialog.KEY_DRAFT_SORT_INDEX,PreferencesDialog.KEY_DRAFT_PILES_TOGGLE);
}
Program: 159503
Project: 159503
Buggy source:
private SortSettingSideboard(){
  super(PreferencesDialog.KEY_SIDEBOARD_SORT_BY,PreferencesDialog.KEY_SIDEBOARD_SORT_INDEX,PreferencesDialog.KEY_SIDEBOARD_SORT_INDEX);
}

Fixed version (ground truth):
private SortSettingSideboard(){
  super(PreferencesDialog.KEY_SIDEBOARD_SORT_BY,PreferencesDialog.KEY_SIDEBOARD_SORT_INDEX,PreferencesDialog.KEY_SIDEBOARD_SORT_INDEX,PreferencesDialog.KEY_SIDEBOARD_PILES_TOGGLE);
}
Program: 159504
Project: 159504
Buggy source:
@Override public void drawCards(SortSetting sortSetting,boolean piles){
  fireTableDataChanged();
}

Fixed version (ground truth):
@Override public void drawCards(SortSetting sortSetting){
  fireTableDataChanged();
}
Program: 159506
Project: 159506
Buggy source:
private SortSettingDraft(){
  super(PreferencesDialog.KEY_DRAFT_SORT_BY,PreferencesDialog.KEY_DRAFT_SORT_INDEX,PreferencesDialog.KEY_DRAFT_SORT_INDEX,PreferencesDialog.KEY_DRAFT_PILES_TOGGLE);
}

Fixed version (ground truth):
private SortSettingDraft(){
  super(PreferencesDialog.KEY_DRAFT_SORT_BY,PreferencesDialog.KEY_DRAFT_SORT_INDEX,PreferencesDialog.KEY_DRAFT_SORT_ASCENDING,PreferencesDialog.KEY_DRAFT_PILES_TOGGLE);
}
Program: 159507
Project: 159507
Buggy source:
private SortSettingSideboard(){
  super(PreferencesDialog.KEY_SIDEBOARD_SORT_BY,PreferencesDialog.KEY_SIDEBOARD_SORT_INDEX,PreferencesDialog.KEY_SIDEBOARD_SORT_INDEX,PreferencesDialog.KEY_SIDEBOARD_PILES_TOGGLE);
}

Fixed version (ground truth):
private SortSettingSideboard(){
  super(PreferencesDialog.KEY_SIDEBOARD_SORT_BY,PreferencesDialog.KEY_SIDEBOARD_SORT_INDEX,PreferencesDialog.KEY_SIDEBOARD_SORT_ASCENDING,PreferencesDialog.KEY_SIDEBOARD_PILES_TOGGLE);
}
Program: 159508
Project: 159508
Buggy source:
@Override public boolean apply(Game game,Ability source){
  UUID objectId=source.getFirstTarget();
  UUID sourceId=source.getSourceId();
  StackObject stackObject=game.getStack().getStackObject(objectId);
  if (stackObject != null && !game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER,objectId,sourceId,stackObject.getControllerId()))) {
    if (stackObject instanceof Spell) {
      game.rememberLKI(objectId,Zone.STACK,(Spell)stackObject);
    }
    game.getStack().remove(stackObject);
    MageObject card=game.getObject(stackObject.getSourceId());
    if (card instanceof Card) {
      ((Card)card).moveToZone(targetZone,sourceId,game,flag);
    }
 else {
      game.informPlayers("String_Node_Str" + targetZone + "String_Node_Str");
    }
    game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTERED,objectId,sourceId,stackObject.getControllerId()));
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  UUID objectId=source.getFirstTarget();
  UUID sourceId=source.getSourceId();
  StackObject stackObject=game.getStack().getStackObject(objectId);
  if (stackObject != null && !game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER,objectId,sourceId,stackObject.getControllerId()))) {
    boolean spell=false;
    if (stackObject instanceof Spell) {
      game.rememberLKI(objectId,Zone.STACK,(Spell)stackObject);
      spell=true;
    }
    game.getStack().remove(stackObject);
    if (spell && !((Spell)stackObject).isCopiedSpell()) {
      MageObject card=game.getObject(stackObject.getSourceId());
      if (card instanceof Card) {
        ((Card)card).moveToZone(targetZone,sourceId,game,flag);
      }
 else {
        game.informPlayers("String_Node_Str" + targetZone + "String_Node_Str");
      }
    }
    game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTERED,objectId,sourceId,stackObject.getControllerId()));
    return true;
  }
  return false;
}
Program: 159509
Project: 159509
Buggy source:
@Override public boolean moveToZone(Zone zone,UUID sourceId,Game game,boolean flag,ArrayList<UUID> appliedEffects){
  throw new UnsupportedOperationException("String_Node_Str");
}

Fixed version (ground truth):
@Override public boolean moveToZone(Zone zone,UUID sourceId,Game game,boolean flag,ArrayList<UUID> appliedEffects){
  if (this.isCopiedSpell() && !zone.equals(Zone.STACK)) {
    return true;
  }
  throw new UnsupportedOperationException("String_Node_Str");
}
Program: 159510
Project: 159510
Buggy source:
@Override public boolean apply(Game game,Ability source){
  MageObject card=game.getLastKnownInformation(source.getFirstTarget(),Zone.BATTLEFIELD);
  if (card != null) {
    int cost=card.getManaCost().get(0).convertedManaCost();
    Player player=game.getPlayer(source.getControllerId());
    if (player != null) {
      player.gainLife(cost,game);
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Permanent targetPermanent=game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game,source));
  if (targetPermanent != null) {
    int cost=targetPermanent.getManaCost().convertedManaCost();
    Player player=game.getPlayer(source.getControllerId());
    if (player != null) {
      player.gainLife(cost,game);
    }
  }
  return true;
}
Program: 159511
Project: 159511
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Permanent creature=game.getPermanent(getTargetPointer().getFirst(game,source));
  if (creature != null) {
    Player controller=game.getPlayer(creature.getControllerId());
    if (controller != null) {
      int power=creature.getPower().getValue();
      creature.destroy(source.getSourceId(),game,false);
      Effect effect=new PutLibraryIntoGraveTargetEffect(power);
      effect.setTargetPointer(new FixedTarget(controller.getId()));
      return effect.apply(game,source);
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Permanent creature=game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game,source));
  if (creature != null) {
    Player controller=game.getPlayer(creature.getControllerId());
    if (controller != null) {
      int power=creature.getPower().getValue();
      Effect effect=new PutLibraryIntoGraveTargetEffect(power);
      effect.setTargetPointer(new FixedTarget(controller.getId()));
      return effect.apply(game,source);
    }
  }
  return false;
}
Program: 159512
Project: 159512
Buggy source:
@Override public boolean apply(Game game,Ability source){
  MageObject card=game.getLastKnownInformation(source.getFirstTarget(),Zone.BATTLEFIELD);
  if (card != null) {
    int cost=card.getManaCost().get(0).convertedManaCost();
    Player player=game.getPlayer(source.getControllerId());
    if (player != null) {
      player.gainLife(cost,game);
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Permanent artefact=game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game,source));
  if (artefact != null) {
    int cost=artefact.getManaCost().convertedManaCost();
    Player player=game.getPlayer(source.getControllerId());
    if (player != null) {
      player.gainLife(cost,game);
    }
  }
  return true;
}
Program: 159513
Project: 159513
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Permanent permanent=game.getPermanent(source.getFirstTarget());
  if (permanent != null) {
    int power=permanent.getPower().getValue();
    permanent.destroy(source.getId(),game,true);
    Player player=game.getPlayer(source.getControllerId());
    if (player != null) {
      player.gainLife(power,game);
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Permanent permanent=game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game,source));
  if (permanent != null) {
    int power=permanent.getPower().getValue();
    Player player=game.getPlayer(source.getControllerId());
    if (player != null) {
      player.gainLife(power,game);
    }
    return true;
  }
  return false;
}
Program: 159514
Project: 159514
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getControllerId());
  Permanent target=(Permanent)game.getLastKnownInformation(source.getFirstTarget(),Zone.BATTLEFIELD);
  if (player != null && target != null) {
    player.loseLife(target.getToughness().getValue(),game);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getControllerId());
  Permanent target=game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game,source));
  if (player != null && target != null) {
    player.loseLife(target.getToughness().getValue(),game);
    return true;
  }
  return false;
}
Program: 159515
Project: 159515
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  MageObject c=game.getLastKnownInformation(targetPointer.getFirst(game,source),Zone.BATTLEFIELD);
  if (c != null && controller != null) {
    controller.gainLife(c.getPower().getValue(),game);
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  Permanent creature=game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game,source));
  if (creature != null && controller != null) {
    controller.gainLife(creature.getPower().getValue(),game);
  }
  return false;
}
Program: 159516
Project: 159516
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.SPELL_CAST) {
    Spell spell=game.getStack().getSpell(event.getTargetId());
    if (spell != null && spell.getCardType().contains(CardType.INSTANT) || spell.getCardType().contains(CardType.SORCERY)) {
      Permanent enchantment=game.getPermanent(sourceId);
      if (enchantment != null && enchantment.getAttachedTo() != null) {
        Player player=game.getPlayer(enchantment.getAttachedTo());
        if (player != null && spell.getControllerId().equals(player.getId())) {
          this.getTargets().get(0).add(spell.getId(),game);
          return true;
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.SPELL_CAST) {
    Spell spell=game.getStack().getSpell(event.getTargetId());
    if (spell != null && (spell.getCardType().contains(CardType.INSTANT) || spell.getCardType().contains(CardType.SORCERY))) {
      Permanent enchantment=game.getPermanent(sourceId);
      if (enchantment != null && enchantment.getAttachedTo() != null) {
        Player player=game.getPlayer(enchantment.getAttachedTo());
        if (player != null && spell.getControllerId().equals(player.getId())) {
          this.getEffects().get(0).setTargetPointer(new FixedTarget(spell.getId()));
          return true;
        }
      }
    }
  }
  return false;
}
Program: 159517
Project: 159517
Buggy source:
private void copyFromToken(Token token,Game game){
  this.name=token.getName();
  this.abilities.clear();
  for (  Ability ability : token.getAbilities()) {
    this.addAbility(ability,game);
  }
  this.manaCost.clear();
  for (  ManaCost cost : token.getManaCost()) {
    this.getManaCost().add(cost.copy());
  }
  this.cardType.addAll(token.getCardType());
  this.color=token.getColor().copy();
  this.power.initValue(token.getPower().getValue());
  this.toughness.initValue(token.getToughness().getValue());
  this.supertype.addAll(token.getSupertype());
  this.subtype.addAll(token.getSubtype());
}

Fixed version (ground truth):
private void copyFromToken(Token token,Game game){
  this.name=token.getName();
  this.abilities.clear();
  for (  Ability ability : token.getAbilities()) {
    this.addAbility(ability,game);
  }
  this.manaCost.clear();
  for (  ManaCost cost : token.getManaCost()) {
    this.getManaCost().add(cost.copy());
  }
  this.cardType=token.getCardType();
  this.color=token.getColor().copy();
  this.power.initValue(token.getPower().getValue());
  this.toughness.initValue(token.getToughness().getValue());
  this.supertype=token.getSupertype();
  this.subtype=token.getSubtype();
}
Program: 159518
Project: 159518
Buggy source:
@Override public boolean applies(UUID sourceId,Ability source,Game game){
  return true;
}

Fixed version (ground truth):
@Override public boolean applies(UUID sourceId,Ability source,Game game){
  return sourceId.equals(source.getSourceId());
}
Program: 159520
Project: 159520
Buggy source:
@Override public Object getValueAt(int arg0,int arg1){
switch (arg1) {
case 0:
    return matches[arg0].getName();
case 1:
  return matches[arg0].getGameType();
case 2:
return matches[arg0].getDeckType();
case 3:
return matches[arg0].getPlayers();
case 4:
return matches[arg0].getResult();
case 5:
return timeFormatter.format(matches[arg0].getStartTime());
case 6:
if (matches[arg0].getEndTime() != null) {
return timeFormatter.format(matches[arg0].getEndTime());
}
 else {
return "String_Node_Str";
}
case 7:
return "String_Node_Str";
case 8:
return matches[arg0].getGames();
}
return "String_Node_Str";
}

Fixed version (ground truth):
@Override public Object getValueAt(int arg0,int arg1){
switch (arg1) {
case 0:
    return matches[arg0].getName();
case 1:
  return matches[arg0].getGameType();
case 2:
return matches[arg0].getDeckType();
case 3:
return matches[arg0].getPlayers();
case 4:
return matches[arg0].getResult();
case 5:
return timeFormatter.format(matches[arg0].getStartTime());
case 6:
if (matches[arg0].getEndTime() != null) {
return timeFormatter.format(matches[arg0].getEndTime());
}
 else {
return "String_Node_Str";
}
case 7:
if (matches[arg0].isReplayAvailable()) {
return "String_Node_Str";
}
 else {
return "String_Node_Str";
}
case 8:
return matches[arg0].getGames();
}
return "String_Node_Str";
}
Program: 159521
Project: 159521
Buggy source:
@Override public boolean isCellEditable(int rowIndex,int columnIndex){
  if (columnIndex != ACTION_COLUMN) {
    return false;
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean isCellEditable(int rowIndex,int columnIndex){
  return columnIndex == ACTION_COLUMN;
}
Program: 159522
Project: 159522
Buggy source:
public MatchView(Table table){
  this.matchId=table.getTournament().getId();
  this.matchName=table.getName();
  this.gameType=table.getGameType();
  if (table.getTournament().getOptions().getNumberRounds() > 0) {
    this.gameType=new StringBuilder(this.gameType).append("String_Node_Str").append(table.getTournament().getOptions().getNumberRounds()).append("String_Node_Str").toString();
  }
  this.deckType=new StringBuilder(table.getDeckType()).append("String_Node_Str").append(table.getTournament().getBoosterInfo()).toString();
  StringBuilder sb1=new StringBuilder();
  for (  TournamentPlayer tPlayer : table.getTournament().getPlayers()) {
    sb1.append(tPlayer.getPlayer().getName()).append("String_Node_Str").append(tPlayer.getPoints()).append("String_Node_Str");
  }
  this.players=sb1.toString();
  StringBuilder sb2=new StringBuilder();
  if (table.getTournament().getRounds().size() > 0) {
    for (    TournamentPlayer tPlayer : table.getTournament().getPlayers()) {
      sb2.append(tPlayer.getPlayer().getName()).append("String_Node_Str").append(tPlayer.getResults()).append("String_Node_Str");
    }
  }
 else {
    sb2.append("String_Node_Str");
  }
  this.result=sb2.toString();
  this.startTime=table.getTournament().getStartTime();
  this.endTime=table.getTournament().getEndTime();
}

Fixed version (ground truth):
public MatchView(Table table){
  this.matchId=table.getTournament().getId();
  this.matchName=table.getName();
  this.gameType=table.getGameType();
  if (table.getTournament().getOptions().getNumberRounds() > 0) {
    this.gameType=new StringBuilder(this.gameType).append("String_Node_Str").append(table.getTournament().getOptions().getNumberRounds()).append("String_Node_Str").toString();
  }
  this.deckType=new StringBuilder(table.getDeckType()).append("String_Node_Str").append(table.getTournament().getBoosterInfo()).toString();
  StringBuilder sb1=new StringBuilder();
  for (  TournamentPlayer tPlayer : table.getTournament().getPlayers()) {
    sb1.append(tPlayer.getPlayer().getName()).append("String_Node_Str").append(tPlayer.getPoints()).append("String_Node_Str");
  }
  this.players=sb1.toString();
  StringBuilder sb2=new StringBuilder();
  if (table.getTournament().getRounds().size() > 0) {
    for (    TournamentPlayer tPlayer : table.getTournament().getPlayers()) {
      sb2.append(tPlayer.getPlayer().getName()).append("String_Node_Str").append(tPlayer.getResults()).append("String_Node_Str");
    }
  }
 else {
    sb2.append("String_Node_Str");
  }
  this.result=sb2.toString();
  this.startTime=table.getTournament().getStartTime();
  this.endTime=table.getTournament().getEndTime();
  this.replayAvailable=false;
}
Program: 159523
Project: 159523
Buggy source:
@Override public boolean applies(GameEvent event,Ability source,Game game){
  if (!this.used && super.applies(event,source,game) && event.getTargetId().equals(source.getFirstTarget())) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(GameEvent event,Ability source,Game game){
  return !this.used && super.applies(event,source,game) && event.getTargetId().equals(source.getFirstTarget());
}
Program: 159525
Project: 159525
Buggy source:
public void cleanUp(){
  permanents.clear();
  Plugins.getInstance().sortPermanents(uiComponentsList,permanents.values());
}

Fixed version (ground truth):
public void cleanUp(){
  for (  Component c : this.jPanel.getComponents()) {
    if (c instanceof Permanent || c instanceof MagePermanent) {
      this.jPanel.remove(c);
    }
  }
  permanents.clear();
  Plugins.getInstance().sortPermanents(uiComponentsList,permanents.values());
}
Program: 159526
Project: 159526
Buggy source:
private void groupAttachments(PermanentView permanent){
  MagePermanent perm=permanents.get(permanent.getId());
  if (perm == null)   return;
  int position=getPosition(perm);
  perm.getLinks().clear();
  Rectangle r=perm.getBounds();
  if (!Plugins.getInstance().isCardPluginLoaded()) {
    for (    UUID attachmentId : permanent.getAttachments()) {
      MagePermanent link=permanents.get(attachmentId);
      if (link != null) {
        perm.getLinks().add(link);
        r.translate(20,20);
        link.setBounds(r);
        setPosition(link,++position);
      }
    }
  }
 else {
    int index=permanent.getAttachments().size();
    for (    UUID attachmentId : permanent.getAttachments()) {
      MagePermanent link=permanents.get(attachmentId);
      if (link != null) {
        link.setBounds(r);
        perm.getLinks().add(link);
        r.translate(8,10);
        perm.setBounds(r);
        moveToFront(link);
        moveToFront(perm);
        jPanel.setComponentZOrder(link,index);
        index--;
      }
    }
    jPanel.setComponentZOrder(perm,index);
  }
}

Fixed version (ground truth):
private void groupAttachments(PermanentView permanent){
  MagePermanent perm=permanents.get(permanent.getId());
  if (perm == null) {
    return;
  }
  int position=getPosition(perm);
  perm.getLinks().clear();
  Rectangle r=perm.getBounds();
  if (!Plugins.getInstance().isCardPluginLoaded()) {
    for (    UUID attachmentId : permanent.getAttachments()) {
      MagePermanent link=permanents.get(attachmentId);
      if (link != null) {
        perm.getLinks().add(link);
        r.translate(20,20);
        link.setBounds(r);
        setPosition(link,++position);
      }
    }
  }
 else {
    int index=permanent.getAttachments().size();
    for (    UUID attachmentId : permanent.getAttachments()) {
      MagePermanent link=permanents.get(attachmentId);
      if (link != null) {
        link.setBounds(r);
        perm.getLinks().add(link);
        r.translate(8,10);
        perm.setBounds(r);
        moveToFront(link);
        moveToFront(perm);
        jPanel.setComponentZOrder(link,index);
        index--;
      }
    }
    jPanel.setComponentZOrder(perm,index);
  }
}
Program: 159527
Project: 159527
Buggy source:
private void btnRightActionPerformed(java.awt.event.ActionEvent evt){
  this.selected=true;
  if (connectedDialog != null) {
    connectedDialog.removeDialog();
    connectedDialog=null;
  }
  if (mode == FeedbackMode.SELECT && (evt.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK) {
    session.sendPlayerInteger(gameId,0);
  }
 else   if (mode == FeedbackMode.END) {
    MageFrame.getGame(gameId).hideGame();
  }
 else {
    session.sendPlayerBoolean(gameId,false);
  }
}

Fixed version (ground truth):
private void btnRightActionPerformed(java.awt.event.ActionEvent evt){
  this.selected=true;
  if (connectedDialog != null) {
    connectedDialog.removeDialog();
    connectedDialog=null;
  }
  if (mode == FeedbackMode.SELECT && (evt.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK) {
    session.sendPlayerInteger(gameId,0);
  }
 else   if (mode == FeedbackMode.END) {
    GamePanel gamePanel=MageFrame.getGame(gameId);
    if (gamePanel != null) {
      gamePanel.removeGame();
    }
  }
 else {
    session.sendPlayerBoolean(gameId,false);
  }
}
Program: 159528
Project: 159528
Buggy source:
private void btnStopWatchingActionPerformed(java.awt.event.ActionEvent evt){
  if (modalQuestion("String_Node_Str","String_Node_Str") == JOptionPane.YES_OPTION) {
    session.stopWatching(gameId);
    this.hideGame();
  }
}

Fixed version (ground truth):
private void btnStopWatchingActionPerformed(java.awt.event.ActionEvent evt){
  if (modalQuestion("String_Node_Str","String_Node_Str") == JOptionPane.YES_OPTION) {
    session.stopWatching(gameId);
    this.removeGame();
  }
}
Program: 159529
Project: 159529
Buggy source:
public synchronized void showGame(UUID gameId,UUID playerId){
  this.gameId=gameId;
  this.playerId=playerId;
  session=MageFrame.getSession();
  MageFrame.addGame(gameId,this);
  this.feedbackPanel.init(gameId);
  this.feedbackPanel.clear();
  this.abilityPicker.init(session,gameId);
  this.btnConcede.setVisible(true);
  this.btnEndTurn.setVisible(true);
  this.btnSwitchHands.setVisible(false);
  this.pnlReplay.setVisible(false);
  this.btnStopWatching.setVisible(false);
  this.gameChatPanel.clear();
  this.gameChatPanel.connect(session.getGameChatId(gameId));
  if (!session.joinGame(gameId)) {
    hideGame();
  }
}

Fixed version (ground truth):
public synchronized void showGame(UUID gameId,UUID playerId){
  this.gameId=gameId;
  this.playerId=playerId;
  session=MageFrame.getSession();
  MageFrame.addGame(gameId,this);
  this.feedbackPanel.init(gameId);
  this.feedbackPanel.clear();
  this.abilityPicker.init(session,gameId);
  this.btnConcede.setVisible(true);
  this.btnEndTurn.setVisible(true);
  this.btnSwitchHands.setVisible(false);
  this.pnlReplay.setVisible(false);
  this.btnStopWatching.setVisible(false);
  this.gameChatPanel.clear();
  this.gameChatPanel.connect(session.getGameChatId(gameId));
  if (!session.joinGame(gameId)) {
    removeGame();
  }
}
Program: 159530
Project: 159530
Buggy source:
public synchronized void replayGame(UUID gameId){
  this.gameId=gameId;
  this.playerId=null;
  session=MageFrame.getSession();
  MageFrame.addGame(gameId,this);
  this.feedbackPanel.init(gameId);
  this.feedbackPanel.clear();
  this.btnConcede.setVisible(false);
  this.btnEndTurn.setVisible(false);
  this.btnSwitchHands.setVisible(false);
  this.btnStopWatching.setVisible(false);
  this.pnlReplay.setVisible(true);
  this.gameChatPanel.clear();
  if (!session.startReplay(gameId)) {
    hideGame();
  }
  for (  PlayAreaPanel panel : getPlayers().values()) {
    panel.setPlayingMode(false);
  }
}

Fixed version (ground truth):
public synchronized void replayGame(UUID gameId){
  this.gameId=gameId;
  this.playerId=null;
  session=MageFrame.getSession();
  MageFrame.addGame(gameId,this);
  this.feedbackPanel.init(gameId);
  this.feedbackPanel.clear();
  this.btnConcede.setVisible(false);
  this.btnEndTurn.setVisible(false);
  this.btnSwitchHands.setVisible(false);
  this.btnStopWatching.setVisible(false);
  this.pnlReplay.setVisible(true);
  this.gameChatPanel.clear();
  if (!session.startReplay(gameId)) {
    removeGame();
  }
  for (  PlayAreaPanel panel : getPlayers().values()) {
    panel.setPlayingMode(false);
  }
}
Program: 159531
Project: 159531
Buggy source:
public synchronized void watchGame(UUID gameId){
  this.gameId=gameId;
  this.playerId=null;
  session=MageFrame.getSession();
  MageFrame.addGame(gameId,this);
  this.feedbackPanel.init(gameId);
  this.feedbackPanel.clear();
  this.btnConcede.setVisible(false);
  this.btnEndTurn.setVisible(false);
  this.btnSwitchHands.setVisible(false);
  this.btnStopWatching.setVisible(true);
  this.pnlReplay.setVisible(false);
  this.gameChatPanel.clear();
  this.gameChatPanel.connect(session.getGameChatId(gameId));
  if (!session.watchGame(gameId)) {
    hideGame();
  }
  for (  PlayAreaPanel panel : getPlayers().values()) {
    panel.setPlayingMode(false);
  }
}

Fixed version (ground truth):
public synchronized void watchGame(UUID gameId){
  this.gameId=gameId;
  this.playerId=null;
  session=MageFrame.getSession();
  MageFrame.addGame(gameId,this);
  this.feedbackPanel.init(gameId);
  this.feedbackPanel.clear();
  this.btnConcede.setVisible(false);
  this.btnEndTurn.setVisible(false);
  this.btnSwitchHands.setVisible(false);
  this.btnStopWatching.setVisible(true);
  this.pnlReplay.setVisible(false);
  this.gameChatPanel.clear();
  this.gameChatPanel.connect(session.getGameChatId(gameId));
  if (!session.watchGame(gameId)) {
    removeGame();
  }
  for (  PlayAreaPanel panel : getPlayers().values()) {
    panel.setPlayingMode(false);
  }
}
Program: 159532
Project: 159532
Buggy source:
private void addPopupMenuWatcher(){
  JMenuItem menuItem;
  menuItem=new JMenuItem("String_Node_Str");
  popupMenu.add(menuItem);
  menuItem.addActionListener(new ActionListener(){
    @Override public void actionPerformed(    ActionEvent e){
      if (JOptionPane.showConfirmDialog(PlayAreaPanel.this,"String_Node_Str","String_Node_Str",JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
        gamePanel.getSession().stopWatching(gameId);
        gamePanel.hideGame();
      }
    }
  }
);
  battlefieldPanel.getMainPanel().addMouseListener(new MouseAdapter(){
    @Override public void mouseReleased(    MouseEvent Me){
      if (Me.isPopupTrigger() && playingMode) {
        popupMenu.show(Me.getComponent(),Me.getX(),Me.getY());
      }
    }
  }
);
}

Fixed version (ground truth):
private void addPopupMenuWatcher(){
  JMenuItem menuItem;
  menuItem=new JMenuItem("String_Node_Str");
  popupMenu.add(menuItem);
  menuItem.addActionListener(new ActionListener(){
    @Override public void actionPerformed(    ActionEvent e){
      if (JOptionPane.showConfirmDialog(PlayAreaPanel.this,"String_Node_Str","String_Node_Str",JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
        gamePanel.getSession().stopWatching(gameId);
        gamePanel.removeGame();
      }
    }
  }
);
  battlefieldPanel.getMainPanel().addMouseListener(new MouseAdapter(){
    @Override public void mouseReleased(    MouseEvent Me){
      if (Me.isPopupTrigger() && playingMode) {
        popupMenu.show(Me.getComponent(),Me.getX(),Me.getY());
      }
    }
  }
);
}
Program: 159535
Project: 159535
Buggy source:
@Override public void gameResult(String result){
  try {
    endGame(result);
  }
 catch (  MageException ex) {
    logger.fatal("String_Node_Str",ex);
  }
}

Fixed version (ground truth):
@Override public void gameResult(String result){
  try {
    logger.warn("String_Node_Str" + result);
    endGame(result);
  }
 catch (  MageException ex) {
    logger.fatal("String_Node_Str",ex);
  }
}
Program: 159536
Project: 159536
Buggy source:
public void update(){
  if (!killed) {
    User user=UserManager.getInstance().getUser(userId);
    if (user != null) {
      user.fireCallback(new ClientCallback("String_Node_Str",game.getId(),getGameView()));
    }
  }
}

Fixed version (ground truth):
public void update(){
  if (!killed) {
    User user=UserManager.getInstance().getUser(userId);
    if (user != null) {
      logger.warn("String_Node_Str");
      GameView gameView=getGameView();
      logger.warn("String_Node_Str");
      UUID id=game.getId();
      logger.warn("String_Node_Str");
      ClientCallback clientCallback=new ClientCallback("String_Node_Str",id,gameView);
      logger.warn("String_Node_Str");
      user.fireCallback(clientCallback);
      logger.warn("String_Node_Str");
    }
  }
}
Program: 159537
Project: 159537
Buggy source:
public GameView getGameView(){
  return new GameView(game.getState(),game,this.isPlayer);
}

Fixed version (ground truth):
public GameView getGameView(){
  logger.warn("String_Node_Str");
  GameState gameState=game.getState();
  logger.warn("String_Node_Str");
  GameView gameView=new GameView(gameState,game,this.isPlayer);
  logger.warn("String_Node_Str");
  return gameView;
}
Program: 159538
Project: 159538
Buggy source:
@Override public Object call(){
  try {
    game.start(choosingPlayerId);
    game.fireUpdatePlayersEvent();
    result.gameResult(game.getWinner());
  }
 catch (  MageException ex) {
    logger.fatal("String_Node_Str",ex);
  }
  return null;
}

Fixed version (ground truth):
@Override public Object call(){
  try {
    game.start(choosingPlayerId);
    game.fireUpdatePlayersEvent();
    result.gameResult(game.getWinner());
    game.cleanUp();
  }
 catch (  MageException ex) {
    logger.fatal("String_Node_Str",ex);
  }
  return null;
}
Program: 159539
Project: 159539
Buggy source:
@Override public void end(){
  if (!state.isGameOver()) {
    state.endGame();
    for (    Player player : state.getPlayers().values()) {
      player.abort();
    }
    gameCards.clear();
  }
}

Fixed version (ground truth):
@Override public void end(){
  if (!state.isGameOver()) {
    state.endGame();
    for (    Player player : state.getPlayers().values()) {
      player.abort();
    }
  }
}
Program: 159540
Project: 159540
Buggy source:
public void checkTriggers(GameEvent event,Game game){
  for (  TriggeredAbility ability : this.values()) {
    if (ability.isInUseableZone(game,null,true)) {
      MageObject object=null;
      if (!ability.getZone().equals(Zone.COMMAND) && !game.getState().getZone(ability.getSourceId()).equals(ability.getZone())) {
        object=game.getShortLivingLKI(ability.getSourceId(),ability.getZone());
      }
      if (object == null) {
        object=getMageObject(event,game,ability);
      }
      if (object != null) {
        if (checkAbilityStillExists(ability,event,object)) {
          if (object instanceof Permanent) {
            ability.setControllerId(((Permanent)object).getControllerId());
          }
          if (ability.checkTrigger(event,game)) {
            UUID controllerId=ability.getControllerId();
            ability.trigger(game,controllerId);
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
public void checkTriggers(GameEvent event,Game game){
  for (  TriggeredAbility ability : this.values()) {
    if (ability.isInUseableZone(game,null,event.getType().equals(GameEvent.EventType.ZONE_CHANGE) ? true : false)) {
      MageObject object=null;
      if (!ability.getZone().equals(Zone.COMMAND) && !game.getState().getZone(ability.getSourceId()).equals(ability.getZone())) {
        object=game.getShortLivingLKI(ability.getSourceId(),ability.getZone());
      }
      if (object == null) {
        object=getMageObject(event,game,ability);
      }
      if (object != null) {
        if (checkAbilityStillExists(ability,event,object)) {
          if (object instanceof Permanent) {
            ability.setControllerId(((Permanent)object).getControllerId());
          }
          if (ability.checkTrigger(event,game)) {
            UUID controllerId=ability.getControllerId();
            ability.trigger(game,controllerId);
          }
        }
      }
    }
  }
}
Program: 159541
Project: 159541
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getControllerId());
  if (player != null) {
switch (targetController) {
case OPPONENT:
      for (      UUID playerId : game.getOpponents(source.getControllerId())) {
        putCardsToGravecard(playerId,source,game);
      }
    break;
case ANY:
  for (  UUID playerId : player.getInRange()) {
    putCardsToGravecard(playerId,source,game);
  }
break;
case NOT_YOU:
for (UUID playerId : player.getInRange()) {
if (!playerId.equals(source.getSourceId())) {
  putCardsToGravecard(playerId,source,game);
}
}
default :
throw new UnsupportedOperationException("String_Node_Str");
}
int cardsCount=Math.min(numberCards,player.getLibrary().size());
for (int i=0; i < cardsCount; i++) {
Card card=player.getLibrary().removeFromTop(game);
if (card != null) {
card.moveToZone(Zone.GRAVEYARD,source.getId(),game,true);
}
}
return true;
}
return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getControllerId());
  if (player != null) {
switch (targetController) {
case OPPONENT:
      for (      UUID playerId : game.getOpponents(source.getControllerId())) {
        putCardsToGravecard(playerId,source,game);
      }
    break;
case ANY:
  for (  UUID playerId : player.getInRange()) {
    putCardsToGravecard(playerId,source,game);
  }
break;
case NOT_YOU:
for (UUID playerId : player.getInRange()) {
if (!playerId.equals(source.getSourceId())) {
  putCardsToGravecard(playerId,source,game);
}
}
break;
default :
throw new UnsupportedOperationException("String_Node_Str");
}
return true;
}
return false;
}
Program: 159542
Project: 159542
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Permanent permanent=game.getPermanent(source.getSourceId());
  if (permanent == null) {
    permanent=(Permanent)game.getLastKnownInformation(source.getFirstTarget(),Zone.BATTLEFIELD);
  }
  if (permanent != null) {
    EmptyToken newToken=new EmptyToken();
    CardUtil.copyTo(newToken).from(permanent);
    return newToken.putOntoBattlefield(1,game,source.getSourceId(),source.getControllerId());
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Permanent permanent=game.getPermanent(source.getSourceId());
  if (permanent == null) {
    permanent=(Permanent)game.getLastKnownInformation(source.getSourceId(),Zone.BATTLEFIELD);
  }
  if (permanent != null) {
    EmptyToken newToken=new EmptyToken();
    CardUtil.copyTo(newToken).from(permanent);
    return newToken.putOntoBattlefield(1,game,source.getSourceId(),source.getControllerId());
  }
  return false;
}