nus-yam/ex-repair huggingface dataset:
Program: 160044
Project: 160044
Buggy source:
public TransformedCondition(){
}

Fixed version (ground truth):
/** 
 * The condition checks wether a permanent is transformed or not.
 * @param notCondition if true the condition is true when the permanent is not transformed
 * @return true if the condition is true, false if the condition is false
 */
public TransformedCondition(Boolean notCondition){
  this.notCondition=notCondition;
}
Program: 160045
Project: 160045
Buggy source:
@Override public String getRule(){
  return text;
}

Fixed version (ground truth):
@Override public String getRule(){
  if (text != null && text.isEmpty()) {
    return ability.getRule();
  }
  return text;
}
Program: 160046
Project: 160046
Buggy source:
/** 
 * Returns true if this abilities source is in the zone for the ability
 * @param game
 * @param checkLKI
 * @return 
 */
public boolean isInUseableZone(Game game,boolean checkLKI);

Fixed version (ground truth):
/** 
 * Returns true if this abilities source is in the zone for the ability
 * @param game
 * @param checkLKI
 * @return 
 */
public boolean isInUseableZone(Game game,MageObject source,boolean checkLKI);
Program: 160047
Project: 160047
Buggy source:
@Override public boolean isInUseableZone(Game game,boolean checkLKI){
  if (zone.equals(Zone.COMMAND)) {
    return true;
  }
  if (checkLKI) {
    MageObject lkiTest=game.getShortLivingLKI(getSourceId(),zone);
    if (lkiTest != null) {
      return true;
    }
  }
  if (!(this instanceof MageSingleton)) {
    MageObject object=game.getObject(getSourceId());
    if (object != null && !object.getAbilities().contains(this)) {
      boolean found=false;
      if (object instanceof PermanentCard && ((PermanentCard)object).canTransform()) {
        PermanentCard permanent=(PermanentCard)object;
        found=permanent.getSecondCardFace().getAbilities().contains(this) || permanent.getCard().getAbilities().contains(this);
      }
      if (!found) {
        return false;
      }
    }
  }
  Zone test=game.getState().getZone(sourceId);
  return test != null && zone.match(test);
}

