nus-yam/ex-repair huggingface dataset:
Program: 159434
Project: 159434
Buggy source:
@Override public Set<Card> getCards(Game game){
  Set<Card> cards=new LinkedHashSet<Card>();
  for (  UUID card : this) {
    cards.add(game.getCard(card));
  }
  return cards;
}

Fixed version (ground truth):
@Override public Set<Card> getCards(Game game){
  Set<Card> cards=new LinkedHashSet<>();
  for (  UUID card : this) {
    cards.add(game.getCard(card));
  }
  return cards;
}
Program: 159435
Project: 159435
Buggy source:
@Override public Collection<Card> getUniqueCards(Game game){
  Map<String,Card> cards=new HashMap<String,Card>();
  for (  UUID cardId : this) {
    Card card=game.getCard(cardId);
    if (!cards.containsKey(card.getName())) {
      cards.put(card.getName(),card);
    }
  }
  return cards.values();
}

Fixed version (ground truth):
@Override public Collection<Card> getUniqueCards(Game game){
  Map<String,Card> cards=new HashMap<>();
  for (  UUID cardId : this) {
    Card card=game.getCard(cardId);
    if (!cards.containsKey(card.getName())) {
      cards.put(card.getName(),card);
    }
  }
  return cards.values();
}
Program: 159436
Project: 159436
Buggy source:
@Override public boolean applies(GameEvent event,Ability source,Game game){
  if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).getToZone() == Zone.GRAVEYARD) {
    if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(GameEvent event,Ability source,Game game){
  if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).getToZone() == Zone.GRAVEYARD) {
    Card card=game.getCard(event.getTargetId());
    if (card != null && game.getOpponents(source.getControllerId()).contains(card.getOwnerId())) {
      return true;
    }
  }
  return false;
}
Program: 159437
Project: 159437
Buggy source:
@Override public boolean canPay(UUID sourceId,UUID controllerId,Game game){
  Permanent planeswalker=game.getPermanent(sourceId);
  if (planeswalker.getCounters().getCount(CounterType.LOYALTY) + amount >= 0 && !planeswalker.isLoyaltyUsed())   return true;
  return false;
}

Fixed version (ground truth):
@Override public boolean canPay(UUID sourceId,UUID controllerId,Game game){
  Permanent planeswalker=game.getPermanent(sourceId);
  return planeswalker.getCounters().getCount(CounterType.LOYALTY) + amount >= 0 && !planeswalker.isLoyaltyUsed();
}
Program: 159438
Project: 159438
Buggy source:
@Override public Cost getFixedCostsFromAnnouncedValue(int xValue){
  return new PayLoyaltyCost(xValue);
}

Fixed version (ground truth):
@Override public Cost getFixedCostsFromAnnouncedValue(int xValue){
  return new PayLoyaltyCost(-xValue);
}
Program: 159439
Project: 159439
Buggy source:
@Override public boolean isOpponent(Player player,UUID playerToCheck){
  return player.getInRange().contains(playerToCheck);
}

Fixed version (ground truth):
@Override public boolean isOpponent(Player player,UUID playerToCheck){
  return !player.getId().equals(playerToCheck) && player.getInRange().contains(playerToCheck);
}
Program: 159440
Project: 159440
Buggy source:
@Override public Set<UUID> getOpponents(UUID playerId){
  Set<UUID> opponents=new HashSet<UUID>();
  for (  UUID opponentId : this.getPlayer(playerId).getInRange()) {
    if (!opponentId.equals(playerId)) {
      opponents.add(opponentId);
    }
  }
  return opponents;
}

Fixed version (ground truth):
@Override public Set<UUID> getOpponents(UUID playerId){
  Set<UUID> opponents=new HashSet<>();
  for (  UUID opponentId : this.getPlayer(playerId).getInRange()) {
    if (!opponentId.equals(playerId)) {
      opponents.add(opponentId);
    }
  }
  return opponents;
}
Program: 159441
Project: 159441
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE) {
switch (targetController) {
case YOU:
      boolean yours=event.getPlayerId().equals(this.controllerId);
    if (yours && setTargetPointer) {
      if (getTargets().size() == 0) {
        for (        Effect effect : this.getEffects()) {
          effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
        }
      }
    }
  return yours;
case OPPONENT:
if (game.getPlayer(this.controllerId).hasOpponent(event.getPlayerId(),game)) {
  if (setTargetPointer && getTargets().size() == 0) {
    for (    Effect effect : this.getEffects()) {
      effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
    }
  }
  return true;
}
break;
case ANY:
if (setTargetPointer && getTargets().size() == 0) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
}
}
return true;
case CONTROLLER_ATTACHED_TO:
Permanent attachment=game.getPermanent(sourceId);
if (attachment != null && attachment.getAttachedTo() != null) {
Permanent attachedTo=game.getPermanent(attachment.getAttachedTo());
if (attachedTo != null && attachedTo.getControllerId().equals(event.getPlayerId())) {
if (setTargetPointer && getTargets().size() == 0) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
}
}
return true;
}
}
}
}
return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE) {
switch (targetController) {
case YOU:
      boolean yours=event.getPlayerId().equals(this.controllerId);
    if (yours && setTargetPointer) {
      if (getTargets().size() == 0) {
        for (        Effect effect : this.getEffects()) {
          effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
        }
      }
    }
  return yours;
case OPPONENT:
if (game.getPlayer(this.controllerId).hasOpponent(event.getPlayerId(),game)) {
  if (setTargetPointer && getTargets().size() == 0) {
    for (    Effect effect : this.getEffects()) {
      effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
    }
  }
  return true;
}
break;
case ANY:
if (setTargetPointer && getTargets().size() == 0) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
}
}
return true;
case CONTROLLER_ATTACHED_TO:
Permanent attachment=game.getPermanent(sourceId);
if (attachment != null && attachment.getAttachedTo() != null) {
Permanent attachedTo=game.getPermanent(attachment.getAttachedTo());
if (attachedTo != null && attachedTo.getControllerId().equals(event.getPlayerId())) {
if (setTargetPointer && getTargets().size() == 0) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
}
}
return true;
}
}
break;
default :
throw new UnsupportedOperationException("String_Node_Str" + targetController.toString());
}
}
return false;
}
Program: 159442
Project: 159442
Buggy source:
@Override public boolean hasOpponent(UUID playerToCheckId,Game game){
  return game.isOpponent(this,playerToCheckId);
}

