nus-yam/ex-repair huggingface dataset:
Program: 159068
Project: 159068
Buggy source:
public AbilityImpl(final AbilityImpl ability){
  this.id=ability.id;
  this.originalId=ability.originalId;
  this.abilityType=ability.abilityType;
  this.controllerId=ability.controllerId;
  this.sourceId=ability.sourceId;
  this.zone=ability.zone;
  this.name=ability.name;
  this.usesStack=ability.usesStack;
  this.manaCosts=ability.manaCosts;
  this.manaCostsToPay=ability.manaCostsToPay.copy();
  this.costs=ability.costs.copy();
  this.optionalCosts=ability.optionalCosts.copy();
  for (  AlternativeCost cost : ability.alternativeCosts) {
    this.alternativeCosts.add((AlternativeCost)cost.copy());
  }
  this.modes=ability.modes.copy();
  this.ruleAtTheTop=ability.ruleAtTheTop;
  this.ruleVisible=ability.ruleVisible;
  this.ruleAdditionalCostsVisible=ability.ruleAdditionalCostsVisible;
  this.costModificationActive=ability.costModificationActive;
  this.worksFaceDown=ability.worksFaceDown;
}

Fixed version (ground truth):
public AbilityImpl(final AbilityImpl ability){
  this.id=ability.id;
  this.originalId=ability.originalId;
  this.abilityType=ability.abilityType;
  this.controllerId=ability.controllerId;
  this.sourceId=ability.sourceId;
  this.zone=ability.zone;
  this.name=ability.name;
  this.usesStack=ability.usesStack;
  this.manaCosts=ability.manaCosts;
  this.manaCostsToPay=ability.manaCostsToPay.copy();
  this.costs=ability.costs.copy();
  this.optionalCosts=ability.optionalCosts.copy();
  for (  AlternativeCost cost : ability.alternativeCosts) {
    this.alternativeCosts.add((AlternativeCost)cost.copy());
  }
  this.modes=ability.modes.copy();
  this.ruleAtTheTop=ability.ruleAtTheTop;
  this.ruleVisible=ability.ruleVisible;
  this.ruleAdditionalCostsVisible=ability.ruleAdditionalCostsVisible;
  this.costModificationActive=ability.costModificationActive;
  this.worksFaceDown=ability.worksFaceDown;
  this.abilityWord=ability.abilityWord;
}
Program: 159069
Project: 159069
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == EventType.DAMAGED_PLAYER && (!onlyCombat || ((DamagedPlayerEvent)event).isCombatDamage())) {
    Permanent permanent=game.getPermanent(event.getSourceId());
    if (permanent != null && filter.match(permanent,sourceId,controllerId,game)) {
      if (setTargetPointer) {
        for (        Effect effect : this.getEffects()) {
          effect.setValue("String_Node_Str",event.getAmount());
          effect.setTargetPointer(new FixedTarget(permanent.getControllerId()));
        }
      }
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == EventType.DAMAGED_PLAYER && (!onlyCombat || ((DamagedPlayerEvent)event).isCombatDamage())) {
    Permanent permanent=game.getPermanent(event.getSourceId());
    if (permanent != null && filter.match(permanent,sourceId,controllerId,game)) {
      if (!setTargetPointer.equals(SetTargetPointer.NONE)) {
        for (        Effect effect : this.getEffects()) {
          effect.setValue("String_Node_Str",event.getAmount());
switch (setTargetPointer) {
case PLAYER:
            effect.setTargetPointer(new FixedTarget(permanent.getControllerId()));
          break;
case PERMANENT:
        effect.setTargetPointer(new FixedTarget(permanent.getId()));
      break;
  }
}
}
return true;
}
}
return false;
}
Program: 159070
Project: 159070
Buggy source:
@Override public String getText(Mode mode){
  if (!staticText.isEmpty()) {
    return staticText;
  }
  StringBuilder sb=new StringBuilder();
  sb.append("String_Node_Str");
  if (counter.getCount() > 1) {
    sb.append(CardUtil.numberToText(counter.getCount())).append("String_Node_Str");
  }
 else {
    sb.append("String_Node_Str");
  }
  sb.append(counter.getName().toLowerCase()).append("String_Node_Str");
  if (mode.getTargets().size() > 0) {
    String targetName=mode.getTargets().get(0).getTargetName();
    if (!targetName.startsWith("String_Node_Str")) {
      sb.append("String_Node_Str");
    }
    sb.append(targetName);
  }
  if (amount.getMessage().length() > 0) {
    sb.append("String_Node_Str").append(amount.getMessage());
  }
  return sb.toString();
}

Fixed version (ground truth):
@Override public String getText(Mode mode){
  if (!staticText.isEmpty()) {
    return staticText;
  }
  StringBuilder sb=new StringBuilder();
  sb.append("String_Node_Str");
  if (counter.getCount() > 1) {
    sb.append(CardUtil.numberToText(counter.getCount())).append("String_Node_Str");
  }
 else {
    sb.append("String_Node_Str");
  }
  sb.append(counter.getName().toLowerCase()).append("String_Node_Str");
  if (mode.getTargets().size() > 0) {
    String targetName=mode.getTargets().get(0).getTargetName();
    if (!targetName.startsWith("String_Node_Str")) {
      sb.append("String_Node_Str");
    }
    sb.append(targetName);
  }
 else {
    sb.append("String_Node_Str");
  }
  if (amount.getMessage().length() > 0) {
    sb.append("String_Node_Str").append(amount.getMessage());
  }
  return sb.toString();
}
Program: 159071
Project: 159071
Buggy source:
@Override public boolean applies(UUID sourceId,Ability source,UUID affectedControllerId,Game game){
  Card card=game.getCard(sourceId);
  if (card != null && filter.match(card,game)) {
    Player player=game.getPlayer(card.getOwnerId());
    if (player != null && card.equals(player.getLibrary().getFromTop(game))) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(UUID objectId,Ability source,UUID affectedControllerId,Game game){
  Card cardOnTop=game.getCard(objectId);
  if (cardOnTop != null && affectedControllerId.equals(source.getControllerId()) && filter.match(cardOnTop,game)) {
    Player player=game.getPlayer(cardOnTop.getOwnerId());
    if (player != null && cardOnTop.equals(player.getLibrary().getFromTop(game))) {
      return true;
    }
  }
  return false;
}
Program: 159072
Project: 159072
Buggy source:
public void selectAttackers(Game game){
  if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.DECLARING_ATTACKERS,attackerId,attackerId))) {
    Player player=game.getPlayer(attackerId);
    checkAttackRequirements(player,game);
    if (!game.getPlayer(game.getActivePlayerId()).getAvailableAttackers(game).isEmpty()) {
      player.selectAttackers(game,attackerId);
    }
    if (game.isPaused() || game.gameOver(null)) {
      return;
    }
    checkAttackRestrictions(player,game);
    resumeSelectAttackers(game);
  }
}