Fixed version (ground truth):
@Override public boolean isInUseableZone(Game game,MageObject source,boolean checkLKI){
  if (zone.equals(Zone.COMMAND)) {
    return true;
  }
  if (checkLKI) {
    MageObject lkiTest=game.getShortLivingLKI(getSourceId(),zone);
    if (lkiTest != null) {
      return true;
    }
  }
  MageObject object;
  UUID sourceId;
  if (this instanceof MageSingleton && source != null) {
    object=source;
    sourceId=source.getId();
  }
 else {
    object=game.getObject(getSourceId());
    sourceId=getSourceId();
  }
  if (object != null && !object.getAbilities().contains(this)) {
    boolean found=false;
    if (object instanceof PermanentCard && ((PermanentCard)object).canTransform()) {
      PermanentCard permanent=(PermanentCard)object;
      found=permanent.getSecondCardFace().getAbilities().contains(this) || permanent.getCard().getAbilities().contains(this);
    }
    if (!found) {
      return false;
    }
  }
  Zone test=game.getState().getZone(sourceId);
  return test != null && zone.match(test);
}
Program: 160048
Project: 160048
Buggy source:
public void checkTriggers(GameEvent event,Game game){
  for (  TriggeredAbility ability : this.values()) {
    if (ability.isInUseableZone(game,true)) {
      MageObject object=getMageObject(event,game,ability);
      if (object != null) {
        if (checkAbilityStillExists(ability,object)) {
          if (object instanceof Permanent) {
            ability.setControllerId(((Permanent)object).getControllerId());
          }
          if (ability.checkTrigger(event,game)) {
            UUID controllerId=ability.getControllerId();
            ability.trigger(game,controllerId);
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
public void checkTriggers(GameEvent event,Game game){
  for (  TriggeredAbility ability : this.values()) {
    if (ability.isInUseableZone(game,null,true)) {
      MageObject object=getMageObject(event,game,ability);
      if (object != null) {
        if (checkAbilityStillExists(ability,object)) {
          if (object instanceof Permanent) {
            ability.setControllerId(((Permanent)object).getControllerId());
          }
          if (ability.checkTrigger(event,game)) {
            UUID controllerId=ability.getControllerId();
            ability.trigger(game,controllerId);
          }
        }
      }
    }
  }
}
Program: 160049
Project: 160049
Buggy source:
@Override public boolean isInUseableZone(Game game,boolean checkLKI){
  MageObject before=game.getLastKnownInformation(sourceId,Constants.Zone.BATTLEFIELD);
  Zone after=game.getState().getZone(sourceId);
  return before != null && after != null && Zone.GRAVEYARD.match(after);
}

Fixed version (ground truth):
@Override public boolean isInUseableZone(Game game,MageObject source,boolean checkLKI){
  MageObject before=game.getLastKnownInformation(sourceId,Constants.Zone.BATTLEFIELD);
  Zone after=game.getState().getZone(sourceId);
  return before != null && after != null && Zone.GRAVEYARD.match(after);
}
Program: 160050
Project: 160050
Buggy source:
@Override public boolean isInUseableZone(Game game,boolean checkLKI){
  throw new UnsupportedOperationException("String_Node_Str");
}

Fixed version (ground truth):
@Override public boolean isInUseableZone(Game game,MageObject source,boolean checkLKI){
  throw new UnsupportedOperationException("String_Node_Str");
}
Program: 160052
Project: 160052
Buggy source:
private void addPermanent(PermanentView permanent,final int count){
  if (cardDimension == null) {
    cardDimension=new Dimension(Config.dimensions.frameWidth,Config.dimensions.frameHeight);
  }
  final MagePermanent perm=Plugins.getInstance().getMagePermanent(permanent,bigCard,cardDimension,gameId,true);
  if (!Plugins.getInstance().isCardPluginLoaded()) {
    perm.setBounds(findEmptySpace(new Dimension(Config.dimensions.frameWidth,Config.dimensions.frameHeight)));
  }
 else {
  }
  permanents.put(permanent.getId(),perm);
  BattlefieldPanel.this.jPanel.add(perm,10);
  if (!Plugins.getInstance().isCardPluginLoaded()) {
    moveToFront(perm);
    perm.update(permanent);
  }
 else {
    moveToFront(jPanel);
    Plugins.getInstance().onAddCard(perm,1);
  }
  if (permanent.getCardTypes().contains(Constants.CardType.ARTIFACT)) {
    addedArtifact=true;
  }
 else   if (permanent.getCardTypes().contains(Constants.CardType.CREATURE)) {
    addedCreature=true;
  }
 else {
    addedPermanent=true;
  }
}

Fixed version (ground truth):
private void addPermanent(PermanentView permanent,final int count){
  if (cardDimension == null) {
    cardDimension=new Dimension(Config.dimensions.frameWidth,Config.dimensions.frameHeight);
  }
  final MagePermanent perm=Plugins.getInstance().getMagePermanent(permanent,bigCard,cardDimension,gameId,true);
  if (!Plugins.getInstance().isCardPluginLoaded()) {
  }
 else {
  }
  permanents.put(permanent.getId(),perm);
  BattlefieldPanel.this.jPanel.add(perm,10);
  if (!Plugins.getInstance().isCardPluginLoaded()) {
    moveToFront(perm);
    perm.update(permanent);
  }
 else {
    moveToFront(jPanel);
    Plugins.getInstance().onAddCard(perm,1);
  }
  if (permanent.getCardTypes().contains(Constants.CardType.ARTIFACT)) {
    addedArtifact=true;
  }
 else   if (permanent.getCardTypes().contains(Constants.CardType.CREATURE)) {
    addedCreature=true;
  }
 else {
    addedPermanent=true;
  }
}
Program: 160053
Project: 160053
Buggy source:
@Override public void init(Game game,boolean testMode){
  this.abort=false;
  if (!testMode) {
    this.hand.clear();
    this.graveyard.clear();
  }
  this.abilities.clear();
  this.counters.clear();
  this.wins=false;
  this.loses=false;
  this.left=false;
  this.passed=false;
  this.passedTurn=false;
  this.passedAllTurns=false;
  this.canGainLife=true;
  this.canLoseLife=true;
  game.getState().getWatchers().add(new BloodthirstWatcher(playerId));
}

Fixed version (ground truth):
@Override public void init(Game game,boolean testMode){
  this.abort=false;
  if (!testMode) {
    this.hand.clear();
    this.graveyard.clear();
  }
  this.library.reset();
  this.abilities.clear();
  this.counters.clear();
  this.wins=false;
  this.loses=false;
  this.left=false;
  this.passed=false;
  this.passedTurn=false;
  this.passedAllTurns=false;
  this.canGainLife=true;
  this.canLoseLife=true;
  game.getState().getWatchers().add(new BloodthirstWatcher(playerId));
}
Program: 160055
Project: 160055
Buggy source:
protected String getMessageText(Game game){
  StringBuilder sb=new StringBuilder();
  MageObject object=game.getObject(this.sourceId);
  if (object != null)   sb.append(object.getName());
 else   sb.append("String_Node_Str");
  if (getTargets().size() > 0) {
    sb.append("String_Node_Str");
    for (    Target target : getTargets()) {
      sb.append(target.getTargetedName(game));
    }
  }
  return sb.toString();
}

Fixed version (ground truth):
protected String getMessageText(Game game){
  StringBuilder sb=new StringBuilder();
  MageObject object=game.getObject(this.sourceId);
  if (object != null) {
    if (object instanceof StackAbility) {
      Card card=game.getCard(((StackAbility)object).getSourceId());
      if (card != null) {
        sb.append(card.getName());
      }
 else {
        sb.append(object.getName());
      }
    }
 else {
      sb.append(object.getName());
    }
  }
 else {
    sb.append("String_Node_Str");
  }
  if (getTargets().size() > 0) {
    sb.append("String_Node_Str");
    for (    Target target : getTargets()) {
      sb.append(target.getTargetedName(game));
    }
  }
  return sb.toString();
}
Program: 160057
Project: 160057
Buggy source:
@Override public boolean putOntoBattlefield(Game game,Zone fromZone,UUID sourceId,UUID controllerId){
  ZoneChangeEvent event=new ZoneChangeEvent(this.objectId,sourceId,controllerId,fromZone,Zone.BATTLEFIELD);
  if (!game.replaceEvent(event)) {
    if (fromZone != null) {
      boolean removed=false;
switch (fromZone) {
case GRAVEYARD:
        removed=game.getPlayer(ownerId).removeFromGraveyard(this,game);
      break;
case HAND:
    removed=game.getPlayer(ownerId).removeFromHand(this,game);
  break;
case LIBRARY:
removed=game.getPlayer(ownerId).removeFromLibrary(this,game);
break;
default :
}
game.rememberLKI(objectId,event.getFromZone(),this);
if (!removed) {
logger.warn("String_Node_Str" + getName() + "String_Node_Str"+ fromZone);
}
}
updateZoneChangeCounter();
PermanentCard permanent=new PermanentCard(this,controllerId);
game.addPermanent(permanent);
game.setZone(objectId,Zone.BATTLEFIELD);
permanent.entersBattlefield(sourceId,game);
game.applyEffects();
game.fireEvent(new ZoneChangeEvent(permanent,controllerId,fromZone,Zone.BATTLEFIELD));
return true;
}
return false;
}

Fixed version (ground truth):
@Override public boolean putOntoBattlefield(Game game,Zone fromZone,UUID sourceId,UUID controllerId){
  ZoneChangeEvent event=new ZoneChangeEvent(this.objectId,sourceId,controllerId,fromZone,Zone.BATTLEFIELD);
  if (!game.replaceEvent(event)) {
    if (fromZone != null) {
      boolean removed=false;
switch (fromZone) {
case GRAVEYARD:
        removed=game.getPlayer(ownerId).removeFromGraveyard(this,game);
      break;
case HAND:
    removed=game.getPlayer(ownerId).removeFromHand(this,game);
  break;
case LIBRARY:
removed=game.getPlayer(ownerId).removeFromLibrary(this,game);
break;
default :
}
game.rememberLKI(objectId,event.getFromZone(),this);
if (!removed) {
logger.warn("String_Node_Str" + getName() + "String_Node_Str"+ fromZone);
}
}
updateZoneChangeCounter();
PermanentCard permanent=new PermanentCard(this,controllerId);
game.resetForSourceId(permanent.getId());
game.addPermanent(permanent);
game.setZone(objectId,Zone.BATTLEFIELD);
permanent.entersBattlefield(sourceId,game);
game.applyEffects();
game.fireEvent(new ZoneChangeEvent(permanent,controllerId,fromZone,Zone.BATTLEFIELD));
return true;
}
return false;
}
Program: 160058
Project: 160058
Buggy source:
public List<RestrictionEffect> getApplicableRestrictionEffects(Permanent permanent,Game game){
  List<RestrictionEffect> effects=new ArrayList<RestrictionEffect>();
  for (  RestrictionEffect effect : restrictionEffects) {
    Ability ability=restrictionEffects.getAbility(effect.getId());
    if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game,false)) {
      if (effect.applies(permanent,ability,game))       effects.add(effect);
    }
  }
  return effects;
}

Fixed version (ground truth):
public List<RestrictionEffect> getApplicableRestrictionEffects(Permanent permanent,Game game){
  List<RestrictionEffect> effects=new ArrayList<RestrictionEffect>();
  for (  RestrictionEffect effect : restrictionEffects) {
    Ability ability=restrictionEffects.getAbility(effect.getId());
    if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game,permanent,false)) {
      if (effect.applies(permanent,ability,game))       effects.add(effect);
    }
  }
  return effects;
}
Program: 160059
Project: 160059
Buggy source:
/** 
 * Filters out asThough effects that are not active.
 * @param game
 * @return
 */
private List<AsThoughEffect> getApplicableAsThoughEffects(Game game){
  List<AsThoughEffect> asThoughEffectsList=new ArrayList<AsThoughEffect>();
  for (  AsThoughEffect effect : asThoughEffects) {
    Ability ability=asThoughEffects.getAbility(effect.getId());
    if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game,false)) {
      if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
        asThoughEffectsList.add(effect);
      }
    }
  }
  return asThoughEffectsList;
}