Fixed version (ground truth):
@Override public boolean hasOpponent(UUID playerToCheckId,Game game){
  return !this.getId().equals(playerToCheckId) && game.isOpponent(this,playerToCheckId);
}
Program: 159443
Project: 159443
Buggy source:
@Override public boolean canTarget(UUID id,Ability source,Game game){
  if (source != null && source.getId().equals(id)) {
    return false;
  }
  Spell spell=game.getStack().getSpell(id);
  if (spell != null) {
    return filter.match(spell,source.getControllerId(),game);
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean canTarget(UUID id,Ability source,Game game){
  if (source == null || source.getId().equals(id)) {
    return false;
  }
  Spell spell=game.getStack().getSpell(id);
  if (spell != null) {
    return filter.match(spell,source.getControllerId(),game);
  }
  return false;
}
Program: 159444
Project: 159444
Buggy source:
@Override public Set<UUID> possibleTargets(UUID sourceControllerId,Game game){
  Set<UUID> possibleTargets=new HashSet<UUID>();
  for (  StackObject stackObject : game.getStack()) {
    if (canBeChosen(stackObject,sourceControllerId,game)) {
      possibleTargets.add(stackObject.getId());
    }
  }
  return possibleTargets;
}

Fixed version (ground truth):
@Override public Set<UUID> possibleTargets(UUID sourceControllerId,Game game){
  Set<UUID> possibleTargets=new HashSet<>();
  for (  StackObject stackObject : game.getStack()) {
    if (canBeChosen(stackObject,sourceControllerId,game)) {
      possibleTargets.add(stackObject.getId());
    }
  }
  return possibleTargets;
}
Program: 159445
Project: 159445
Buggy source:
@Override public boolean canChoose(UUID sourceControllerId,Game game){
  int count=0;
  for (  StackObject stackObject : game.getStack()) {
    if (canBeChosen(stackObject,sourceControllerId,game)) {
      count++;
      if (count >= this.minNumberOfTargets)       return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean canChoose(UUID sourceControllerId,Game game){
  int count=0;
  for (  StackObject stackObject : game.getStack()) {
    if (canBeChosen(stackObject,sourceControllerId,game)) {
      count++;
      if (count >= this.minNumberOfTargets) {
        return true;
      }
    }
  }
  return false;
}
Program: 159446
Project: 159446
Buggy source:
/** 
 * Complete remove of the table, release all objects
 */
public void cleanUp(){
  match.cleanUpOnMatchEnd(isTournament);
}

Fixed version (ground truth):
/** 
 * Complete remove of the table, release all objects
 */
public void cleanUp(){
  if (match != null) {
    match.cleanUpOnMatchEnd(isTournament);
  }
}
Program: 159447
Project: 159447
Buggy source:
protected List<Permanent> threats(UUID playerId,UUID sourceId,FilterPermanent filter,Game game,List<UUID> targets){
  List<Permanent> threats=(playerId == null || sourceId == null) ? game.getBattlefield().getActivePermanents(filter,this.getId(),sourceId,game) : game.getBattlefield().getAllActivePermanents(filter,playerId,game);
  Iterator<Permanent> it=threats.iterator();
  while (it.hasNext()) {
    Permanent test=it.next();
    if (targets.contains(test.getId()) || (playerId != null && !test.getControllerId().equals(playerId))) {
      it.remove();
    }
  }
  Collections.sort(threats,new PermanentComparator(game));
  Collections.reverse(threats);
  return threats;
}

Fixed version (ground truth):
protected List<Permanent> threats(UUID playerId,UUID sourceId,FilterPermanent filter,Game game,List<UUID> targets){
  List<Permanent> threats=(playerId == null || sourceId == null) ? game.getBattlefield().getActivePermanents(filter,this.getId(),sourceId,game) : game.getBattlefield().getActivePermanents(filter,playerId,sourceId,game);
  Iterator<Permanent> it=threats.iterator();
  while (it.hasNext()) {
    Permanent test=it.next();
    if (targets.contains(test.getId()) || (playerId != null && !test.getControllerId().equals(playerId))) {
      it.remove();
    }
  }
  Collections.sort(threats,new PermanentComparator(game));
  Collections.reverse(threats);
  return threats;
}
Program: 159448
Project: 159448
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Permanent permanent=game.getPermanent(source.getSourceId());
  if (permanent != null) {
    new ExileTargetEffect(source.getSourceId(),permanent.getName()).apply(game,source);
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  ExileZone exile=game.getExile().getExileZone(source.getSourceId());
  Card sourceCard=game.getCard(source.getSourceId());
  if (exile != null && sourceCard != null) {
    LinkedList<UUID> cards=new LinkedList<>(exile);
    for (    UUID cardId : cards) {
      Card card=game.getCard(cardId);
      card.moveToZone(Zone.BATTLEFIELD,source.getSourceId(),game,false);
      game.informPlayers(new StringBuilder(sourceCard.getName()).append("String_Node_Str").append(card.getName()).append("String_Node_Str").toString());
    }
    exile.clear();
    return true;
  }
  return false;
}
Program: 159449
Project: 159449
Buggy source:
@Override public BanisherPriestWatcher copy(){
  return new BanisherPriestWatcher(this);
}

Fixed version (ground truth):
@Override public ReturnExiledCreatureEffect copy(){
  return new ReturnExiledCreatureEffect(this);
}
Program: 159450
Project: 159450
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Permanent permanent=game.getPermanent(source.getSourceId());
  Player controller=game.getPlayer(source.getControllerId());
  if (permanent != null) {
    return controller.moveCardToExileWithInfo(permanent,null,null,source.getSourceId(),game,null);
  }
 else {
    Card card=game.getCard(source.getSourceId());
    if (card != null) {
      return controller.moveCardToExileWithInfo(permanent,null,null,source.getSourceId(),game,null);
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Permanent permanent=game.getPermanent(source.getSourceId());
  Player controller=game.getPlayer(source.getControllerId());
  if (permanent != null) {
    return controller.moveCardToExileWithInfo(permanent,null,null,source.getSourceId(),game,null);
  }
 else {
    Card card=game.getCard(source.getSourceId());
    if (card != null) {
      return controller.moveCardToExileWithInfo(card,null,null,source.getSourceId(),game,null);
    }
  }
  return false;
}
Program: 159451
Project: 159451
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Permanent permanent=game.getPermanent(source.getSourceId());
  if (permanent != null) {
    new ExileTargetEffect(source.getSourceId(),permanent.getName()).apply(game,source);
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  ExileZone exile=game.getExile().getExileZone(source.getSourceId());
  Card sourceCard=game.getCard(source.getSourceId());
  if (exile != null && sourceCard != null) {
    LinkedList<UUID> cards=new LinkedList<>(exile);
    for (    UUID cardId : cards) {
      Card card=game.getCard(cardId);
      card.moveToZone(Zone.BATTLEFIELD,source.getSourceId(),game,false);
      game.informPlayers(new StringBuilder(sourceCard.getName()).append("String_Node_Str").append(card.getName()).append("String_Node_Str").toString());
    }
    exile.clear();
    return true;
  }
  return false;
}
Program: 159452
Project: 159452
Buggy source:
@Override public ChainedToTheRocksWatcher copy(){
  return new ChainedToTheRocksWatcher(this);
}

Fixed version (ground truth):
@Override public ReturnExiledCreatureChainedToTheRocksEffect copy(){
  return new ReturnExiledCreatureChainedToTheRocksEffect(this);
}
Program: 159453
Project: 159453
Buggy source:
@Override public void adjustTargets(Ability ability,Game game){
  if (ability instanceof ConditionalTriggeredAbility) {
    for (    Effect effect : ability.getEffects()) {
      if (effect instanceof DestroyTargetEffect) {
        Player attackedPlayer=game.getPlayer(effect.getTargetPointer().getFirst(game,ability));
        if (attackedPlayer != null) {
          ability.getTargets().clear();
          FilterPermanent filterEnchantment=new FilterEnchantmentPermanent("String_Node_Str");
          filter.add(new ControllerIdPredicate(attackedPlayer.getId()));
          Target target=new TargetPermanent(filterEnchantment);
          target.setRequired(true);
          ability.addTarget(target);
          effect.setTargetPointer(new FirstTargetPointer());
          break;
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override public void adjustTargets(Ability ability,Game game){
  if (ability instanceof ConditionalTriggeredAbility) {
    for (    Effect effect : ability.getEffects()) {
      if (effect instanceof DestroyTargetEffect) {
        Player attackedPlayer=game.getPlayer(effect.getTargetPointer().getFirst(game,ability));
        if (attackedPlayer != null) {
          ability.getTargets().clear();
          FilterPermanent filterEnchantment=new FilterEnchantmentPermanent("String_Node_Str");
          filterEnchantment.add(new ControllerIdPredicate(attackedPlayer.getId()));
          Target target=new TargetPermanent(filterEnchantment);
          target.setRequired(true);
          ability.addTarget(target);
          effect.setTargetPointer(new FirstTargetPointer());
          break;
        }
      }
    }
  }
}
Program: 159454
Project: 159454
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED && event.getSourceId().equals(this.getSourceId())) {
    FilterCreaturePermanent filter=new FilterCreaturePermanent("String_Node_Str");
    UUID defenderId=game.getCombat().getDefenderId(sourceId);
    filter.add(new ControllerIdPredicate(defenderId));
    this.getTargets().clear();
    TargetCreaturePermanent target=new TargetCreaturePermanent(filter);
    target.setRequired(true);
    this.addTarget(target);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@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.getFromZone() == Zone.BATTLEFIELD) {
      return true;
    }
  }
  return false;
}
Program: 159455
Project: 159455
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Permanent permanent=game.getPermanent(source.getSourceId());
  if (permanent != null) {
    new ExileTargetEffect(source.getSourceId(),permanent.getName()).apply(game,source);
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  ExileZone exile=game.getExile().getExileZone(source.getSourceId());
  Card sourceCard=game.getCard(source.getSourceId());
  if (exile != null && sourceCard != null) {
    LinkedList<UUID> cards=new LinkedList<>(exile);
    for (    UUID cardId : cards) {
      Card card=game.getCard(cardId);
      card.moveToZone(Zone.BATTLEFIELD,source.getSourceId(),game,false);
      game.informPlayers(new StringBuilder(sourceCard.getName()).append("String_Node_Str").append(card.getName()).append("String_Node_Str").toString());
    }
    exile.clear();
    return true;
  }
  return false;
}
Program: 159456
Project: 159456
Buggy source:
@Override public ColossalWhaleWatcher copy(){
  return new ColossalWhaleWatcher(this);
}

Fixed version (ground truth):
@Override public ReturnExiledCreatureColossalWhaleEffect copy(){
  return new ReturnExiledCreatureColossalWhaleEffect(this);
}
Program: 159457
Project: 159457
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Card card=game.getCard(source.getSourceId());
  if (card != null) {
    ExileZone currentZone=game.getState().getExile().getExileZone(source.getSourceId());
    if (currentZone.size() > 0) {
      if (card.putOntoBattlefield(game,Zone.EXILED,source.getSourceId(),card.getOwnerId(),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) {
    ExileZone currentZone=game.getState().getExile().getExileZone(source.getSourceId());
    if (currentZone.size() > 0) {
      Player owner=game.getPlayer(card.getOwnerId());
      if (owner != null && owner.putOntoBattlefieldWithInfo(card,game,Zone.EXILED,source.getSourceId())) {
        return true;
      }
    }
  }
  return false;
}
Program: 159458
Project: 159458
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE && event.getPlayerId().equals(this.controllerId)) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  return event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE && event.getPlayerId().equals(this.controllerId);
}
Program: 159459
Project: 159459
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Permanent permanent=game.getPermanent(targetPointer.getFirst(game,source));
  if (permanent != null) {
    return permanent.moveToExile(exileId,exileZone,source.getSourceId(),game);
  }
 else {
    Card card=game.getCard(targetPointer.getFirst(game,source));
    if (card != null) {
      return card.moveToExile(exileId,exileZone,source.getSourceId(),game);
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Permanent permanent=game.getPermanent(targetPointer.getFirst(game,source));
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    if (permanent != null) {
      Zone currentZone=game.getState().getZone(permanent.getId());
      if (!currentZone.equals(Zone.EXILED) && (onlyFromZone == null || onlyFromZone.equals(Zone.BATTLEFIELD))) {
        return controller.moveCardToExileWithInfo(permanent,exileId,exileZone,source.getSourceId(),game,onlyFromZone);
      }
    }
 else {
      Card card=game.getCard(targetPointer.getFirst(game,source));
      if (card != null) {
        Zone currentZone=game.getState().getZone(card.getId());
        if (!currentZone.equals(Zone.EXILED) && (onlyFromZone == null || onlyFromZone.equals(currentZone))) {
          return controller.moveCardToExileWithInfo(card,exileId,exileZone,source.getSourceId(),game,onlyFromZone);
        }
      }
    }
  }
  return false;
}
Program: 159460
Project: 159460
Buggy source:
public ExileTargetEffect(final ExileTargetEffect effect){
  super(effect);
  this.exileZone=effect.exileZone;
  this.exileId=effect.exileId;
}

Fixed version (ground truth):
public ExileTargetEffect(final ExileTargetEffect effect){
  super(effect);
  this.exileZone=effect.exileZone;
  this.exileId=effect.exileId;
  this.onlyFromZone=effect.onlyFromZone;
}
Program: 159461
Project: 159461
Buggy source:
@Override public boolean moveCardToGraveyardWithInfo(Card card,UUID sourceId,Game game,Zone fromZone){
  boolean result=false;
  if (card.moveToZone(Zone.GRAVEYARD,sourceId,game,fromZone != null ? fromZone.equals(Zone.BATTLEFIELD) : false)) {
    game.informPlayers(new StringBuilder(this.getName()).append("String_Node_Str").append(card.getName()).append("String_Node_Str").append(fromZone != null ? new StringBuilder("String_Node_Str").append(fromZone.toString().toLowerCase(Locale.ENGLISH)).append("String_Node_Str") : "String_Node_Str").append("String_Node_Str").toString());
  }
  return result;
}

Fixed version (ground truth):
@Override public boolean moveCardToGraveyardWithInfo(Card card,UUID sourceId,Game game,Zone fromZone){
  boolean result=false;
  if (card.moveToZone(Zone.GRAVEYARD,sourceId,game,fromZone != null ? fromZone.equals(Zone.BATTLEFIELD) : false)) {
    game.informPlayers(new StringBuilder(this.getName()).append("String_Node_Str").append(card.getName()).append("String_Node_Str").append(fromZone != null ? new StringBuilder("String_Node_Str").append(fromZone.toString().toLowerCase(Locale.ENGLISH)).append("String_Node_Str") : "String_Node_Str").append("String_Node_Str").toString());
    result=true;
  }
  return result;
}
Program: 159462
Project: 159462
Buggy source:
@Override public boolean moveCardToHandWithInfo(Card card,UUID sourceId,Game game,Zone fromZone){
  boolean result=false;
  if (card.moveToZone(Zone.HAND,sourceId,game,false)) {
    game.informPlayers(new StringBuilder(this.getName()).append("String_Node_Str").append(card.getName()).append("String_Node_Str").append(fromZone != null ? new StringBuilder("String_Node_Str").append(fromZone.toString().toLowerCase(Locale.ENGLISH)).append("String_Node_Str") : "String_Node_Str").append("String_Node_Str").toString());
  }
  return result;
}

Fixed version (ground truth):
@Override public boolean moveCardToHandWithInfo(Card card,UUID sourceId,Game game,Zone fromZone){
  boolean result=false;
  if (card.moveToZone(Zone.HAND,sourceId,game,false)) {
    game.informPlayers(new StringBuilder(this.getName()).append("String_Node_Str").append(card.getName()).append("String_Node_Str").append(fromZone != null ? new StringBuilder("String_Node_Str").append(fromZone.toString().toLowerCase(Locale.ENGLISH)).append("String_Node_Str") : "String_Node_Str").append("String_Node_Str").toString());
    result=true;
  }
  return result;
}
Program: 159463
Project: 159463
Buggy source:
@Override public boolean putOntoBattlefieldWithInfo(Card card,Game game,Zone fromZone,UUID sourceId,boolean tapped){
  boolean result=false;
  if (card.putOntoBattlefield(game,fromZone,sourceId,this.getId(),tapped)) {
    game.informPlayers(new StringBuilder(this.getName()).append("String_Node_Str").append(card.getName()).append("String_Node_Str").append(fromZone.toString().toLowerCase(Locale.ENGLISH)).append("String_Node_Str").append("String_Node_Str").toString());
  }
  return result;
}

Fixed version (ground truth):
@Override public boolean putOntoBattlefieldWithInfo(Card card,Game game,Zone fromZone,UUID sourceId,boolean tapped){
  boolean result=false;
  if (card.putOntoBattlefield(game,fromZone,sourceId,this.getId(),tapped)) {
    game.informPlayers(new StringBuilder(this.getName()).append("String_Node_Str").append(card.getName()).append("String_Node_Str").append(fromZone.toString().toLowerCase(Locale.ENGLISH)).append("String_Node_Str").append("String_Node_Str").toString());
    result=true;
  }
  return result;
}
Program: 159464
Project: 159464
Buggy source:
@Override public ConditionalMana build(Object... options){
  return new CavernOfSoulsConditionalMana(this.mana);
}

Fixed version (ground truth):
@Override public ConditionalMana build(Object... options){
  this.mana.setFlag(true);
  return new CavernOfSoulsConditionalMana(this.mana);
}
Program: 159465
Project: 159465
Buggy source:
@Override public void watch(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.MANA_PAYED) {
    MageObject object=game.getObject(event.getSourceId());
    if (object != null && object.getName().equals("String_Node_Str")) {
      spells.add(event.getTargetId());
    }
  }
}

Fixed version (ground truth):
@Override public void watch(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.MANA_PAYED) {
    MageObject object=game.getObject(event.getSourceId());
    if (object != null && object.getName().equals("String_Node_Str") && event.getFlag()) {
      spells.add(event.getTargetId());
    }
  }
}
Program: 159466
Project: 159466
Buggy source:
/** 
 * Tests card can be countered for cast with Cavern of Souls
 */
@Test public void testDrakeCantBeCountered(){
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",3);
  addCard(Zone.HAND,playerA,"String_Node_Str");
  addCard(Zone.HAND,playerA,"String_Node_Str");
  addCard(Zone.HAND,playerB,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerB,"String_Node_Str",2);
  setChoice(playerA,"String_Node_Str");
  setChoice(playerA,"String_Node_Str");
  playLand(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str");
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str");
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerB,"String_Node_Str");
  setStopAt(1,PhaseStep.BEGIN_COMBAT);
  execute();
  assertGraveyardCount(playerA,"String_Node_Str",0);
  assertPermanentCount(playerA,"String_Node_Str",1);
}

Fixed version (ground truth):
/** 
 * Tests spell can't be countered for cast with Cavern of Souls
 */
@Test public void testDrakeCantBeCountered(){
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",3);
  addCard(Zone.HAND,playerA,"String_Node_Str");
  addCard(Zone.HAND,playerA,"String_Node_Str");
  addCard(Zone.HAND,playerB,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerB,"String_Node_Str",2);
  setChoice(playerA,"String_Node_Str");
  setChoice(playerA,"String_Node_Str");
  playLand(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str");
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str");
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerB,"String_Node_Str");
  setStopAt(1,PhaseStep.BEGIN_COMBAT);
  execute();
  assertGraveyardCount(playerA,"String_Node_Str",0);
  assertPermanentCount(playerA,"String_Node_Str",1);
}
Program: 159467
Project: 159467
Buggy source:
private void removeConditional(ManaType manaType,Ability ability,Game game){
  for (  ConditionalMana mana : getConditionalMana()) {
    if (mana.get(manaType) > 0 && mana.apply(ability,game,mana.getManaProducerId())) {
      mana.set(manaType,mana.get(manaType) - 1);
      game.fireEvent(new GameEvent(GameEvent.EventType.MANA_PAYED,ability.getId(),mana.getManaProducerId(),ability.getControllerId()));
      break;
    }
  }
}

Fixed version (ground truth):
private void removeConditional(ManaType manaType,Ability ability,Game game){
  for (  ConditionalMana mana : getConditionalMana()) {
    if (mana.get(manaType) > 0 && mana.apply(ability,game,mana.getManaProducerId())) {
      mana.set(manaType,mana.get(manaType) - 1);
      game.fireEvent(new GameEvent(GameEvent.EventType.MANA_PAYED,ability.getId(),mana.getManaProducerId(),ability.getControllerId(),0,mana.getFlag()));
      break;
    }
  }
}
Program: 159469
Project: 159469
Buggy source:
public void cleanUp(){
  ActionCallback actionCallback=Plugins.getInstance().getActionCallback();
  if (actionCallback instanceof MageActionCallback) {
    ((MageActionCallback)actionCallback).setCardPreviewComponent(null);
  }
}

Fixed version (ground truth):
public void cleanUp(){
}
Program: 159470
Project: 159470
Buggy source:
/** 
 * Free resources so GC can remove unused objects from memory
 */
public void cleanUp(){
  if (updateDeckTask != null) {
    updateDeckTask.cancel(true);
  }
  if (countdown != null) {
    if (countdown.isRunning()) {
      countdown.stop();
    }
    for (    ActionListener al : countdown.getActionListeners()) {
      countdown.removeActionListener(al);
    }
  }
  this.cardSelector.cleanUp();
  this.deckArea.cleanUp();
  this.remove(bigCard);
  this.bigCard=null;
  ((MageActionCallback)Plugins.getInstance().getActionCallback()).setCardPreviewComponent(null);
}

Fixed version (ground truth):
/** 
 * Free resources so GC can remove unused objects from memory
 */
public void cleanUp(){
  if (updateDeckTask != null) {
    updateDeckTask.cancel(true);
  }
  if (countdown != null) {
    if (countdown.isRunning()) {
      countdown.stop();
    }
    for (    ActionListener al : countdown.getActionListeners()) {
      countdown.removeActionListener(al);
    }
  }
  this.cardSelector.cleanUp();
  this.deckArea.cleanUp();
  this.remove(bigCard);
  this.bigCard=null;
}
Program: 159471
Project: 159471
Buggy source:
public void update(Map<UUID,PermanentView> battlefield){
  boolean changed=false;
  List<PermanentView> permanentsToAdd=new ArrayList<PermanentView>();
  for (  PermanentView permanent : battlefield.values()) {
    if (!permanents.containsKey(permanent.getId())) {
      permanentsToAdd.add(permanent);
      changed=true;
    }
 else {
      MagePermanent p=permanents.get(permanent.getId());
      if (!changed) {
        int s1=permanent.getAttachments() == null ? 0 : permanent.getAttachments().size();
        int s2=p.getLinks().size();
        if (s1 != s2) {
          changed=true;
        }
      }
      permanents.get(permanent.getId()).update(permanent);
    }
  }
  addedArtifact=addedCreature=addedPermanent=false;
  int count=permanentsToAdd.size();
  for (  PermanentView permanent : permanentsToAdd) {
    addPermanent(permanent,count);
  }
  if (addedArtifact) {
    AudioManager.playAddArtifact();
  }
 else   if (addedCreature) {
    AudioManager.playSummon();
  }
 else   if (addedPermanent) {
    AudioManager.playAddPermanent();
  }
  removedCreature=false;
  for (Iterator<Entry<UUID,MagePermanent>> iterator=permanents.entrySet().iterator(); iterator.hasNext(); ) {
    Entry<UUID,MagePermanent> entry=iterator.next();
    if (!battlefield.containsKey(entry.getKey())) {
      removePermanent(entry.getKey(),1);
      iterator.remove();
      changed=true;
    }
  }
  if (removedCreature) {
    AudioManager.playDiedCreature();
  }
  if (changed) {
    this.battlefield=battlefield;
    sortLayout();
  }
}

Fixed version (ground truth):
public void update(Map<UUID,PermanentView> battlefield){
  boolean changed=false;
  List<PermanentView> permanentsToAdd=new ArrayList<>();
  for (  PermanentView permanent : battlefield.values()) {
    if (!permanents.containsKey(permanent.getId())) {
      permanentsToAdd.add(permanent);
      changed=true;
    }
 else {
      MagePermanent p=permanents.get(permanent.getId());
      if (!changed) {
        int s1=permanent.getAttachments() == null ? 0 : permanent.getAttachments().size();
        int s2=p.getLinks().size();
        if (s1 != s2) {
          changed=true;
        }
      }
      permanents.get(permanent.getId()).update(permanent);
    }
  }
  addedArtifact=addedCreature=addedPermanent=false;
  int count=permanentsToAdd.size();
  for (  PermanentView permanent : permanentsToAdd) {
    addPermanent(permanent,count);
  }
  if (addedArtifact) {
    AudioManager.playAddArtifact();
  }
 else   if (addedCreature) {
    AudioManager.playSummon();
  }
 else   if (addedPermanent) {
    AudioManager.playAddPermanent();
  }
  removedCreature=false;
  for (Iterator<Entry<UUID,MagePermanent>> iterator=permanents.entrySet().iterator(); iterator.hasNext(); ) {
    Entry<UUID,MagePermanent> entry=iterator.next();
    if (!battlefield.containsKey(entry.getKey())) {
      removePermanent(entry.getKey(),1);
      iterator.remove();
      changed=true;
    }
  }
  if (removedCreature) {
    AudioManager.playDiedCreature();
  }
  if (changed) {
    this.battlefield=battlefield;
    sortLayout();
  }
}
Program: 159472
Project: 159472
Buggy source:
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());
}

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());
  this.bigCard=null;
}
Program: 159473
Project: 159473
Buggy source:
public void select(String message,GameView gameView,int messageId){
  updateGame(gameView);
  String messageToDisplay=message;
  Map<String,Serializable> options=null;
  for (  PlayerView playerView : gameView.getPlayers()) {
    if (playerView.getPlayerId().equals(playerId)) {
      if (playerView.isActive()) {
        options=new HashMap<String,Serializable>();
        options.put("String_Node_Str",true);
        messageToDisplay=message + "String_Node_Str";
      }
      if (playerView.getStatesSavedSize() > 0 && gameView.getStack().size() == 0) {
        feedbackPanel.allowUndo(playerView.getStatesSavedSize());
      }
      break;
    }
  }
  this.feedbackPanel.getFeedback(FeedbackMode.SELECT,messageToDisplay,gameView.getSpecial(),options,messageId);
  if (PhaseManager.getInstance().isSkip(gameView,message)) {
    this.feedbackPanel.doClick();
    logger.debug(new StringBuilder("String_Node_Str").append(message).append("String_Node_Str").append(messageId));
  }
 else {
    logger.debug(new StringBuilder("String_Node_Str").append(message).append("String_Node_Str").append(messageId));
  }
}

Fixed version (ground truth):
public void select(String message,GameView gameView,int messageId){
  updateGame(gameView);
  String messageToDisplay=message;
  Map<String,Serializable> options=null;
  for (  PlayerView playerView : gameView.getPlayers()) {
    if (playerView.getPlayerId().equals(playerId)) {
      if (playerView.isActive()) {
        options=new HashMap<>();
        options.put("String_Node_Str",true);
        messageToDisplay=message + "String_Node_Str";
      }
      if (playerView.getStatesSavedSize() > 0 && gameView.getStack().size() == 0) {
        feedbackPanel.allowUndo(playerView.getStatesSavedSize());
      }
      break;
    }
  }
  this.feedbackPanel.getFeedback(FeedbackMode.SELECT,messageToDisplay,gameView.getSpecial(),options,messageId);
  if (PhaseManager.getInstance().isSkip(gameView,message)) {
    this.feedbackPanel.doClick();
    logger.debug(new StringBuilder("String_Node_Str").append(message).append("String_Node_Str").append(messageId));
  }
 else {
    logger.debug(new StringBuilder("String_Node_Str").append(message).append("String_Node_Str").append(messageId));
  }
}
Program: 159474
Project: 159474
Buggy source:
private Map<String,JComponent> getUIComponents(JLayeredPane jLayeredPane){
  Map<String,JComponent> components=new HashMap<String,JComponent>();
  components.put("String_Node_Str",jSplitPane1);
  components.put("String_Node_Str",pnlBattlefield);
  components.put("String_Node_Str",jPanel3);
  components.put("String_Node_Str",handContainer);
  components.put("String_Node_Str",gameChatPanel);
  components.put("String_Node_Str",userChatPanel);
  components.put("String_Node_Str",jLayeredPane);
  components.put("String_Node_Str",this);
  return components;
}

Fixed version (ground truth):
private Map<String,JComponent> getUIComponents(JLayeredPane jLayeredPane){
  Map<String,JComponent> components=new HashMap<>();
  components.put("String_Node_Str",jSplitPane1);
  components.put("String_Node_Str",pnlBattlefield);
  components.put("String_Node_Str",jPanel3);
  components.put("String_Node_Str",handContainer);
  components.put("String_Node_Str",gameChatPanel);
  components.put("String_Node_Str",userChatPanel);
  components.put("String_Node_Str",jLayeredPane);
  components.put("String_Node_Str",this);
  return components;
}
Program: 159476
Project: 159476
Buggy source:
private void createPhaseButton(String name){
  if (hoverButtons == null) {
    hoverButtons=new LinkedHashMap<String,HoverButton>();
  }
  Rectangle rect=new Rectangle(36,36);
  HoverButton button=new HoverButton("String_Node_Str",ImageManagerImpl.getInstance().getPhaseImage(name),rect);
  button.setToolTipText(name.replaceAll("String_Node_Str","String_Node_Str"));
  button.setPreferredSize(new Dimension(36,36));
  hoverButtons.put(name,button);
}

Fixed version (ground truth):
private void createPhaseButton(String name){
  if (hoverButtons == null) {
    hoverButtons=new LinkedHashMap<>();
  }
  Rectangle rect=new Rectangle(36,36);
  HoverButton button=new HoverButton("String_Node_Str",ImageManagerImpl.getInstance().getPhaseImage(name),rect);
  button.setToolTipText(name.replaceAll("String_Node_Str","String_Node_Str"));
  button.setPreferredSize(new Dimension(36,36));
  hoverButtons.put(name,button);
}
Program: 159477
Project: 159477
Buggy source:
public void cleanUp(){
  MageFrame.removeGame(gameId);
  saveDividerLocations();
  this.gameChatPanel.disconnect();
  this.userChatPanel.disconnect();
  this.removeListener();
  this.handContainer.cleanUp();
  this.stack.cleanUp();
  for (  Map.Entry<UUID,PlayAreaPanel> playAreaPanelEntry : players.entrySet()) {
    playAreaPanelEntry.getValue().CleanUp();
  }
  this.players.clear();
  jLayeredPane.remove(abilityPicker);
  this.abilityPicker.cleanUp();
  jLayeredPane.remove(DialogManager.getManager(gameId));
  DialogManager.removeGame(gameId);
  if (pickNumber != null) {
    pickNumber.removeDialog();
  }
  for (  ExileZoneDialog exileDialog : exiles.values()) {
    exileDialog.cleanUp();
    exileDialog.removeDialog();
  }
  for (  ShowCardsDialog revealDialog : revealed.values()) {
    revealDialog.cleanUp();
    revealDialog.removeDialog();
  }
  for (  ShowCardsDialog lookedAtDialog : lookedAt.values()) {
    lookedAtDialog.cleanUp();
    lookedAtDialog.removeDialog();
  }
  for (  ShowCardsDialog pickTargetDialog : pickTarget) {
    pickTargetDialog.cleanUp();
    pickTargetDialog.removeDialog();
  }
  try {
    Component popupContainer=MageFrame.getUI().getComponent(MageComponents.POPUP_CONTAINER);
    popupContainer.setVisible(false);
  }
 catch (  InterruptedException ex) {
    logger.fatal("String_Node_Str",ex);
  }
}

Fixed version (ground truth):
public void cleanUp(){
  MageFrame.removeGame(gameId);
  saveDividerLocations();
  this.gameChatPanel.disconnect();
  this.userChatPanel.disconnect();
  this.removeListener();
  this.handContainer.cleanUp();
  this.stack.cleanUp();
  for (  Map.Entry<UUID,PlayAreaPanel> playAreaPanelEntry : players.entrySet()) {
    playAreaPanelEntry.getValue().CleanUp();
  }
  this.players.clear();
  jLayeredPane.remove(abilityPicker);
  this.abilityPicker.cleanUp();
  jLayeredPane.remove(DialogManager.getManager(gameId));
  DialogManager.removeGame(gameId);
  if (pickNumber != null) {
    pickNumber.removeDialog();
  }
  for (  ExileZoneDialog exileDialog : exiles.values()) {
    exileDialog.cleanUp();
    exileDialog.removeDialog();
  }
  for (  ShowCardsDialog revealDialog : revealed.values()) {
    revealDialog.cleanUp();
    revealDialog.removeDialog();
  }
  for (  ShowCardsDialog lookedAtDialog : lookedAt.values()) {
    lookedAtDialog.cleanUp();
    lookedAtDialog.removeDialog();
  }
  for (  ShowCardsDialog pickTargetDialog : pickTarget) {
    pickTargetDialog.cleanUp();
    pickTargetDialog.removeDialog();
  }
  try {
    Component popupContainer=MageFrame.getUI().getComponent(MageComponents.POPUP_CONTAINER);
    popupContainer.setVisible(false);
  }
 catch (  InterruptedException ex) {
    logger.fatal("String_Node_Str",ex);
  }
  jPanel2.remove(bigCard);
  this.bigCard=null;
}
Program: 159479
Project: 159479
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == EventType.ZONE_CHANGE) {
    ZoneChangeEvent zEvent=(ZoneChangeEvent)event;
    if (zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getToZone() == Zone.GRAVEYARD) {
      Permanent permanent=game.getPermanent(event.getTargetId());
      if (filter.match(permanent,game)) {
        if (setTargetPointer) {
          for (          Effect effect : this.getEffects()) {
            effect.setTargetPointer(new FixedTarget(event.getSourceId()));
          }
        }
        return true;
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == EventType.ZONE_CHANGE) {
    ZoneChangeEvent zEvent=(ZoneChangeEvent)event;
    if (zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getToZone() == Zone.GRAVEYARD) {
      Permanent permanent=game.getPermanent(event.getTargetId());
      if (filter.match(permanent,this.getSourceId(),this.getControllerId(),game)) {
        if (setTargetPointer) {
          for (          Effect effect : this.getEffects()) {
            effect.setTargetPointer(new FixedTarget(event.getSourceId()));
          }
        }
        return true;
      }
    }
  }
  return false;
}
Program: 159480
Project: 159480
Buggy source:
@Override public boolean apply(Game game,Ability source){
  boolean result=true;
  for (  UUID targetId : targetPointer.getTargets(game,source)) {
switch (game.getState().getZone(targetId)) {
case BATTLEFIELD:
      Permanent permanent=game.getPermanent(targetId);
    if (permanent != null) {
      permanent.moveToZone(Zone.HAND,source.getSourceId(),game,false);
    }
 else {
      result=false;
    }
  break;
case GRAVEYARD:
Card card=game.getCard(targetId);
if (card != null) {
card.moveToZone(Zone.HAND,source.getSourceId(),game,true);
}
 else {
result=false;
}
break;
case EXILED:
card=game.getCard(targetId);
if (card != null) {
card.moveToZone(Zone.HAND,source.getSourceId(),game,true);
}
 else {
result=false;
}
break;
}
}
return result;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  boolean result=true;
  Player controller=game.getPlayer(source.getControllerId());
  if (controller == null) {
    return false;
  }
  for (  UUID targetId : targetPointer.getTargets(game,source)) {
switch (game.getState().getZone(targetId)) {
case BATTLEFIELD:
      Permanent permanent=game.getPermanent(targetId);
    if (permanent != null) {
      controller.moveCardToHandWithInfo((Card)permanent,source.getSourceId(),game,Zone.BATTLEFIELD);
    }
 else {
      result=false;
    }
  break;
case GRAVEYARD:
Card card=game.getCard(targetId);
if (card != null) {
controller.moveCardToHandWithInfo(card,source.getSourceId(),game,Zone.GRAVEYARD);
}
 else {
result=false;
}
break;
case EXILED:
card=game.getCard(targetId);
if (card != null) {
controller.moveCardToHandWithInfo(card,source.getSourceId(),game,Zone.EXILED);
}
 else {
result=false;
}
break;
}
}
return result;
}
Program: 159481
Project: 159481
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getFirstTarget());
  if (player != null) {
    player.revealCards("String_Node_Str",player.getHand(),game);
    Player you=game.getPlayer(source.getControllerId());
    if (you != null) {
      TargetCard target=new TargetCard(Zone.HAND,filter);
      target.setRequired(true);
      if (target.canChoose(source.getControllerId(),game) && you.chooseTarget(outcome,player.getHand(),target,source,game)) {
        Card card=player.getHand().get(target.getFirstTarget(),game);
        if (card != null) {
          return player.discard(card,source,game);
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getFirstTarget());
  if (player != null) {
    player.revealCards("String_Node_Str",player.getHand(),game);
    Player you=game.getPlayer(source.getControllerId());
    if (you != null) {
      TargetCard target=new TargetCard(Zone.HAND,filter);
      target.setRequired(true);
      if (target.canChoose(source.getControllerId(),player.getId(),game) && you.chooseTarget(outcome,player.getHand(),target,source,game)) {
        Card card=player.getHand().get(target.getFirstTarget(),game);
        if (card != null) {
          return player.discard(card,source,game);
        }
      }
    }
  }
  return false;
}
Program: 159483
Project: 159483
Buggy source:
@Override public void loadCards(CardsView showCards,SortSetting sortSetting,boolean piles,BigCard bigCard,UUID gameId,boolean merge){
  boolean drawImage=showCards.size() < MAX_IMAGES;
  this.bigCard=bigCard;
  this.gameId=gameId;
  if (merge) {
    for (    CardView card : showCards.values()) {
      if (!cards.containsKey(card.getId())) {
        addCard(card,bigCard,gameId,drawImage);
      }
    }
    for (Iterator<Entry<UUID,MageCard>> i=cards.entrySet().iterator(); i.hasNext(); ) {
      Entry<UUID,MageCard> entry=i.next();
      if (!showCards.containsKey(entry.getKey())) {
        removeCardImg(entry.getKey());
        i.remove();
      }
    }
  }
 else {
    this.clearCards();
    for (    CardView card : showCards.values()) {
      addCard(card,bigCard,gameId,drawImage);
    }
  }
  System.gc();
  drawCards(sortSetting,piles);
  this.setVisible(true);
}

Fixed version (ground truth):
@Override public void loadCards(CardsView showCards,SortSetting sortSetting,BigCard bigCard,UUID gameId,boolean merge){
  boolean drawImage=showCards.size() < MAX_IMAGES;
  this.bigCard=bigCard;
  this.gameId=gameId;
  if (merge) {
    for (    CardView card : showCards.values()) {
      if (!cards.containsKey(card.getId())) {
        addCard(card,bigCard,gameId,drawImage);
      }
    }
    for (Iterator<Entry<UUID,MageCard>> i=cards.entrySet().iterator(); i.hasNext(); ) {
      Entry<UUID,MageCard> entry=i.next();
      if (!showCards.containsKey(entry.getKey())) {
        removeCardImg(entry.getKey());
        i.remove();
      }
    }
  }
 else {
    this.clearCards();
    for (    CardView card : showCards.values()) {
      addCard(card,bigCard,gameId,drawImage);
    }
  }
  drawCards(sortSetting);
  this.setVisible(true);
}
Program: 159484
Project: 159484
Buggy source:
private void redrawCards(){
  if (cards == null) {
    cards=new CardsView();
  }
  currentView.loadCards(cards,sortSetting,false,bigCard,gameId);
}

Fixed version (ground truth):
private void redrawCards(){
  if (cards == null) {
    cards=new CardsView();
  }
  currentView.loadCards(cards,sortSetting,bigCard,gameId);
}