Fixed version (ground truth):
public void selectAttackers(Game game){
  if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.DECLARING_ATTACKERS,attackerId,attackerId))) {
    Player player=game.getPlayer(attackerId);
    game.getCombat().checkAttackRequirements(player,game);
    if (!game.getPlayer(game.getActivePlayerId()).getAvailableAttackers(game).isEmpty()) {
      player.selectAttackers(game,attackerId);
    }
    if (game.isPaused() || game.gameOver(null)) {
      return;
    }
    game.getCombat().checkAttackRestrictions(player,game);
    game.getCombat().resumeSelectAttackers(game);
  }
}
Program: 159073
Project: 159073
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Permanent sourceObject=game.getPermanent(source.getSourceId());
  Permanent targetPermanent=null;
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    if (targetPointer.getFirst(game,source) != null) {
      targetPermanent=game.getPermanent(targetPointer.getFirst(game,source));
      if (targetPermanent != null) {
        ContinuousEffect effect=new ExchangeControlTargetEffect(Duration.EndOfGame,"String_Node_Str",true);
        effect.setTargetPointer(targetPointer);
        game.addEffect(effect,source);
      }
 else {
        sourceObject.sacrifice(source.getSourceId(),game);
      }
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Permanent sourceObject=game.getPermanent(source.getSourceId());
  Permanent targetPermanent;
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    if (targetPointer.getFirst(game,source) != null) {
      targetPermanent=game.getPermanent(targetPointer.getFirst(game,source));
      if (targetPermanent != null) {
        ContinuousEffect effect=new ExchangeControlTargetEffect(Duration.EndOfGame,"String_Node_Str",true);
        effect.setTargetPointer(targetPointer);
        game.addEffect(effect,source);
      }
 else {
        sourceObject.sacrifice(source.getSourceId(),game);
      }
    }
    return true;
  }
  return false;
}
Program: 159074
Project: 159074
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Set<UUID> toDelete=new HashSet<>();
  for (  Map.Entry<UUID,Integer> entry : zoneChangeCounter.entrySet()) {
    Permanent permanent=game.getPermanent(entry.getKey());
    if (permanent == null || permanent.getZoneChangeCounter() != entry.getValue()) {
      toDelete.add(entry.getKey());
      continue;
    }
    permanent.changeControllerId(lockedControllers.get(permanent.getId()),game);
  }
  if (!toDelete.isEmpty()) {
    for (    UUID uuid : toDelete) {
      zoneChangeCounter.remove(uuid);
    }
    if (zoneChangeCounter.isEmpty()) {
      discard();
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Set<UUID> toDelete=new HashSet<>();
  for (  Map.Entry<UUID,Integer> entry : zoneChangeCounter.entrySet()) {
    Permanent permanent=game.getPermanent(entry.getKey());
    if (permanent == null || permanent.getZoneChangeCounter() != entry.getValue()) {
      toDelete.add(entry.getKey());
      continue;
    }
    permanent.changeControllerId(lockedControllers.get(permanent.getId()),game);
    permanent.getAbilities().setControllerId(lockedControllers.get(permanent.getId()));
  }
  if (!toDelete.isEmpty()) {
    for (    UUID uuid : toDelete) {
      zoneChangeCounter.remove(uuid);
    }
    if (zoneChangeCounter.isEmpty()) {
      discard();
      return false;
    }
  }
  return true;
}
Program: 159075
Project: 159075
Buggy source:
@Override public Permanent copyPermanent(Duration duration,Permanent copyFromPermanent,Permanent copyToPermanent,Ability source,ApplyToPermanent applier){
  Permanent permanent=copyFromPermanent.copy();
  permanent.reset(this);
  if (copyFromPermanent.isMorphCard() && copyFromPermanent.isFaceDown()) {
    MorphAbility.setPermanentToMorph(permanent);
  }
  permanent.assignNewId();
  if (copyFromPermanent.isTransformed()) {
    TransformAbility.transform(permanent,copyFromPermanent.getSecondCardFace(),this);
  }
  applier.apply(this,permanent);
  Ability newAbility=source.copy();
  CopyEffect newEffect=new CopyEffect(duration,permanent,copyToPermanent.getId());
  newEffect.newId();
  newEffect.setApplier(applier);
  newEffect.init(newAbility,this);
  for (  Effect effect : getState().getContinuousEffects().getLayeredEffects(this)) {
    if (effect instanceof CopyEffect) {
      CopyEffect copyEffect=(CopyEffect)effect;
      if (copyEffect.getSourceId().equals(copyFromPermanent.getId())) {
        MageObject object=((CopyEffect)effect).getTarget();
        if (object instanceof Permanent) {
          Permanent original=(Permanent)object;
          original=original.copy();
          applier.apply(this,original);
          newEffect.setTarget(object);
        }
      }
    }
  }
  state.addEffect(newEffect,newAbility);
  return permanent;
}

Fixed version (ground truth):
@Override public Permanent copyPermanent(Duration duration,Permanent copyFromPermanent,Permanent copyToPermanent,Ability source,ApplyToPermanent applier){
  Permanent permanent=copyFromPermanent.copy();
  permanent.reset(this);
  if (copyFromPermanent.isMorphCard() && copyFromPermanent.isFaceDown()) {
    MorphAbility.setPermanentToMorph(permanent);
  }
  permanent.assignNewId();
  if (copyFromPermanent.isTransformed()) {
    TransformAbility.transform(permanent,copyFromPermanent.getSecondCardFace(),this);
  }
  applier.apply(this,permanent);
  CopyEffect newEffect=new CopyEffect(duration,permanent,copyToPermanent.getId());
  newEffect.newId();
  newEffect.setApplier(applier);
  Ability newAbility=source.copy();
  newEffect.init(newAbility,this);
  for (  Effect effect : getState().getContinuousEffects().getLayeredEffects(this)) {
    if (effect instanceof CopyEffect) {
      CopyEffect copyEffect=(CopyEffect)effect;
      if (copyEffect.getSourceId().equals(copyFromPermanent.getId())) {
        MageObject object=((CopyEffect)effect).getTarget();
        if (object instanceof Permanent) {
          Permanent original=(Permanent)object;
          original=original.copy();
          applier.apply(this,original);
          newEffect.setTarget(object);
        }
      }
    }
  }
  state.addEffect(newEffect,newAbility);
  return permanent;
}
Program: 159076
Project: 159076
Buggy source:
@Override public boolean applies(GameEvent event,Ability source,Game game){
  player1=(Player)game.getState().getValue(source.getSourceId() + "String_Node_Str");
  player2=(Player)game.getState().getValue(source.getSourceId() + "String_Node_Str");
  if (player1 != null && player2 != null) {
    UUID targetPlayerId=null;
switch (event.getType()) {
case DAMAGE_PLAYER:
      targetPlayerId=event.getTargetId();
    break;
case DAMAGE_CREATURE:
case DAMAGED_PLANESWALKER:
  Permanent permanent=game.getPermanent(event.getTargetId());
if (permanent != null) {
  targetPlayerId=permanent.getControllerId();
}
break;
default :
return false;
}
if (player1.getId().equals(targetPlayerId) || player2.getId().equals(targetPlayerId)) {
UUID sourcePlayerId=null;
MageObject damageSource=game.getObject(event.getSourceId());
if (damageSource instanceof StackObject) {
sourcePlayerId=((StackObject)damageSource).getControllerId();
}
 else if (damageSource instanceof Permanent) {
sourcePlayerId=((Permanent)damageSource).getControllerId();
}
 else if (damageSource instanceof Card) {
sourcePlayerId=((Card)damageSource).getOwnerId();
}
if (sourcePlayerId != null && (player1.getId().equals(sourcePlayerId) || player2.getId().equals(sourcePlayerId)) && !sourcePlayerId.equals(targetPlayerId)) {
return true;
}
}
}
return false;
}

Fixed version (ground truth):
@Override public boolean applies(GameEvent event,Ability source,Game game){
  player1=(Player)game.getState().getValue(source.getSourceId() + "String_Node_Str");
  player2=(Player)game.getState().getValue(source.getSourceId() + "String_Node_Str");
  if (player1 != null && player2 != null) {
    UUID targetPlayerId=null;
switch (event.getType()) {
case DAMAGE_PLAYER:
      targetPlayerId=event.getTargetId();
    break;
case DAMAGE_CREATURE:
case DAMAGE_PLANESWALKER:
  Permanent permanent=game.getPermanent(event.getTargetId());
if (permanent != null) {
  targetPlayerId=permanent.getControllerId();
}
break;
default :
return false;
}
if (player1.getId().equals(targetPlayerId) || player2.getId().equals(targetPlayerId)) {
UUID sourcePlayerId=null;
MageObject damageSource=game.getObject(event.getSourceId());
if (damageSource instanceof StackObject) {
sourcePlayerId=((StackObject)damageSource).getControllerId();
}
 else if (damageSource instanceof Permanent) {
sourcePlayerId=((Permanent)damageSource).getControllerId();
}
 else if (damageSource instanceof Card) {
sourcePlayerId=((Card)damageSource).getOwnerId();
}
if (sourcePlayerId != null && (player1.getId().equals(sourcePlayerId) || player2.getId().equals(sourcePlayerId)) && !sourcePlayerId.equals(targetPlayerId)) {
return true;
}
}
}
return false;
}
Program: 159077
Project: 159077
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player you=game.getPlayer(source.getControllerId());
  if (you == null) {
    return false;
  }
  Permanent arsenalThresher=game.getPermanent(source.getSourceId());
  FilterArtifactCard filter=new FilterArtifactCard();
  filter.add(new AnotherPredicate());
  if (you.chooseUse(Outcome.Benefit,"String_Node_Str",game)) {
    Cards cards=new CardsImpl();
    if (you.getHand().count(filter,source.getSourceId(),source.getControllerId(),game) > 0) {
      TargetCardInHand target=new TargetCardInHand(0,Integer.MAX_VALUE,filter);
      if (you.choose(Outcome.Benefit,target,source.getSourceId(),game)) {
        for (        UUID uuid : target.getTargets()) {
          cards.add(you.getHand().get(uuid,game));
        }
        you.revealCards("String_Node_Str",cards,game);
        if (arsenalThresher != null) {
          arsenalThresher.addCounters(CounterType.P1P1.createInstance(cards.size()),game);
          return true;
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player you=game.getPlayer(source.getControllerId());
  if (you == null) {
    return false;
  }
  Permanent arsenalThresher=game.getPermanent(source.getSourceId());
  FilterArtifactCard filter=new FilterArtifactCard();
  filter.add(new AnotherCardPredicate());
  if (you.chooseUse(Outcome.Benefit,"String_Node_Str",game)) {
    Cards cards=new CardsImpl();
    if (you.getHand().count(filter,source.getSourceId(),source.getControllerId(),game) > 0) {
      TargetCardInHand target=new TargetCardInHand(0,Integer.MAX_VALUE,filter);
      if (you.choose(Outcome.Benefit,target,source.getSourceId(),game)) {
        for (        UUID uuid : target.getTargets()) {
          cards.add(you.getHand().get(uuid,game));
        }
        you.revealCards("String_Node_Str",cards,game);
        if (arsenalThresher != null) {
          arsenalThresher.addCounters(CounterType.P1P1.createInstance(cards.size()),game);
          return true;
        }
      }
    }
  }
  return false;
}
Program: 159078
Project: 159078
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Permanent creature=null;
  if (fixedTarget) {
    creature=game.getPermanent(targetPointer.getFirst(game,source));
  }
 else {
    Permanent equipment=game.getPermanent(source.getSourceId());
    if (equipment != null && equipment.getAttachedTo() != null) {
      creature=game.getPermanent(equipment.getAttachedTo());
    }
  }
  if (creature != null) {
    creature.addAbility(ability,source.getSourceId(),game);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Permanent creature=null;
  if (fixedTarget) {
    creature=game.getPermanent(targetPointer.getFirst(game,source));
  }
 else {
    Permanent equipment=game.getPermanent(source.getSourceId());
    if (equipment != null && equipment.getAttachedTo() != null) {
      creature=game.getPermanent(equipment.getAttachedTo());
    }
  }
  if (creature != null) {
    creature.addAbility(ability,source.getSourceId(),game,false);
  }
  return true;
}
Program: 159079
Project: 159079
Buggy source:
@Override public boolean apply(Game game,Ability source){
  int value=amount.calculate(game,source,this);
  Token tokenCopy=token.copy();
  tokenCopy.getAbilities().newId();
  tokenCopy.putOntoBattlefield(value,game,source.getSourceId(),source.getControllerId(),tapped,attacking);
  this.lastAddedTokenId=tokenCopy.getLastAddedToken();
  this.lastAddedTokenIds=tokenCopy.getLastAddedTokenIds();
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  int value=amount.calculate(game,source,this);
  token.putOntoBattlefield(value,game,source.getSourceId(),source.getControllerId(),tapped,attacking);
  this.lastAddedTokenId=token.getLastAddedToken();
  this.lastAddedTokenIds=token.getLastAddedTokenIds();
  return true;
}
Program: 159080
Project: 159080
Buggy source:
@Override public String getText(Mode mode){
  StringBuilder sb=new StringBuilder();
  sb.append("String_Node_Str");
  if (mode != null) {
    sb.append(mode.getTargets().get(0).getTargetName());
  }
  return sb.toString();
}

Fixed version (ground truth):
@Override public String getText(Mode mode){
  if (staticText != null && !staticText.isEmpty()) {
    return staticText;
  }
  StringBuilder sb=new StringBuilder();
  sb.append("String_Node_Str");
  Target target=mode.getTargets().get(0);
  if (target != null) {
    if (!target.getTargetName().toLowerCase().startsWith("String_Node_Str")) {
      sb.append("String_Node_Str");
    }
    sb.append(target.getTargetName());
  }
  return sb.toString();
}
Program: 159081
Project: 159081
Buggy source:
@Override public void reset(Game game){
  Token tokenCopy=token.copy();
  copyFromToken(tokenCopy,game,true);
  super.reset(game);
}

Fixed version (ground truth):
@Override public void reset(Game game){
  copyFromToken(token,game,true);
  super.reset(game);
}
Program: 159082
Project: 159082
Buggy source:
@Override public boolean applies(GameEvent event,Ability source,Game game){
  if (event.getType() == EventType.DRAW_CARD) {
    if (game.getActivePlayerId().equals(event.getPlayerId())) {
      CardsDrawnDuringDrawStepWatcher watcher=(CardsDrawnDuringDrawStepWatcher)game.getState().getWatchers().get("String_Node_Str");
      if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) > 0) {
        return true;
      }
    }
 else {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(GameEvent event,Ability source,Game game){
  if (event.getType() == EventType.DRAW_CARD) {
    if (game.getActivePlayerId().equals(event.getPlayerId()) && game.getPhase().getStep().getType().equals(PhaseStep.DRAW)) {
      CardsDrawnDuringDrawStepWatcher watcher=(CardsDrawnDuringDrawStepWatcher)game.getState().getWatchers().get("String_Node_Str");
      if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) > 0) {
        return true;
      }
    }
 else {
      return true;
    }
  }
  return false;
}
Program: 159083
Project: 159083
Buggy source:
/** 
 * Tests if Misdirection for target opponent works correctly https://github.com/magefree/mage/issues/574
 */
@Test public void testChangeTargetOpponent(){
  addCard(Zone.HAND,playerA,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",3);
  addCard(Zone.HAND,playerB,"String_Node_Str");
  addCard(Zone.HAND,playerB,"String_Node_Str",2);
  addCard(Zone.BATTLEFIELD,playerB,"String_Node_Str",5);
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str",playerB);
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerB,"String_Node_Str","String_Node_Str","String_Node_Str");
  addTarget(playerA,playerA);
  setStopAt(1,PhaseStep.BEGIN_COMBAT);
  execute();
  assertGraveyardCount(playerA,"String_Node_Str",1);
  assertGraveyardCount(playerB,"String_Node_Str",1);
  assertHandCount(playerB,"String_Node_Str",2);
}

Fixed version (ground truth):
/** 
 * Tests if Misdirection for target opponent works correctly https://github.com/magefree/mage/issues/574
 */
@Test public void testChangeTargetOpponent(){
  addCard(Zone.HAND,playerA,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",3);
  addCard(Zone.HAND,playerB,"String_Node_Str");
  addCard(Zone.HAND,playerB,"String_Node_Str",2);
  addCard(Zone.BATTLEFIELD,playerB,"String_Node_Str",5);
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str",playerB);
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerB,"String_Node_Str","String_Node_Str","String_Node_Str");
  addTarget(playerB,playerA);
  setStopAt(1,PhaseStep.BEGIN_COMBAT);
  execute();
  assertGraveyardCount(playerA,"String_Node_Str",1);
  assertGraveyardCount(playerB,"String_Node_Str",1);
  assertHandCount(playerB,"String_Node_Str",0);
}
Program: 159084
Project: 159084
Buggy source:
@Override public void init(Ability source,Game game){
  super.init(source,game);
  if (affectedObjectsSet) {
    affectedObjectList.add(new MageObjectReference(source.getSourceId(),game));
  }
}

Fixed version (ground truth):
@Override public void init(Ability source,Game game){
  super.init(source,game);
  if (affectedObjectsSet) {
    affectedObjectList.add(new MageObjectReference(sourceId,game));
  }
}
Program: 159086
Project: 159086
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getControllerId());
  Permanent permanent=game.getPermanent(source.getSourceId());
  if (player != null && permanent != null) {
    Choice typeChoice=new ChoiceImpl(true);
    typeChoice.setMessage("String_Node_Str");
    typeChoice.setChoices(CardRepository.instance.getCreatureTypes());
    while (!player.choose(Outcome.Detriment,typeChoice,game)) {
      if (!player.isInGame()) {
        return false;
      }
    }
    game.informPlayers(permanent.getName() + "String_Node_Str" + player.getName()+ "String_Node_Str"+ typeChoice.getChoice());
    game.getState().setValue(permanent.getId() + "String_Node_Str",typeChoice.getChoice().toString());
    permanent.addInfo("String_Node_Str","String_Node_Str" + typeChoice.getChoice() + "String_Node_Str");
    permanent.getSubtype().add(typeChoice.getChoice());
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getControllerId());
  Permanent permanent=game.getPermanent(source.getSourceId());
  if (player != null && permanent != null) {
    Choice typeChoice=new ChoiceImpl(true);
    typeChoice.setMessage("String_Node_Str");
    typeChoice.setChoices(CardRepository.instance.getCreatureTypes());
    while (!player.choose(Outcome.Detriment,typeChoice,game)) {
      if (!player.isInGame()) {
        return false;
      }
    }
    game.informPlayers(permanent.getName() + "String_Node_Str" + player.getName()+ "String_Node_Str"+ typeChoice.getChoice());
    ContinuousEffect effect=new AddCardSubTypeTargetEffect(typeChoice.getChoice(),Duration.EndOfTurn);
    effect.setTargetPointer(new FixedTarget(permanent.getId()));
    game.addEffect(effect,source);
  }
  return false;
}
Program: 159087
Project: 159087
Buggy source:
@Override public boolean isLegal(Ability source,Game game){
  Set<UUID> illegalTargets=new HashSet<>();
  int replacedTargets=0;
  for (  UUID targetId : targets.keySet()) {
    Card card=game.getCard(targetId);
    if (card != null) {
      if (zoneChangeCounters.containsKey(targetId) && zoneChangeCounters.get(targetId) != card.getZoneChangeCounter()) {
        illegalTargets.add(targetId);
        continue;
      }
    }
    if (!notTarget && game.replaceEvent(GameEvent.getEvent(EventType.TARGET,targetId,source.getSourceId(),source.getControllerId()))) {
      replacedTargets++;
      continue;
    }
    if (!canTarget(targetId,source,game)) {
      illegalTargets.add(targetId);
    }
  }
  for (  UUID targetId : illegalTargets) {
    targets.remove(targetId);
  }
  if (replacedTargets > 0 && replacedTargets == targets.size()) {
    return false;
  }
  if (minNumberOfTargets == 0 && targets.isEmpty()) {
    return true;
  }
  return targets.size() > 0;
}

Fixed version (ground truth):
@Override public boolean isLegal(Ability source,Game game){
  Set<UUID> illegalTargets=new HashSet<>();
  for (  UUID targetId : targets.keySet()) {
    Card card=game.getCard(targetId);
    if (card != null) {
      if (zoneChangeCounters.containsKey(targetId) && zoneChangeCounters.get(targetId) != card.getZoneChangeCounter()) {
        illegalTargets.add(targetId);
        continue;
      }
    }
    if (!notTarget && game.replaceEvent(GameEvent.getEvent(EventType.TARGET,targetId,source.getSourceId(),source.getControllerId()))) {
      illegalTargets.add(targetId);
      continue;
    }
    if (!canTarget(targetId,source,game)) {
      illegalTargets.add(targetId);
    }
  }
  for (  UUID targetId : illegalTargets) {
    targets.remove(targetId);
  }
  if (minNumberOfTargets == 0 && targets.isEmpty()) {
    return true;
  }
  return targets.size() > 0;
}
Program: 159090
Project: 159090
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Permanent targetCreature=game.getPermanent(source.getFirstTarget());
  if (targetCreature != null) {
    Player player=game.getPlayer(targetCreature.getControllerId());
    if (player != null) {
      cost.clearPaid();
      final StringBuilder sb=new StringBuilder("String_Node_Str").append(targetCreature.getName()).append("String_Node_Str");
      if (player.chooseUse(Outcome.Benefit,sb.toString(),game)) {
        cost.pay(source,game,targetCreature.getControllerId(),targetCreature.getControllerId(),true);
      }
      if (!cost.isPaid()) {
        return targetCreature.moveToZone(Zone.HAND,source.getSourceId(),game,true);
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Permanent targetCreature=game.getPermanent(source.getFirstTarget());
  if (targetCreature != null) {
    Player player=game.getPlayer(targetCreature.getControllerId());
    if (player != null) {
      cost.clearPaid();
      final StringBuilder sb=new StringBuilder("String_Node_Str").append(targetCreature.getName()).append("String_Node_Str");
      if (player.chooseUse(Outcome.Benefit,sb.toString(),game)) {
        cost.pay(source,game,targetCreature.getControllerId(),targetCreature.getControllerId(),false);
      }
      if (!cost.isPaid()) {
        return targetCreature.moveToZone(Zone.HAND,source.getSourceId(),game,true);
      }
    }
  }
  return false;
}
Program: 159091
Project: 159091
Buggy source:
@Override public void handleConnectionException(Throwable throwable,Client client){
  Session session=SessionManager.getInstance().getSession(client.getSessionId());
  if (session != null) {
    StringBuilder sessionInfo=new StringBuilder();
    User user=UserManager.getInstance().getUser(session.getUserId());
    if (user != null) {
      sessionInfo.append(user.getName());
    }
 else {
      sessionInfo.append("String_Node_Str");
    }
    sessionInfo.append("String_Node_Str").append(session.getHost()).append("String_Node_Str").append(session.getId());
    if (throwable instanceof ClientDisconnectedException) {
      SessionManager.getInstance().disconnect(client.getSessionId(),DisconnectReason.LostConnection);
      logger.info("String_Node_Str" + sessionInfo,throwable);
      if (logger.isDebugEnabled()) {
        throwable.printStackTrace();
      }
    }
 else {
      SessionManager.getInstance().disconnect(client.getSessionId(),DisconnectReason.LostConnection);
      logger.info("String_Node_Str" + sessionInfo,throwable);
      if (logger.isDebugEnabled()) {
        if (throwable == null) {
          logger.debug("String_Node_Str");
        }
 else {
          throwable.printStackTrace();
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override public void handleConnectionException(Throwable throwable,Client client){
  Session session=SessionManager.getInstance().getSession(client.getSessionId());
  if (session != null) {
    StringBuilder sessionInfo=new StringBuilder();
    User user=UserManager.getInstance().getUser(session.getUserId());
    if (user != null) {
      sessionInfo.append(user.getName());
    }
 else {
      sessionInfo.append("String_Node_Str");
    }
    sessionInfo.append("String_Node_Str").append(session.getHost()).append("String_Node_Str").append(session.getId());
    if (throwable instanceof ClientDisconnectedException) {
      SessionManager.getInstance().disconnect(client.getSessionId(),DisconnectReason.LostConnection);
      logger.info("String_Node_Str" + sessionInfo,throwable);
      logger.debug("String_Node_Str",throwable);
    }
 else {
      SessionManager.getInstance().disconnect(client.getSessionId(),DisconnectReason.LostConnection);
      logger.info("String_Node_Str" + sessionInfo);
      if (logger.isDebugEnabled()) {
        if (throwable == null) {
          logger.debug("String_Node_Str");
        }
 else {
          logger.debug("String_Node_Str" + Session.getBasicCause(throwable).toString());
        }
      }
    }
  }
}
Program: 159092
Project: 159092
Buggy source:
public void userLostConnection(){
  try {
    if (lock.tryLock(5,TimeUnit.SECONDS)) {
      User user=UserManager.getInstance().getUser(userId);
      if (user == null || !user.isConnected()) {
        return;
      }
      if (!user.getSessionId().equals(sessionId)) {
        logger.info("String_Node_Str" + user.getName());
        return;
      }
      logger.info("String_Node_Str" + user.getName());
      UserManager.getInstance().disconnect(userId,DisconnectReason.LostConnection);
    }
 else {
      logger.error("String_Node_Str" + userId);
    }
  }
 catch (  InterruptedException ex) {
    logger.error("String_Node_Str" + userId,ex);
  }
 finally {
    lock.unlock();
  }
}

Fixed version (ground truth):
public void userLostConnection(){
  boolean lockSet=false;
  try {
    if (lock.tryLock(500,TimeUnit.MILLISECONDS)) {
      lockSet=true;
      User user=UserManager.getInstance().getUser(userId);
      if (user == null || !user.isConnected()) {
        return;
      }
      if (!user.getSessionId().equals(sessionId)) {
        logger.info("String_Node_Str" + user.getName());
        return;
      }
      logger.info("String_Node_Str" + user.getName() + "String_Node_Str"+ userId);
      UserManager.getInstance().disconnect(userId,DisconnectReason.LostConnection);
    }
 else {
      logger.error("String_Node_Str" + userId);
    }
  }
 catch (  InterruptedException ex) {
    logger.error("String_Node_Str" + userId,ex);
  }
 finally {
    if (lockSet) {
      lock.unlock();
    }
  }
}
Program: 159093
Project: 159093
Buggy source:
public void fireCallback(final ClientCallback call){
  try {
    boolean tryLock;
    if (lock.tryLock(5,TimeUnit.SECONDS)) {
      call.setMessageId(messageId++);
      callbackHandler.handleCallbackOneway(new Callback(call));
    }
 else {
      logger.error("String_Node_Str" + userId);
      logger.error("String_Node_Str" + call.getMethod());
    }
  }
 catch (  HandleCallbackException ex) {
    logger.info("String_Node_Str" + userId,ex);
    if (logger.isDebugEnabled()) {
      ex.printStackTrace();
    }
    userLostConnection();
  }
catch (  InterruptedException ex) {
    logger.error("String_Node_Str" + userId,ex);
    logger.error("String_Node_Str" + call.getMethod());
  }
 finally {
    lock.unlock();
  }
}

Fixed version (ground truth):
public void fireCallback(final ClientCallback call){
  boolean lockSet=false;
  try {
    if (lock.tryLock(500,TimeUnit.MILLISECONDS)) {
      lockSet=true;
      call.setMessageId(messageId++);
      callbackHandler.handleCallbackOneway(new Callback(call));
    }
 else {
      logger.error("String_Node_Str" + userId);
      logger.error("String_Node_Str" + call.getMethod());
    }
  }
 catch (  HandleCallbackException ex) {
    User user=UserManager.getInstance().getUser(userId);
    logger.warn("String_Node_Str" + (user != null ? user.getName() : "String_Node_Str") + "String_Node_Str"+ userId);
    logger.warn("String_Node_Str" + call.getMethod());
    logger.warn("String_Node_Str" + getBasicCause(ex).toString());
    logger.trace("String_Node_Str",ex);
    userLostConnection();
  }
catch (  InterruptedException ex) {
    logger.error("String_Node_Str" + userId);
    logger.error("String_Node_Str" + call.getMethod());
    logger.error("String_Node_Str" + getBasicCause(ex).toString());
    logger.trace("String_Node_Str",ex);
  }
 finally {
    if (lockSet) {
      lock.unlock();
    }
  }
}
Program: 159094
Project: 159094
Buggy source:
public void kill(DisconnectReason reason){
  UserManager.getInstance().removeUser(userId,reason);
}

Fixed version (ground truth):
public void kill(DisconnectReason reason){
  boolean lockSet=false;
  try {
    if (lock.tryLock(500,TimeUnit.MILLISECONDS)) {
      lockSet=true;
      UserManager.getInstance().removeUser(userId,reason);
    }
 else {
      logger.error("String_Node_Str" + userId);
    }
  }
 catch (  InterruptedException ex) {
    logger.error("String_Node_Str" + userId,ex);
  }
 finally {
    if (lockSet) {
      lock.unlock();
    }
  }
}
Program: 159095
Project: 159095
Buggy source:
public void disconnect(String sessionId,DisconnectReason reason){
  Session session=sessions.get(sessionId);
  if (session != null) {
    if (!reason.equals(DisconnectReason.AdminDisconnect)) {
synchronized (session) {
        if (!sessions.containsKey(sessionId)) {
          return;
        }
        sessions.remove(sessionId);
switch (reason) {
case Disconnected:
          session.kill(reason);
        LogServiceImpl.instance.log(LogKeys.KEY_SESSION_KILLED,sessionId);
      break;
case SessionExpired:
    session.kill(reason);
  LogServiceImpl.instance.log(LogKeys.KEY_SESSION_EXPIRED,sessionId);
break;
case LostConnection:
session.userLostConnection();
LogServiceImpl.instance.log(LogKeys.KEY_SESSION_DISCONNECTED,sessionId);
break;
default :
logger.error("String_Node_Str" + reason.toString() + "String_Node_Str"+ sessionId);
}
}
}
 else {
sessions.remove(sessionId);
session.kill(reason);
}
}
}

Fixed version (ground truth):
public void disconnect(String sessionId,DisconnectReason reason){
  Session session=sessions.get(sessionId);
  if (session != null) {
    if (!reason.equals(DisconnectReason.AdminDisconnect)) {
      if (!sessions.containsKey(sessionId)) {
        return;
      }
      sessions.remove(sessionId);
switch (reason) {
case Disconnected:
        session.kill(reason);
      LogServiceImpl.instance.log(LogKeys.KEY_SESSION_KILLED,sessionId);
    break;
case SessionExpired:
  session.kill(reason);
LogServiceImpl.instance.log(LogKeys.KEY_SESSION_EXPIRED,sessionId);
break;
case LostConnection:
session.userLostConnection();
LogServiceImpl.instance.log(LogKeys.KEY_SESSION_DISCONNECTED,sessionId);
break;
default :
logger.error("String_Node_Str" + reason.toString() + "String_Node_Str"+ sessionId);
}
}
 else {
sessions.remove(sessionId);
session.kill(reason);
}
}
}
Program: 159096
Project: 159096
Buggy source:
public void setSessionId(String sessionId){
  this.sessionId=sessionId;
  if (sessionId.isEmpty()) {
    userState=UserState.Disconnected;
    logger.debug("String_Node_Str" + userName + "String_Node_Str"+ userId);
  }
 else   if (userState == UserState.Created) {
    userState=UserState.Connected;
    logger.debug("String_Node_Str" + userName + "String_Node_Str"+ userId);
  }
 else {
    userState=UserState.Reconnected;
    reconnect();
    logger.info("String_Node_Str" + userName + "String_Node_Str"+ userId);
  }
}

Fixed version (ground truth):
public void setSessionId(String sessionId){
  this.sessionId=sessionId;
  if (sessionId.isEmpty()) {
    userState=UserState.Disconnected;
    lostConnection();
    logger.debug("String_Node_Str" + userName + "String_Node_Str"+ userId);
  }
 else   if (userState == UserState.Created) {
    userState=UserState.Connected;
    logger.debug("String_Node_Str" + userName + "String_Node_Str"+ userId);
  }
 else {
    userState=UserState.Reconnected;
    reconnect();
    logger.info("String_Node_Str" + userName + "String_Node_Str"+ userId);
  }
}
Program: 159097
Project: 159097
Buggy source:
@Override protected void init(UUID choosingPlayerId,GameOptions gameOptions){
  super.init(choosingPlayerId,gameOptions);
  Ability ability=new SimpleStaticAbility(Zone.COMMAND,new EmptyEffect("String_Node_Str"));
  for (  UUID playerId : state.getPlayerList(startingPlayerId)) {
    Player player=getPlayer(playerId);
    if (player != null) {
      if (player.getSideboard().size() > 0) {
        Card commander=getCard((UUID)player.getSideboard().toArray()[0]);
        if (commander != null) {
          player.setCommanderId(commander.getId());
          commander.moveToZone(Zone.COMMAND,null,this,true);
          ability.addEffect(new CommanderReplacementEffect(commander.getId(),alsoLibrary));
          ability.addEffect(new CommanderCostModification(commander.getId()));
          ability.addEffect(new CommanderManaReplacementEffect(player.getId(),commander.getSpellAbility().getManaCosts().getMana()));
          getState().setValue(commander.getId() + "String_Node_Str",0);
          CommanderCombatDamageWatcher watcher=new CommanderCombatDamageWatcher(commander.getId());
          getState().getWatchers().add(watcher);
          this.commanderCombatWatcher.add(watcher);
          watcher.addCardInfoToCommander(this);
        }
      }
    }
  }
  this.getState().addAbility(ability,this.getId(),null);
  state.getTurnMods().add(new TurnMod(startingPlayerId,PhaseStep.DRAW));
}

Fixed version (ground truth):
@Override protected void init(UUID choosingPlayerId,GameOptions gameOptions){
  super.init(choosingPlayerId,gameOptions);
  Ability ability=new SimpleStaticAbility(Zone.COMMAND,new EmptyEffect("String_Node_Str"));
  for (  UUID playerId : state.getPlayerList(startingPlayerId)) {
    Player player=getPlayer(playerId);
    if (player != null) {
      if (player.getSideboard().size() > 0) {
        Card commander=getCard((UUID)player.getSideboard().toArray()[0]);
        if (commander != null) {
          player.setCommanderId(commander.getId());
          commander.moveToZone(Zone.COMMAND,null,this,true);
          ability.addEffect(new CommanderReplacementEffect(commander.getId(),alsoLibrary));
          ability.addEffect(new CommanderCostModification(commander.getId()));
          Mana commanderMana;
          if (commander.getSpellAbility().getManaCosts() == null) {
            Logger.getLogger(GameCommanderImpl.class).warn("String_Node_Str" + commander.getName());
            commanderMana=new Mana();
          }
 else {
            commanderMana=commander.getSpellAbility().getManaCosts().getMana();
          }
          ability.addEffect(new CommanderManaReplacementEffect(player.getId(),commanderMana));
          getState().setValue(commander.getId() + "String_Node_Str",0);
          CommanderCombatDamageWatcher watcher=new CommanderCombatDamageWatcher(commander.getId());
          getState().getWatchers().add(watcher);
          this.commanderCombatWatcher.add(watcher);
          watcher.addCardInfoToCommander(this);
        }
      }
    }
  }
  this.getState().addAbility(ability,this.getId(),null);
  state.getTurnMods().add(new TurnMod(startingPlayerId,PhaseStep.DRAW));
}
Program: 159098
Project: 159098
Buggy source:
@Override public boolean moveToZone(Zone zone,UUID sourceId,Game game,boolean flag){
  if (!game.replaceEvent(new ZoneChangeEvent(this,this.getControllerId(),Zone.BATTLEFIELD,zone))) {
    game.rememberLKI(objectId,Zone.BATTLEFIELD,this);
    if (game.getPlayer(controllerId).removeFromBattlefield(this,game)) {
      game.fireEvent(new ZoneChangeEvent(this,this.getControllerId(),Zone.BATTLEFIELD,zone));
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean moveToZone(Zone zone,UUID sourceId,Game game,boolean flag){
  if (!game.replaceEvent(new ZoneChangeEvent(this,this.getControllerId(),Zone.BATTLEFIELD,zone))) {
    game.rememberLKI(objectId,Zone.BATTLEFIELD,this);
    if (game.getPlayer(controllerId).removeFromBattlefield(this,game)) {
      game.setZone(objectId,zone);
      game.fireEvent(new ZoneChangeEvent(this,this.getControllerId(),Zone.BATTLEFIELD,zone));
      game.getState().resetTriggersForSourceId(this.getId());
      game.getState().getContinuousEffects().removeGainedEffectsForSource(this.getId());
      return true;
    }
  }
  return false;
}
Program: 159099
Project: 159099
Buggy source:
@Override public boolean applies(UUID objectId,Ability source,UUID affectedControllerId,Game game){
  return source.getControllerId().equals(affectedControllerId) && targetPointer.getFirst(game,source).equals(objectId) && game.getState().getZone(objectId) == Zone.GRAVEYARD;
}

Fixed version (ground truth):
@Override public boolean applies(UUID objectId,Ability source,UUID affectedControllerId,Game game){
  UUID targetId=getTargetPointer().getFirst(game,source);
  if (targetId != null) {
    return targetId.equals(objectId) && source.getControllerId().equals(affectedControllerId) && Zone.GRAVEYARD.equals(game.getState().getZone(objectId));
  }
 else {
    discard();
    return false;
  }
}
Program: 159100
Project: 159100
Buggy source:
@Override public void run(){
  try {
    tappedAngle=isTapped() ? CardPanel.TAPPED_ANGLE : 0;
    flippedAngle=isFlipped() ? CardPanel.FLIPPED_ANGLE : 0;
    if (gameCard.isFaceDown()) {
      return;
    }
    BufferedImage srcImage=ImageCache.getThumbnail(gameCard);
    if (srcImage != null) {
      hasImage=true;
      setText(gameCard);
      setImage(srcImage);
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
catch (  Error err) {
    err.printStackTrace();
  }
}

Fixed version (ground truth):
@Override public void run(){
  try {
    tappedAngle=isTapped() ? CardPanel.TAPPED_ANGLE : 0;
    flippedAngle=isFlipped() ? CardPanel.FLIPPED_ANGLE : 0;
    BufferedImage srcImage;
    if (gameCard.isFaceDown()) {
      if (gameCard.isMorphCard()) {
        srcImage=ImageCache.getMorphImage();
      }
 else {
        srcImage=ImageCache.loadImage(new TFile(DirectLinksForDownload.outDir + File.separator + DirectLinksForDownload.cardbackFilename));
      }
    }
 else {
      srcImage=ImageCache.getThumbnail(gameCard);
    }
    if (srcImage != null) {
      hasImage=true;
      setText(gameCard);
      setImage(srcImage);
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
catch (  Error err) {
    err.printStackTrace();
  }
}
Program: 159101
Project: 159101
Buggy source:
@Override public void updateImage(){
  Util.threadPool.submit(new Runnable(){
    @Override public void run(){
      try {
        tappedAngle=isTapped() ? CardPanel.TAPPED_ANGLE : 0;
        flippedAngle=isFlipped() ? CardPanel.FLIPPED_ANGLE : 0;
        if (gameCard.isFaceDown()) {
          return;
        }
        BufferedImage srcImage=ImageCache.getThumbnail(gameCard);
        if (srcImage != null) {
          hasImage=true;
          setText(gameCard);
          setImage(srcImage);
        }
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
catch (      Error err) {
        err.printStackTrace();
      }
    }
  }
);
}

Fixed version (ground truth):
@Override public void updateImage(){
  Util.threadPool.submit(new Runnable(){
    @Override public void run(){
      try {
        tappedAngle=isTapped() ? CardPanel.TAPPED_ANGLE : 0;
        flippedAngle=isFlipped() ? CardPanel.FLIPPED_ANGLE : 0;
        BufferedImage srcImage;
        if (gameCard.isFaceDown()) {
          if (gameCard.isMorphCard()) {
            srcImage=ImageCache.getMorphImage();
          }
 else {
            srcImage=ImageCache.loadImage(new TFile(DirectLinksForDownload.outDir + File.separator + DirectLinksForDownload.cardbackFilename));
          }
        }
 else {
          srcImage=ImageCache.getThumbnail(gameCard);
        }
        if (srcImage != null) {
          hasImage=true;
          setText(gameCard);
          setImage(srcImage);
        }
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
catch (      Error err) {
        err.printStackTrace();
      }
    }
  }
);
}