Fixed version (ground truth):
/** 
 * Filters out asThough effects that are not active.
 * @param game
 * @return
 */
private List<AsThoughEffect> getApplicableAsThoughEffects(Game game){
  List<AsThoughEffect> asThoughEffectsList=new ArrayList<AsThoughEffect>();
  for (  AsThoughEffect effect : asThoughEffects) {
    Ability ability=asThoughEffects.getAbility(effect.getId());
    if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game,null,false)) {
      if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
        asThoughEffectsList.add(effect);
      }
    }
  }
  return asThoughEffectsList;
}
Program: 160060
Project: 160060
Buggy source:
/** 
 * @param event
 * @param game
 * @return a list of all {@link ReplacementEffect} that apply to the current event
 */
private List<ReplacementEffect> getApplicableReplacementEffects(GameEvent event,Game game){
  List<ReplacementEffect> replaceEffects=new ArrayList<ReplacementEffect>();
  if (planeswalkerRedirectionEffect.applies(event,null,game))   replaceEffects.add(planeswalkerRedirectionEffect);
  if (auraReplacementEffect.applies(event,null,game))   replaceEffects.add(auraReplacementEffect);
  for (  ReplacementEffect effect : replacementEffects) {
    Ability ability=replacementEffects.getAbility(effect.getId());
    if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game,false)) {
      if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
        if (effect.applies(event,ability,game)) {
          replaceEffects.add(effect);
        }
      }
    }
  }
  for (  PreventionEffect effect : preventionEffects) {
    Ability ability=preventionEffects.getAbility(effect.getId());
    if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game,false)) {
      if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
        if (effect.applies(event,ability,game)) {
          replaceEffects.add(effect);
        }
      }
    }
  }
  return replaceEffects;
}

Fixed version (ground truth):
/** 
 * @param event
 * @param game
 * @return a list of all {@link ReplacementEffect} that apply to the current event
 */
private List<ReplacementEffect> getApplicableReplacementEffects(GameEvent event,Game game){
  List<ReplacementEffect> replaceEffects=new ArrayList<ReplacementEffect>();
  if (planeswalkerRedirectionEffect.applies(event,null,game))   replaceEffects.add(planeswalkerRedirectionEffect);
  if (auraReplacementEffect.applies(event,null,game))   replaceEffects.add(auraReplacementEffect);
  for (  ReplacementEffect effect : replacementEffects) {
    Ability ability=replacementEffects.getAbility(effect.getId());
    if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game,null,false)) {
      if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
        if (effect.applies(event,ability,game)) {
          replaceEffects.add(effect);
        }
      }
    }
  }
  for (  PreventionEffect effect : preventionEffects) {
    Ability ability=preventionEffects.getAbility(effect.getId());
    if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game,null,false)) {
      if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
        if (effect.applies(event,ability,game)) {
          replaceEffects.add(effect);
        }
      }
    }
  }
  return replaceEffects;
}
Program: 160061
Project: 160061
Buggy source:
/** 
 * Filters out cost modification effects that are not active.
 * @param game
 * @return
 */
private List<CostModificationEffect> getApplicableCostModificationEffects(Game game){
  List<CostModificationEffect> costEffects=new ArrayList<CostModificationEffect>();
  for (  CostModificationEffect effect : costModificationEffects) {
    Ability ability=costModificationEffects.getAbility(effect.getId());
    if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game,false)) {
      if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
        costEffects.add(effect);
      }
    }
  }
  return costEffects;
}

Fixed version (ground truth):
/** 
 * Filters out cost modification effects that are not active.
 * @param game
 * @return
 */
private List<CostModificationEffect> getApplicableCostModificationEffects(Game game){
  List<CostModificationEffect> costEffects=new ArrayList<CostModificationEffect>();
  for (  CostModificationEffect effect : costModificationEffects) {
    Ability ability=costModificationEffects.getAbility(effect.getId());
    if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game,null,false)) {
      if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
        costEffects.add(effect);
      }
    }
  }
  return costEffects;
}
Program: 160062
Project: 160062
Buggy source:
public List<ContinuousEffect> getLayeredEffects(Game game){
  List<ContinuousEffect> layerEffects=new ArrayList<ContinuousEffect>();
  for (  ContinuousEffect effect : layeredEffects) {
switch (effect.getDuration()) {
case WhileOnBattlefield:
case WhileOnStack:
case WhileInGraveyard:
      Ability ability=layeredEffects.getAbility(effect.getId());
    if (ability.isInUseableZone(game,false))     layerEffects.add(effect);
  break;
default :
layerEffects.add(effect);
}
}
updateTimestamps(layerEffects);
Collections.sort(layerEffects,new TimestampSorter());
return layerEffects;
}

Fixed version (ground truth):
public List<ContinuousEffect> getLayeredEffects(Game game){
  List<ContinuousEffect> layerEffects=new ArrayList<ContinuousEffect>();
  for (  ContinuousEffect effect : layeredEffects) {
switch (effect.getDuration()) {
case WhileOnBattlefield:
case WhileOnStack:
case WhileInGraveyard:
      Ability ability=layeredEffects.getAbility(effect.getId());
    if (ability.isInUseableZone(game,null,false))     layerEffects.add(effect);
  break;
default :
layerEffects.add(effect);
}
}
updateTimestamps(layerEffects);
Collections.sort(layerEffects,new TimestampSorter());
return layerEffects;
}
Program: 160063
Project: 160063
Buggy source:
public List<RequirementEffect> getApplicableRequirementEffects(Permanent permanent,Game game){
  List<RequirementEffect> effects=new ArrayList<RequirementEffect>();
  for (  RequirementEffect effect : requirementEffects) {
    Ability ability=requirementEffects.getAbility(effect.getId());
    if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game,false)) {
      if (effect.applies(permanent,ability,game))       effects.add(effect);
    }
  }
  return effects;
}

Fixed version (ground truth):
public List<RequirementEffect> getApplicableRequirementEffects(Permanent permanent,Game game){
  List<RequirementEffect> effects=new ArrayList<RequirementEffect>();
  for (  RequirementEffect effect : requirementEffects) {
    Ability ability=requirementEffects.getAbility(effect.getId());
    if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game,null,false)) {
      if (effect.applies(permanent,ability,game))       effects.add(effect);
    }
  }
  return effects;
}
Program: 160064
Project: 160064
Buggy source:
@Override public void init(Ability source,Game game){
  super.init(source,game);
  if (lockedIn) {
    power=new StaticValue(power.calculate(game,source));
    toughness=new StaticValue(toughness.calculate(game,source));
  }
}

Fixed version (ground truth):
@Override public void init(Ability source,Game game){
  super.init(source,game);
  getAffectedObjects().add(source.getSourceId());
  if (lockedIn) {
    power=new StaticValue(power.calculate(game,source));
    toughness=new StaticValue(toughness.calculate(game,source));
  }
}
Program: 160065
Project: 160065
Buggy source:
@Override public void resetForSourceId(UUID sourceId){
  for (  ContinuousEffect effect : getContinuousEffects().getLayeredEffects(this)) {
    if (effect.getAffectedObjects().contains(sourceId)) {
      effect.getAffectedObjects().remove(sourceId);
    }
    if (effect.getAffectedObjects().contains(sourceId)) {
      effect.getAffectedObjects().remove(sourceId);
    }
  }
  getContinuousEffects().removeGainedEffectsForSource(sourceId);
}

Fixed version (ground truth):
@Override public void resetForSourceId(UUID sourceId){
  for (  ContinuousEffect effect : getContinuousEffects().getLayeredEffects(this)) {
    if (effect.getAffectedObjects().contains(sourceId)) {
      effect.getAffectedObjects().remove(sourceId);
      if (effect instanceof SourceEffect) {
        effect.discard();
      }
    }
  }
  getContinuousEffects().removeGainedEffectsForSource(sourceId);
}
Program: 160066
Project: 160066
Buggy source:
@Override public boolean isInUseableZone(Game game,boolean checkLKI){
  if (zone.equals(Zone.COMMAND)) {
    return true;
  }
  if (checkLKI) {
    MageObject lkiTest=game.getShortLivingLKI(getSourceId(),zone);
    if (lkiTest != null) {
      return true;
    }
  }
  MageObject object=game.getObject(getSourceId());
  if (object != null && !object.getAbilities().contains(this)) {
    boolean found=false;
    if (object instanceof PermanentCard && ((PermanentCard)object).canTransform()) {
      PermanentCard permanent=(PermanentCard)object;
      found=permanent.getSecondCardFace().getAbilities().contains(this) || permanent.getCard().getAbilities().contains(this);
    }
    if (!found) {
      return false;
    }
  }
  Zone test=game.getState().getZone(sourceId);
  return test != null && zone.match(test);
}

Fixed version (ground truth):
@Override public boolean isInUseableZone(Game game,boolean checkLKI){
  if (zone.equals(Zone.COMMAND)) {
    return true;
  }
  if (checkLKI) {
    MageObject lkiTest=game.getShortLivingLKI(getSourceId(),zone);
    if (lkiTest != null) {
      return true;
    }
  }
  if (!(this instanceof MageSingleton)) {
    MageObject object=game.getObject(getSourceId());
    if (object != null && !object.getAbilities().contains(this)) {
      boolean found=false;
      if (object instanceof PermanentCard && ((PermanentCard)object).canTransform()) {
        PermanentCard permanent=(PermanentCard)object;
        found=permanent.getSecondCardFace().getAbilities().contains(this) || permanent.getCard().getAbilities().contains(this);
      }
      if (!found) {
        return false;
      }
    }
  }
  Zone test=game.getState().getZone(sourceId);
  return test != null && zone.match(test);
}
Program: 160067
Project: 160067
Buggy source:
@Override public List<String> getRules(String source){
  List<String> rules=new ArrayList<String>();
  for (  T ability : this) {
    if (!(ability instanceof SpellAbility || ability instanceof PlayLandAbility))     rules.add(ability.getRule());
    if (ability instanceof SpellAbility) {
      if (ability.getAlternativeCosts().size() > 0) {
        StringBuilder sbRule=new StringBuilder();
        for (        AlternativeCost cost : ability.getAlternativeCosts()) {
          sbRule.append(cost.getName()).append("String_Node_Str");
        }
        rules.add(sbRule.toString());
      }
      if (ability.getCosts().size() > 0) {
        StringBuilder sbRule=new StringBuilder();
        for (        Cost cost : ability.getCosts()) {
          sbRule.append(cost.getText()).append("String_Node_Str");
        }
        rules.add(sbRule.toString());
      }
    }
  }
  return rules;
}

Fixed version (ground truth):
@Override public List<String> getRules(String source){
  List<String> rules=new ArrayList<String>();
  for (  T ability : this) {
    if (!(ability instanceof SpellAbility || ability instanceof PlayLandAbility))     rules.add(ability.getRule());
    if (ability instanceof SpellAbility) {
      if (ability.getAlternativeCosts().size() > 0) {
        StringBuilder sbRule=new StringBuilder();
        for (        AlternativeCost cost : ability.getAlternativeCosts()) {
          sbRule.append(cost.getName()).append("String_Node_Str");
        }
        rules.add(sbRule.toString());
      }
      if (ability.getCosts().size() > 0) {
        StringBuilder sbRule=new StringBuilder();
        for (        Cost cost : ability.getCosts()) {
          if (cost.getText() != null && !cost.getText().isEmpty()) {
            if (!cost.getText().startsWith("String_Node_Str")) {
              sbRule.append("String_Node_Str");
            }
            sbRule.append(cost.getText()).append("String_Node_Str");
          }
        }
        rules.add(sbRule.toString());
      }
    }
  }
  return rules;
}
Program: 160068
Project: 160068
Buggy source:
protected Integer addActionsTimed(){
  FutureTask<Integer> task=new FutureTask<Integer>(new Callable<Integer>(){
    @Override public Integer call() throws Exception {
      return addActions(root,maxDepth,Integer.MIN_VALUE,Integer.MAX_VALUE);
    }
  }
);
  pool.execute(task);
  try {
    return task.get(maxThink,TimeUnit.SECONDS);
  }
 catch (  TimeoutException e) {
    logger.info("String_Node_Str");
    task.cancel(true);
  }
catch (  ExecutionException e) {
    e.printStackTrace();
    task.cancel(true);
  }
catch (  InterruptedException e) {
    e.printStackTrace();
    task.cancel(true);
  }
catch (  Exception e) {
    e.printStackTrace();
    task.cancel(true);
  }
  return 0;
}

Fixed version (ground truth):
protected Integer addActionsTimed(){
  FutureTask<Integer> task=new FutureTask<Integer>(new Callable<Integer>(){
    @Override public Integer call() throws Exception {
      return addActions(root,maxDepth,Integer.MIN_VALUE,Integer.MAX_VALUE);
    }
  }
);
  pool.execute(task);
  try {
    System.out.println("String_Node_Str" + maxThink);
    return task.get(maxThink,TimeUnit.SECONDS);
  }
 catch (  TimeoutException e) {
    logger.info("String_Node_Str");
    task.cancel(true);
  }
catch (  ExecutionException e) {
    e.printStackTrace();
    task.cancel(true);
  }
catch (  InterruptedException e) {
    e.printStackTrace();
    task.cancel(true);
  }
catch (  Exception e) {
    e.printStackTrace();
    task.cancel(true);
  }
  return 0;
}
Program: 160069
Project: 160069
Buggy source:
protected void act(Game game){
  if (actions == null || actions.size() == 0)   pass();
 else {
    boolean usedStack=false;
    while (actions.peek() != null) {
      Ability ability=actions.poll();
      System.out.println("String_Node_Str" + game.getPlayer(playerId).getName() + "String_Node_Str"+ ability.toString());
      if (ability.getTargets().size() > 0) {
        Player player=game.getPlayer(ability.getFirstTarget());
        if (player != null) {
          System.out.println("String_Node_Str" + player.getName());
        }
      }
      this.activateAbility((ActivatedAbility)ability,game);
      if (ability.isUsesStack())       usedStack=true;
      if (!suggested.isEmpty() && !(ability instanceof PassAbility)) {
        Iterator<String> it=suggested.iterator();
        while (it.hasNext()) {
          Card card=game.getCard(ability.getSourceId());
          String action=it.next();
          System.out.println("String_Node_Str" + action + "String_Node_Str"+ card);
          if (action.equals(card.getName())) {
            System.out.println("String_Node_Str" + action);
            it.remove();
          }
        }
      }
    }
    if (usedStack)     pass();
  }
}

Fixed version (ground truth):
protected void act(Game game){
  if (actions == null || actions.size() == 0)   pass();
 else {
    boolean usedStack=false;
    while (actions.peek() != null) {
      Ability ability=actions.poll();
      System.out.println("String_Node_Str" + game.getPlayer(playerId).getName() + "String_Node_Str"+ ability.toString());
      if (ability.getTargets().size() > 0) {
        for (        Target target : ability.getTargets()) {
          for (          UUID id : target.getTargets()) {
            target.updateTarget(id,game);
          }
        }
        Player player=game.getPlayer(ability.getFirstTarget());
        if (player != null) {
          System.out.println("String_Node_Str" + player.getName());
        }
      }
      this.activateAbility((ActivatedAbility)ability,game);
      if (ability.isUsesStack())       usedStack=true;
      if (!suggested.isEmpty() && !(ability instanceof PassAbility)) {
        Iterator<String> it=suggested.iterator();
        while (it.hasNext()) {
          Card card=game.getCard(ability.getSourceId());
          String action=it.next();
          System.out.println("String_Node_Str" + action + "String_Node_Str"+ card);
          if (action.equals(card.getName())) {
            System.out.println("String_Node_Str" + action);
            it.remove();
          }
        }
      }
    }
    if (usedStack)     pass();
  }
}
Program: 160071
Project: 160071
Buggy source:
protected String formatRule(String rule,String source){
  String replace=rule.replace("String_Node_Str",source);
  replace=replace.replace("String_Node_Str",source);
  return replace;
}

Fixed version (ground truth):
protected String formatRule(String rule,String source){
  String replace=rule;
  if (source != null && !source.isEmpty()) {
    replace=rule.replace("String_Node_Str",source);
    replace=replace.replace("String_Node_Str",source);
  }
  return replace;
}
Program: 160072
Project: 160072
Buggy source:
@Override public boolean moveToZone(Zone toZone,UUID sourceId,Game game,boolean flag){
  Zone fromZone=game.getState().getZone(objectId);
  Player controller=game.getPlayer(controllerId);
  if (controller != null && controller.removeFromBattlefield(this,game)) {
    ZoneChangeEvent event=new ZoneChangeEvent(this,sourceId,controllerId,fromZone,toZone);
    if (!game.replaceEvent(event)) {
      Player owner=game.getPlayer(ownerId);
      game.rememberLKI(objectId,Zone.BATTLEFIELD,this);
      if (owner != null) {
switch (event.getToZone()) {
case GRAVEYARD:
          owner.putInGraveyard(card,game,!flag);
        break;
case HAND:
      owner.getHand().add(card);
    break;
case EXILED:
  game.getExile().getPermanentExile().add(card);
break;
case LIBRARY:
if (flag) owner.getLibrary().putOnTop(card,game);
 else owner.getLibrary().putOnBottom(card,game);
break;
case BATTLEFIELD:
break;
}
game.setZone(objectId,event.getToZone());
game.fireEvent(event);
return game.getState().getZone(objectId) == toZone;
}
}
}
return false;
}

Fixed version (ground truth):
@Override public boolean moveToZone(Zone toZone,UUID sourceId,Game game,boolean flag){
  Zone fromZone=game.getState().getZone(objectId);
  Player controller=game.getPlayer(controllerId);
  if (controller != null && controller.removeFromBattlefield(this,game)) {
    ZoneChangeEvent event=new ZoneChangeEvent(this,sourceId,controllerId,fromZone,toZone);
    if (!game.replaceEvent(event)) {
      if (event.getFromZone().equals(Zone.BATTLEFIELD)) {
        for (        ContinuousEffect effect : game.getContinuousEffects().getLayeredEffects(game)) {
          if (effect.getAffectedObjects().contains(getId())) {
            effect.getAffectedObjects().remove(getId());
          }
        }
      }
      Player owner=game.getPlayer(ownerId);
      game.rememberLKI(objectId,Zone.BATTLEFIELD,this);
      if (owner != null) {
switch (event.getToZone()) {
case GRAVEYARD:
          owner.putInGraveyard(card,game,!flag);
        break;
case HAND:
      owner.getHand().add(card);
    break;
case EXILED:
  game.getExile().getPermanentExile().add(card);
break;
case LIBRARY:
if (flag) owner.getLibrary().putOnTop(card,game);
 else owner.getLibrary().putOnBottom(card,game);
break;
case BATTLEFIELD:
break;
}
game.setZone(objectId,event.getToZone());
game.fireEvent(event);
return game.getState().getZone(objectId) == toZone;
}
}
}
return false;
}
Program: 160074
Project: 160074
Buggy source:
/** 
 * Update phase buttons\labels.
 */
private void updatePhases(Constants.PhaseStep step){
  if (step == null) {
    logger.warn("String_Node_Str");
    return;
  }
  if (currentStep != null) {
    currentStep.setLocation(prevPoint);
  }
switch (step) {
case UNTAP:
    updateButton("String_Node_Str");
  break;
case UPKEEP:
updateButton("String_Node_Str");
break;
case DRAW:
updateButton("String_Node_Str");
break;
case PRECOMBAT_MAIN:
updateButton("String_Node_Str");
break;
case BEGIN_COMBAT:
updateButton("String_Node_Str");
break;
case DECLARE_ATTACKERS:
updateButton("String_Node_Str");
break;
case DECLARE_BLOCKERS:
updateButton("String_Node_Str");
break;
case FIRST_COMBAT_DAMAGE:
case COMBAT_DAMAGE:
updateButton("String_Node_Str");
break;
case POSTCOMBAT_MAIN:
updateButton("String_Node_Str");
break;
case END_TURN:
updateButton("String_Node_Str");
break;
}
}

Fixed version (ground truth):
/** 
 * Update phase buttons\labels.
 */
private void updatePhases(Constants.PhaseStep step){
  if (step == null) {
    logger.warn("String_Node_Str");
    return;
  }
  if (currentStep != null) {
    currentStep.setLocation(prevPoint);
  }
switch (step) {
case UNTAP:
    updateButton("String_Node_Str");
  break;
case UPKEEP:
updateButton("String_Node_Str");
break;
case DRAW:
updateButton("String_Node_Str");
break;
case PRECOMBAT_MAIN:
updateButton("String_Node_Str");
break;
case BEGIN_COMBAT:
updateButton("String_Node_Str");
break;
case DECLARE_ATTACKERS:
updateButton("String_Node_Str");
break;
case DECLARE_BLOCKERS:
updateButton("String_Node_Str");
break;
case FIRST_COMBAT_DAMAGE:
case COMBAT_DAMAGE:
updateButton("String_Node_Str");
break;
case END_COMBAT:
updateButton("String_Node_Str");
break;
case POSTCOMBAT_MAIN:
updateButton("String_Node_Str");
break;
case END_TURN:
updateButton("String_Node_Str");
break;
}
}
Program: 160075
Project: 160075
Buggy source:
@Override public Set<UUID> possibleTargets(UUID sourceId,UUID sourceControllerId,Game game){
  Set<UUID> availablePossibleTargets=super.possibleTargets(sourceId,sourceControllerId,game);
  Set<UUID> possibleTargets=new HashSet<UUID>();
  MageObject object=game.getObject(sourceId);
  if (object instanceof StackObject) {
    UUID playerId=((StackObject)object).getStackAbility().getFirstTarget();
    for (    UUID targetId : availablePossibleTargets) {
      Permanent permanent=game.getPermanent(targetId);
      if (permanent != null && permanent.getControllerId().equals(playerId)) {
        possibleTargets.add(targetId);
      }
    }
  }
  return possibleTargets;
}

Fixed version (ground truth):
@Override public Set<UUID> possibleTargets(UUID sourceId,UUID sourceControllerId,Game game){
  Set<UUID> availablePossibleTargets=super.possibleTargets(sourceId,sourceControllerId,game);
  Set<UUID> possibleTargets=new HashSet<UUID>();
  MageObject object=game.getObject(sourceId);
  for (  StackObject item : game.getState().getStack()) {
    if (item.getId().equals(sourceId)) {
      object=item;
    }
    if (item.getSourceId().equals(sourceId)) {
      object=item;
    }
  }
  if (object instanceof StackObject) {
    UUID playerId=((StackObject)object).getStackAbility().getFirstTarget();
    for (    UUID targetId : availablePossibleTargets) {
      Permanent permanent=game.getPermanent(targetId);
      if (permanent != null && permanent.getControllerId().equals(playerId)) {
        possibleTargets.add(targetId);
      }
    }
  }
  return possibleTargets;
}
Program: 160076
Project: 160076
Buggy source:
@Override public boolean resolve(Game game){
  if (ability.getTargets().stillLegal(ability,game)) {
    return ability.resolve(game);
  }
  counter(null,game);
  return false;
}

Fixed version (ground truth):
@Override public boolean resolve(Game game){
  if (ability.getTargets().stillLegal(ability,game)) {
    return ability.resolve(game);
  }
  game.informPlayers("String_Node_Str" + getRule());
  counter(null,game);
  return false;
}
Program: 160077
Project: 160077
Buggy source:
public boolean stillLegal(Ability source,Game game){
  int illegalCount=0;
  for (  Target target : this) {
    if (target.isLegal(source,game)) {
      illegalCount++;
    }
  }
  return this.size() == illegalCount;
}

Fixed version (ground truth):
public boolean stillLegal(Ability source,Game game){
  int illegalCount=0;
  for (  Target target : this) {
    if (!target.isLegal(source,game)) {
      illegalCount++;
    }
  }
  return this.size() == 0 || this.size() != illegalCount;
}
Program: 160078
Project: 160078
Buggy source:
@Override public DearlyDeparted copy(){
  return new DearlyDeparted(this);
}

Fixed version (ground truth):
@Override public EntersBattlefieldEffect copy(){
  return new EntersBattlefieldEffect(this);
}
Program: 160079
Project: 160079
Buggy source:
@Override public boolean isInUseableZone(Game game,boolean checkLKI){
  if (zone.equals(Zone.COMMAND)) {
    return true;
  }
  if (checkLKI) {
    MageObject lkiTest=game.getShortLivingLKI(getSourceId(),zone);
    if (lkiTest != null) {
      return true;
    }
  }
  Zone test=game.getState().getZone(sourceId);
  return test != null && zone.match(test);
}

Fixed version (ground truth):
@Override public boolean isInUseableZone(Game game,boolean checkLKI){
  if (zone.equals(Zone.COMMAND)) {
    return true;
  }
  if (checkLKI) {
    MageObject lkiTest=game.getShortLivingLKI(getSourceId(),zone);
    if (lkiTest != null) {
      return true;
    }
  }
  MageObject object=game.getObject(getSourceId());
  if (object != null && !object.getAbilities().contains(this)) {
    boolean found=false;
    if (object instanceof PermanentCard && ((PermanentCard)object).canTransform()) {
      PermanentCard permanent=(PermanentCard)object;
      found=permanent.getSecondCardFace().getAbilities().contains(this) || permanent.getCard().getAbilities().contains(this);
    }
    if (!found) {
      return false;
    }
  }
  Zone test=game.getState().getZone(sourceId);
  return test != null && zone.match(test);
}
Program: 160080
Project: 160080
Buggy source:
public ContinuousEffects(final ContinuousEffects effect){
  this.applyCounters=effect.applyCounters.copy();
  this.planeswalkerRedirectionEffect=effect.planeswalkerRedirectionEffect.copy();
  this.auraReplacementEffect=effect.auraReplacementEffect.copy();
  layeredEffects=effect.layeredEffects.copy();
  replacementEffects=effect.replacementEffects.copy();
  preventionEffects=effect.preventionEffects.copy();
  requirementEffects=effect.requirementEffects.copy();
  restrictionEffects=effect.restrictionEffects.copy();
  asThoughEffects=effect.asThoughEffects.copy();
  costModificationEffects=effect.costModificationEffects.copy();
  collectAllEffects();
}

Fixed version (ground truth):
public ContinuousEffects(final ContinuousEffects effect){
  this.applyCounters=effect.applyCounters.copy();
  this.planeswalkerRedirectionEffect=effect.planeswalkerRedirectionEffect.copy();
  this.auraReplacementEffect=effect.auraReplacementEffect.copy();
  layeredEffects=effect.layeredEffects.copy();
  replacementEffects=effect.replacementEffects.copy();
  preventionEffects=effect.preventionEffects.copy();
  requirementEffects=effect.requirementEffects.copy();
  restrictionEffects=effect.restrictionEffects.copy();
  asThoughEffects=effect.asThoughEffects.copy();
  costModificationEffects=effect.costModificationEffects.copy();
  for (  Map.Entry<Effect,UUID> entry : effect.sources.entrySet()) {
    sources.put(entry.getKey(),entry.getValue());
  }
  collectAllEffects();
}
Program: 160082
Project: 160082
Buggy source:
public void clear(){
  for (  ContinuousEffectsList effectsList : allEffectsLists) {
    effectsList.clear();
  }
}

Fixed version (ground truth):
public void clear(){
  for (  ContinuousEffectsList effectsList : allEffectsLists) {
    effectsList.clear();
  }
  sources.clear();
}
Program: 160083
Project: 160083
Buggy source:
@Override public boolean apply(Game game,Ability source){
  for (  Permanent perm : game.getBattlefield().getAllActivePermanents(filter,source.getControllerId(),game)) {
    if (!this.affectedObjectsSet || objects.contains(perm.getId())) {
      if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
        for (        Ability abilityToAdd : ability) {
          perm.addAbility(abilityToAdd,game);
        }
      }
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  for (  Permanent perm : game.getBattlefield().getAllActivePermanents(filter,source.getControllerId(),game)) {
    if (!this.affectedObjectsSet || objects.contains(perm.getId())) {
      if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
        for (        Ability abilityToAdd : ability) {
          perm.addAbility(abilityToAdd,source.getSourceId(),game);
        }
      }
    }
  }
  return true;
}
Program: 160084
Project: 160084
Buggy source:
@Override public boolean apply(Game game,Ability source){
  int affectedTargets=0;
  for (  UUID permanentId : targetPointer.getTargets(game,source)) {
    Permanent permanent=game.getPermanent(permanentId);
    if (permanent != null) {
      permanent.getAbilities().clear();
      affectedTargets++;
    }
  }
  return affectedTargets > 0;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  int affectedTargets=0;
  for (  UUID permanentId : targetPointer.getTargets(game,source)) {
    Permanent permanent=game.getPermanent(permanentId);
    if (permanent != null) {
      permanent.removeAllAbilities(source.getSourceId(),game);
      affectedTargets++;
    }
  }
  return affectedTargets > 0;
}
Program: 160085
Project: 160085
Buggy source:
@Override public boolean putOntoBattlefield(Game game,Zone fromZone,UUID sourceId,UUID controllerId){
  ZoneChangeEvent event=new ZoneChangeEvent(this.objectId,sourceId,controllerId,fromZone,Zone.BATTLEFIELD);
  if (!game.replaceEvent(event)) {
    if (fromZone != null) {
      boolean removed=false;
switch (fromZone) {
case GRAVEYARD:
        removed=game.getPlayer(ownerId).removeFromGraveyard(this,game);
      break;
case HAND:
    removed=game.getPlayer(ownerId).removeFromHand(this,game);
  break;
case LIBRARY:
removed=game.getPlayer(ownerId).removeFromLibrary(this,game);
break;
default :
}
game.rememberLKI(objectId,event.getFromZone(),this);
if (!removed) {
logger.warn("String_Node_Str" + getName() + "String_Node_Str"+ fromZone);
}
}
updateZoneChangeCounter();
PermanentCard permanent=new PermanentCard(this,controllerId);
game.addPermanent(permanent);
game.setZone(objectId,Zone.BATTLEFIELD);
game.applyEffects();
permanent.entersBattlefield(sourceId,game);
game.applyEffects();
game.fireEvent(new ZoneChangeEvent(permanent,controllerId,fromZone,Zone.BATTLEFIELD));
return true;
}
return false;
}

Fixed version (ground truth):
@Override public boolean putOntoBattlefield(Game game,Zone fromZone,UUID sourceId,UUID controllerId){
  ZoneChangeEvent event=new ZoneChangeEvent(this.objectId,sourceId,controllerId,fromZone,Zone.BATTLEFIELD);
  if (!game.replaceEvent(event)) {
    if (fromZone != null) {
      boolean removed=false;
switch (fromZone) {
case GRAVEYARD:
        removed=game.getPlayer(ownerId).removeFromGraveyard(this,game);
      break;
case HAND:
    removed=game.getPlayer(ownerId).removeFromHand(this,game);
  break;
case LIBRARY:
removed=game.getPlayer(ownerId).removeFromLibrary(this,game);
break;
default :
}
game.rememberLKI(objectId,event.getFromZone(),this);
if (!removed) {
logger.warn("String_Node_Str" + getName() + "String_Node_Str"+ fromZone);
}
}
updateZoneChangeCounter();
PermanentCard permanent=new PermanentCard(this,controllerId);
game.addPermanent(permanent);
game.setZone(objectId,Zone.BATTLEFIELD);
permanent.entersBattlefield(sourceId,game);
game.applyEffects();
game.fireEvent(new ZoneChangeEvent(permanent,controllerId,fromZone,Zone.BATTLEFIELD));
return true;
}
return false;
}
Program: 160086
Project: 160086
Buggy source:
public void addEffect(ContinuousEffect effect,Ability source){
  effects.addEffect(effect,source);
}

Fixed version (ground truth):
public void addEffect(ContinuousEffect effect,UUID sourceId,Ability source){
  effects.addEffect(effect,sourceId,source);
}
Program: 160087
Project: 160087
Buggy source:
public void addAbility(Ability ability,MageObject attachedTo){
  if (ability instanceof StaticAbility) {
    if (ability instanceof KickerAbility) {
      return;
    }
    for (    Mode mode : ability.getModes().values()) {
      for (      Effect effect : mode.getEffects()) {
        if (effect instanceof ContinuousEffect) {
          addEffect((ContinuousEffect)effect,ability);
        }
      }
    }
  }
 else   if (ability instanceof TriggeredAbility) {
    this.triggers.add((TriggeredAbility)ability,attachedTo);
  }
}

Fixed version (ground truth):
public void addAbility(Ability ability,UUID sourceId,MageObject attachedTo){
  if (ability instanceof StaticAbility) {
    if (ability instanceof KickerAbility) {
      return;
    }
    for (    Mode mode : ability.getModes().values()) {
      for (      Effect effect : mode.getEffects()) {
        if (effect instanceof ContinuousEffect) {
          addEffect((ContinuousEffect)effect,sourceId,ability);
        }
      }
    }
  }
 else   if (ability instanceof TriggeredAbility) {
    this.triggers.add((TriggeredAbility)ability,attachedTo);
  }
}
Program: 160088
Project: 160088
Buggy source:
public void addAbility(Ability ability,Game game);

Fixed version (ground truth):
public void addAbility(Ability ability,UUID sourceId,Game game);