nus-yam/ex-repair huggingface dataset:
Program: 158966
Project: 158966
Buggy source:
public boolean pay(ManaType manaType,Ability ability,Filter filter,Game game){
  if (!autoPayment && !manaType.equals(unlockedManaType)) {
    return false;
  }
  if (getConditional(manaType,ability,filter,game) > 0) {
    removeConditional(manaType,ability,game);
    lockManaType();
    return true;
  }
  for (  ManaPoolItem mana : manaItems) {
    if (filter != null) {
      MageObject sourceObject=game.getObject(mana.getSourceId());
      if (!filter.match(sourceObject,game)) {
        continue;
      }
    }
    boolean spendAnyMana=spendAnyMana(ability,game);
    if (mana.get(manaType) > 0 || (spendAnyMana && mana.count() > 0)) {
      game.fireEvent(new GameEvent(GameEvent.EventType.MANA_PAYED,ability.getId(),mana.getSourceId(),ability.getControllerId(),0,mana.getFlag()));
      if (spendAnyMana) {
        mana.removeAny();
      }
 else {
        mana.remove(manaType);
      }
      lockManaType();
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
public boolean pay(ManaType manaType,Ability ability,Filter filter,Game game){
  if (!autoPayment && !manaType.equals(unlockedManaType)) {
    return false;
  }
  if (getConditional(manaType,ability,filter,game) > 0) {
    removeConditional(manaType,ability,game);
    lockManaType();
    return true;
  }
  for (  ManaPoolItem mana : manaItems) {
    if (filter != null) {
      MageObject sourceObject=game.getObject(mana.getSourceId());
      if (!filter.match(sourceObject,game)) {
        continue;
      }
    }
    boolean spendAnyMana=spendAnyMana(ability,game);
    if (mana.get(manaType) > 0 || (spendAnyMana && mana.count() > 0)) {
      GameEvent event=new GameEvent(GameEvent.EventType.MANA_PAYED,ability.getId(),mana.getSourceId(),ability.getControllerId(),0,mana.getFlag());
      event.setData(mana.getOriginalId().toString());
      game.fireEvent(event);
      if (spendAnyMana) {
        mana.removeAny();
      }
 else {
        mana.remove(manaType);
      }
      lockManaType();
      return true;
    }
  }
  return false;
}
Program: 158967
Project: 158967
Buggy source:
public ManaPoolItem(final ManaPoolItem item){
  this.red=item.red;
  this.green=item.green;
  this.blue=item.blue;
  this.white=item.white;
  this.black=item.black;
  this.colorless=item.colorless;
  if (item.conditionalMana != null) {
    this.conditionalMana=item.conditionalMana.copy();
  }
  this.sourceId=item.sourceId;
  this.flag=item.flag;
  this.duration=item.duration;
}

Fixed version (ground truth):
public ManaPoolItem(final ManaPoolItem item){
  this.red=item.red;
  this.green=item.green;
  this.blue=item.blue;
  this.white=item.white;
  this.black=item.black;
  this.colorless=item.colorless;
  if (item.conditionalMana != null) {
    this.conditionalMana=item.conditionalMana.copy();
  }
  this.sourceId=item.sourceId;
  this.originalId=item.originalId;
  this.flag=item.flag;
  this.duration=item.duration;
}
Program: 158968
Project: 158968
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player targetPlayer=game.getPlayer(this.getTargetPointer().getFirst(game,source));
  boolean colorShared;
  if (targetPlayer != null) {
    int possibleIterations=targetPlayer.getLibrary().size() / 2;
    int iteration=0;
    do {
      iteration++;
      if (iteration > possibleIterations + 20) {
        game.setDraw(source.getControllerId());
        return true;
      }
      colorShared=false;
      Card card1=targetPlayer.getLibrary().removeFromTop(game);
      if (card1 != null) {
        targetPlayer.moveCardToGraveyardWithInfo(card1,source.getSourceId(),game,Zone.LIBRARY);
        Card card2=targetPlayer.getLibrary().removeFromTop(game);
        if (card2 != null) {
          targetPlayer.moveCardToGraveyardWithInfo(card2,source.getSourceId(),game,Zone.LIBRARY);
          if (card1.getColor().hasColor() && card2.getColor().hasColor()) {
            colorShared=card1.getColor().shares(card2.getColor());
          }
        }
      }
    }
 while (colorShared && targetPlayer.isInGame());
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player targetPlayer=game.getPlayer(this.getTargetPointer().getFirst(game,source));
  boolean colorShared;
  if (targetPlayer != null) {
    int possibleIterations=targetPlayer.getLibrary().size() / 2;
    int iteration=0;
    do {
      iteration++;
      if (iteration > possibleIterations + 20) {
        game.setDraw(source.getControllerId());
        return true;
      }
      colorShared=false;
      Card card1=null;
      Card card2=null;
      if (targetPlayer.getLibrary().size() > 0) {
        card1=targetPlayer.getLibrary().removeFromTop(game);
        if (targetPlayer.getLibrary().size() > 0) {
          card2=targetPlayer.getLibrary().removeFromTop(game);
          if (card1.getColor().hasColor() && card2.getColor().hasColor()) {
            colorShared=card1.getColor().shares(card2.getColor());
          }
        }
      }
      if (card1 != null) {
        targetPlayer.moveCardToGraveyardWithInfo(card1,source.getSourceId(),game,Zone.LIBRARY);
      }
      if (card2 != null) {
        targetPlayer.moveCardToGraveyardWithInfo(card2,source.getSourceId(),game,Zone.LIBRARY);
      }
    }
 while (colorShared && targetPlayer.isInGame());
    return true;
  }
  return false;
}
Program: 158969
Project: 158969
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) {
    int ageCounter=permanent.getCounters().getCount(CounterType.AGE);
    if (cumulativeCost instanceof ManaCost) {
      ManaCostsImpl totalCost=new ManaCostsImpl();
      for (int i=0; i < ageCounter; i++) {
        totalCost.add(cumulativeCost.copy());
      }
      if (player.chooseUse(Outcome.Benefit,"String_Node_Str" + totalCost.getText() + "String_Node_Str",game)) {
        totalCost.clearPaid();
        if (totalCost.payOrRollback(source,game,source.getSourceId(),source.getControllerId())) {
          return true;
        }
      }
      permanent.sacrifice(source.getSourceId(),game);
      return true;
    }
 else {
      CostsImpl totalCost=new CostsImpl();
      for (int i=0; i < ageCounter; i++) {
        totalCost.add(cumulativeCost.copy());
      }
      if (player.chooseUse(Outcome.Benefit,totalCost.getText() + "String_Node_Str",game)) {
        totalCost.clearPaid();
        int bookmark=game.bookmarkState();
        if (totalCost.pay(source,game,source.getSourceId(),source.getControllerId(),false)) {
          return true;
        }
 else {
          game.restoreState(bookmark,source.getRule());
        }
      }
      permanent.sacrifice(source.getSourceId(),game);
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getControllerId());
  Permanent permanent=game.getPermanent(source.getSourceId());
  if (player != null && permanent != null) {
    int ageCounter=permanent.getCounters().getCount(CounterType.AGE);
    if (cumulativeCost instanceof ManaCost) {
      ManaCostsImpl totalCost=new ManaCostsImpl();
      for (int i=0; i < ageCounter; i++) {
        totalCost.add((ManaCost)cumulativeCost.copy());
      }
      if (player.chooseUse(Outcome.Benefit,"String_Node_Str" + totalCost.getText() + "String_Node_Str",game)) {
        totalCost.clearPaid();
        if (totalCost.payOrRollback(source,game,source.getSourceId(),source.getControllerId())) {
          return true;
        }
      }
      permanent.sacrifice(source.getSourceId(),game);
      return true;
    }
 else {
      CostsImpl totalCost=new CostsImpl();
      for (int i=0; i < ageCounter; i++) {
        totalCost.add(cumulativeCost.copy());
      }
      if (player.chooseUse(Outcome.Benefit,totalCost.getText() + "String_Node_Str",game)) {
        totalCost.clearPaid();
        int bookmark=game.bookmarkState();
        if (totalCost.pay(source,game,source.getSourceId(),source.getControllerId(),false)) {
          return true;
        }
 else {
          game.restoreState(bookmark,source.getRule());
        }
      }
      permanent.sacrifice(source.getSourceId(),game);
      return true;
    }
  }
  return false;
}
Program: 158970
Project: 158970
Buggy source:
/** 
 * @param game
 * @param source
 * @return 
 */
@Override public boolean isInUseableZone(Game game,MageObject source,GameEvent event){
  if (zone.equals(Zone.COMMAND)) {
    if (this.getSourceId() == null) {
      return true;
    }
    MageObject object=game.getObject(this.getSourceId());
    if (object != null && object instanceof Emblem) {
      return true;
    }
  }
  MageObject object;
  UUID parameterSourceId;
  if (this instanceof MageSingleton && source != null) {
    object=source;
    parameterSourceId=source.getId();
  }
 else {
    object=game.getObject(getSourceId());
    parameterSourceId=getSourceId();
  }
  if (object != null && !object.getAbilities().contains(this)) {
    boolean found=false;
    if (object instanceof PermanentCard) {
      if (((PermanentCard)object).canTransform()) {
        PermanentCard permanent=(PermanentCard)object;
        found=permanent.getSecondCardFace().getAbilities().contains(this) || permanent.getCard().getAbilities().contains(this);
      }
    }
 else {
      Abilities<Ability> otherAbilities=game.getState().getAllOtherAbilities(this.getSourceId());
      found=otherAbilities != null && otherAbilities.contains(this);
    }
    if (!found) {
      return false;
    }
  }
  Zone test=game.getState().getZone(parameterSourceId);
  return test != null && zone.match(test);
}

Fixed version (ground truth):
/** 
 * @param game
 * @param source
 * @return 
 */
@Override public boolean isInUseableZone(Game game,MageObject source,GameEvent event){
  if (zone.equals(Zone.COMMAND)) {
    if (this.getSourceId() == null) {
      return true;
    }
    MageObject object=game.getObject(this.getSourceId());
    if (object != null && object instanceof Emblem) {
      return true;
    }
  }
  MageObject object;
  UUID parameterSourceId;
  if (this instanceof MageSingleton && source != null) {
    object=source;
    parameterSourceId=source.getId();
  }
 else {
    object=game.getObject(getSourceId());
    parameterSourceId=getSourceId();
  }
  if (object != null && !object.getAbilities().contains(this)) {
    if (!(object instanceof Permanent)) {
      Abilities<Ability> otherAbilities=game.getState().getAllOtherAbilities(this.getSourceId());
      if (otherAbilities == null || !otherAbilities.contains(this)) {
        return false;
      }
    }
  }
  Zone test=game.getState().getZone(parameterSourceId);
  return test != null && zone.match(test);
}
Program: 158971
Project: 158971
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.TRANSFORMED && event.getTargetId().equals(sourceId)) {
    Permanent permanent=game.getPermanent(sourceId);
    if (permanent != null && permanent.isTransformed()) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getTargetId().equals(sourceId)) {
    Permanent permanent=game.getPermanent(sourceId);
    if (permanent != null && permanent.isTransformed()) {
      return true;
    }
  }
  return false;
}
Program: 158972
Project: 158972
Buggy source:
/** 
 * @param game
 * @param source
 * @return 
 */
@Override public boolean isInUseableZone(Game game,MageObject source,GameEvent event){
  if (zone.equals(Zone.COMMAND)) {
    if (this.getSourceId() == null) {
      return true;
    }
    MageObject object=game.getObject(this.getSourceId());
    if (object != null && object instanceof Emblem) {
      return true;
    }
  }
  MageObject object;
  UUID parameterSourceId;
  if (this instanceof MageSingleton && source != null) {
    object=source;
    parameterSourceId=source.getId();
  }
 else {
    object=game.getObject(getSourceId());
    parameterSourceId=getSourceId();
  }
  if (object != null && !object.getAbilities().contains(this)) {
    if (!(object instanceof Permanent)) {
      Abilities<Ability> otherAbilities=game.getState().getAllOtherAbilities(this.getSourceId());
      if (otherAbilities == null || !otherAbilities.contains(this)) {
        return false;
      }
    }
  }
  Zone test=game.getState().getZone(parameterSourceId);
  return test != null && zone.match(test);
}

Fixed version (ground truth):
/** 
 * @param game
 * @param source
 * @return 
 */
@Override public boolean isInUseableZone(Game game,MageObject source,GameEvent event){
  if (zone.equals(Zone.COMMAND)) {
    if (this.getSourceId() == null) {
      return true;
    }
    MageObject object=game.getObject(this.getSourceId());
    if (object != null && object instanceof Emblem) {
      return true;
    }
  }
  MageObject object;
  UUID parameterSourceId;
  if (this instanceof MageSingleton && source != null) {
    object=source;
    parameterSourceId=source.getId();
  }
 else {
    object=game.getObject(getSourceId());
    parameterSourceId=getSourceId();
  }
  if (object != null && !object.getAbilities().contains(this)) {
    if (object instanceof Permanent) {
      return false;
    }
 else {
      Abilities<Ability> otherAbilities=game.getState().getAllOtherAbilities(this.getSourceId());
      if (otherAbilities == null || !otherAbilities.contains(this)) {
        return false;
      }
    }
  }
  Zone test=game.getState().getZone(parameterSourceId);
  return test != null && zone.match(test);
}
Program: 158973
Project: 158973
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player target=game.getPlayer(source.getFirstTarget());
  if (target != null) {
    for (    Permanent p : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(),target.getId(),game)) {
      p.addCounters(CounterType.M1M1.createInstance(),game);
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player targetPlayer=game.getPlayer(getTargetPointer().getFirst(game,source));
  if (targetPlayer != null) {
    for (    Permanent creature : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(),targetPlayer.getId(),game)) {
      creature.addCounters(CounterType.M1M1.createInstance(),game);
    }
    return true;
  }
  return false;
}
Program: 158977
Project: 158977
Buggy source:
@Override public boolean apply(Permanent input,Game game){
  return input.getCounters().containsKey(counter);
}

Fixed version (ground truth):
@Override public boolean apply(Permanent input,Game game){
  if (counter == null) {
    return !input.getCounters().keySet().isEmpty();
  }
 else {
    return input.getCounters().containsKey(counter);
  }
}
Program: 158978
Project: 158978
Buggy source:
public CounterPredicate(CounterType counter){
  this.counter=counter;
}

Fixed version (ground truth):
/** 
 * @param counter if null any counter selects the permanent
 */
public CounterPredicate(CounterType counter){
  this.counter=counter;
}
Program: 158979
Project: 158979
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player targetOpponent=game.getPlayer(source.getTargets().getFirstTarget());
  Player controller=game.getPlayer(source.getControllerId());
  if (targetOpponent == null || controller == null) {
    return false;
  }
  FilterControlledPermanent filter=new FilterControlledPermanent("String_Node_Str");
  filter.add(new CardTypePredicate(CardType.CREATURE));
  filter.add(new ControllerPredicate(TargetController.YOU));
  filter.add(Predicates.or(new ColorPredicate(ObjectColor.GREEN),new ColorPredicate(ObjectColor.WHITE)));
  TargetControlledPermanent target=new TargetControlledPermanent(1,1,filter,false);
  if (target.canChoose(targetOpponent.getId(),game)) {
    targetOpponent.chooseTarget(Outcome.Sacrifice,target,source,game);
    Permanent permanent=game.getPermanent(target.getFirstTarget());
    if (permanent != null) {
      if (permanent.sacrifice(source.getSourceId(),game)) {
        controller.loseLife(2,game);
      }
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player targetOpponent=game.getPlayer(source.getTargets().getFirstTarget());
  Player controller=game.getPlayer(source.getControllerId());
  if (targetOpponent == null || controller == null) {
    return false;
  }
  FilterControlledPermanent filter=new FilterControlledPermanent("String_Node_Str");
  filter.add(new CardTypePredicate(CardType.CREATURE));
  filter.add(new ControllerPredicate(TargetController.YOU));
  filter.add(Predicates.or(new ColorPredicate(ObjectColor.GREEN),new ColorPredicate(ObjectColor.WHITE)));
  TargetControlledPermanent target=new TargetControlledPermanent(1,1,filter,false);
  if (target.canChoose(targetOpponent.getId(),game)) {
    targetOpponent.chooseTarget(Outcome.Sacrifice,target,source,game);
    Permanent permanent=game.getPermanent(target.getFirstTarget());
    if (permanent != null) {
      if (permanent.sacrifice(source.getSourceId(),game)) {
        targetOpponent.loseLife(2,game);
      }
    }
  }
  return true;
}
Program: 158980
Project: 158980
Buggy source:
protected final String getType(CardView card){
  StringBuilder sbType=new StringBuilder();
  for (  String superType : card.getSuperTypes()) {
    sbType.append(superType).append("String_Node_Str");
  }
  for (  CardType cardType : card.getCardTypes()) {
    sbType.append(cardType.toString()).append("String_Node_Str");
  }
  if (card.getSubTypes().size() > 0) {
    sbType.append("String_Node_Str");
    for (    String subType : card.getSubTypes()) {
      sbType.append(subType).append("String_Node_Str");
    }
  }
  return sbType.toString();
}

Fixed version (ground truth):
protected final String getType(CardView card){
  StringBuilder sbType=new StringBuilder();
  for (  String superType : card.getSuperTypes()) {
    sbType.append(superType).append("String_Node_Str");
  }
  for (  CardType cardType : card.getCardTypes()) {
    sbType.append(cardType.toString()).append("String_Node_Str");
  }
  if (card.getSubTypes().size() > 0) {
    sbType.append("String_Node_Str");
    for (    String subType : card.getSubTypes()) {
      sbType.append(subType).append("String_Node_Str");
    }
  }
  return sbType.toString().trim();
}
Program: 158982
Project: 158982
Buggy source:
@Override public boolean applies(GameEvent event,Ability source,Game game){
  if (event.getTargetId().equals(source.getSourceId())) {
    Permanent sourcePermanent=game.getPermanent(source.getSourceId());
    game.getState().setValue(sourcePermanent.getId().toString() + "String_Node_Str",null);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(GameEvent event,Ability source,Game game){
  return event.getTargetId().equals(source.getSourceId());
}
Program: 158983
Project: 158983
Buggy source:
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Permanent creature=game.getPermanent(event.getTargetId());
  Player controller=game.getPlayer(creature.getControllerId());
  if (controller != null) {
    for (    String subtype : creature.getSubtype()) {
      filter.add(new SubtypePredicate((subtype)));
    }
    if (controller.getHand().count(filter,source.getSourceId(),source.getControllerId(),game) > 0) {
      if (controller.chooseUse(Outcome.Benefit,"String_Node_Str",game)) {
        TargetCardInHand target=new TargetCardInHand(0,Integer.MAX_VALUE,filter);
        if (controller.choose(Outcome.Benefit,target,source.getSourceId(),game)) {
          Cards cards=new CardsImpl();
          for (          UUID uuid : target.getTargets()) {
            cards.add(controller.getHand().get(uuid,game));
          }
          int amountCounters=cards.size() * amplifyFactor.getFactor();
          creature.addCounters(CounterType.P1P1.createInstance(amountCounters),game);
          controller.revealCards("String_Node_Str",cards,game);
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Permanent sourceCreature=game.getPermanent(event.getTargetId());
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null && sourceCreature != null) {
    FilterCreatureCard filter=new FilterCreatureCard("String_Node_Str");
    List<SubtypePredicate> filterSubtypes=new ArrayList<>();
    for (    String subtype : sourceCreature.getSubtype()) {
      filterSubtypes.add(new SubtypePredicate((subtype)));
    }
    filter.add(Predicates.or(filterSubtypes));
    if (controller.getHand().count(filter,source.getSourceId(),source.getControllerId(),game) > 0) {
      if (controller.chooseUse(outcome,"String_Node_Str",game)) {
        TargetCardInHand target=new TargetCardInHand(0,Integer.MAX_VALUE,filter);
        if (controller.choose(outcome,target,source.getSourceId(),game) && !target.getTargets().isEmpty()) {
          Cards cards=new CardsImpl();
          cards.addAll(target.getTargets());
          int amountCounters=cards.size() * amplifyFactor.getFactor();
          sourceCreature.addCounters(CounterType.P1P1.createInstance(amountCounters),game);
          controller.revealCards(sourceCreature.getLogName(),cards,game);
        }
      }
    }
  }
  return false;
}
Program: 158985
Project: 158985
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  MageObject sourceObject=game.getObject(source.getSourceId());
  if (controller != null) {
    Player targetPlayer=game.getPlayer(getTargetPointer().getFirst(game,source));
    if (targetPlayer != null) {
      if (targetPlayer.getHand().size() > 0) {
        Cards cards=new CardsImpl();
        Card card=targetPlayer.getHand().getRandom(game);
        cards.add(card);
        if (targetPlayer.getHand().size() > 1) {
          do {
            card=targetPlayer.getHand().getRandom(game);
          }
 while (cards.contains(card.getId()));
          cards.add(card);
        }
        targetPlayer.revealCards(sourceObject.getLogName(),cards,game);
        for (        Card cardToDiscard : cards.getCards(game)) {
          if (!card.getCardType().contains(CardType.LAND)) {
            targetPlayer.discard(cardToDiscard,source,game);
          }
        }
      }
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  MageObject sourceObject=game.getObject(source.getSourceId());
  if (controller != null) {
    Player targetPlayer=game.getPlayer(getTargetPointer().getFirst(game,source));
    if (targetPlayer != null) {
      if (targetPlayer.getHand().size() > 0) {
        Cards cards=new CardsImpl();
        Card card=targetPlayer.getHand().getRandom(game);
        cards.add(card);
        if (targetPlayer.getHand().size() > 1) {
          do {
            card=targetPlayer.getHand().getRandom(game);
          }
 while (cards.contains(card.getId()));
          cards.add(card);
        }
        targetPlayer.revealCards(sourceObject.getLogName(),cards,game);
        for (        Card cardToDiscard : cards.getCards(game)) {
          if (!cardToDiscard.getCardType().contains(CardType.LAND)) {
            targetPlayer.discard(cardToDiscard,source,game);
          }
        }
      }
    }
    return true;
  }
  return false;
}
Program: 158986
Project: 158986
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(targetPointer.getFirst(game,source));
  if (player == null) {
    return false;
  }
  filter.add(new ControllerPredicate(TargetController.YOU));
  int amount=count.calculate(game,source,this);
  int realCount=game.getBattlefield().countAll(filter,player.getId(),game);
  amount=Math.min(amount,realCount);
  Target target=new TargetPermanent(amount,amount,filter,true);
  if (amount > 0 && target.canChoose(source.getSourceId(),player.getId(),game)) {
    boolean abilityApplied=false;
    while (!target.isChosen() && target.canChoose(player.getId(),game) && player.isInGame()) {
      player.chooseTarget(Outcome.Sacrifice,target,source,game);
    }
    for (int idx=0; idx < target.getTargets().size(); idx++) {
      Permanent permanent=game.getPermanent(target.getTargets().get(idx));
      if (permanent != null) {
        abilityApplied|=permanent.sacrifice(source.getSourceId(),game);
      }
    }
    return abilityApplied;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(targetPointer.getFirst(game,source));
  if (player == null) {
    return false;
  }
  FilterPermanent newFilter=filter.copy();
  newFilter.add(new ControllerIdPredicate(player.getId()));
  int amount=count.calculate(game,source,this);
  int realCount=game.getBattlefield().countAll(newFilter,player.getId(),game);
  amount=Math.min(amount,realCount);
  Target target=new TargetPermanent(amount,amount,newFilter,true);
  if (amount > 0 && target.canChoose(source.getSourceId(),player.getId(),game)) {
    boolean abilityApplied=false;
    while (!target.isChosen() && target.canChoose(player.getId(),game) && player.isInGame()) {
      player.chooseTarget(Outcome.Sacrifice,target,source,game);
    }
    for (int idx=0; idx < target.getTargets().size(); idx++) {
      Permanent permanent=game.getPermanent(target.getTargets().get(idx));
      if (permanent != null) {
        abilityApplied|=permanent.sacrifice(source.getSourceId(),game);
      }
    }
    return abilityApplied;
  }
  return false;
}
Program: 158987
Project: 158987
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Permanent permanent=game.getPermanent(source.getSourceId());
  if (permanent != null) {
    Permanent attach=game.getPermanent(permanent.getAttachedTo());
    if (attach != null) {
      attach.tap(game);
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Permanent permanent=(Permanent)source.getSourceObject(game);
  if (permanent != null) {
    Permanent attach=game.getPermanent(permanent.getAttachedTo());
    if (attach != null) {
      attach.tap(game);
      return true;
    }
  }
  return false;
}
Program: 158988
Project: 158988
Buggy source:
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    Card card=game.getCard(getTargetPointer().getFirst(game,source));
    if (card != null) {
      controller.moveCardToGraveyardWithInfo(card,source.getSourceId(),game,Zone.STACK);
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    Card card=game.getCard(getTargetPointer().getFirst(game,source));
    if (card != null) {
      controller.moveCardToExileWithInfo(card,null,"String_Node_Str",source.getSourceId(),game,Zone.STACK);
      return true;
    }
  }
  return false;
}
Program: 158989
Project: 158989
Buggy source:
@Override public boolean applies(GameEvent event,Ability source,Game game){
  Spell spell=game.getStack().getSpell(event.getTargetId());
  if (spell != null && spell.getControllerId().equals(source.getControllerId()) && filterTarget.match(spell,game)) {
    if (filterSource == null) {
      return true;
    }
 else {
      MageObject sourceObject=game.getObject(source.getSourceId());
      if (sourceObject != null && filterSource.match(sourceObject,game)) {
        return true;
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(GameEvent event,Ability source,Game game){
  Spell spell=game.getStack().getSpell(event.getTargetId());
  if (spell != null && spell.getControllerId().equals(source.getControllerId()) && filterTarget.match(spell,source.getControllerId(),game)) {
    if (filterSource == null) {
      return true;
    }
 else {
      MageObject sourceObject=game.getObject(event.getSourceId());
      if (sourceObject != null && filterSource.match(sourceObject,game)) {
        return true;
      }
    }
  }
  return false;
}
Program: 158990
Project: 158990
Buggy source:
public CavernOfSoulsWatcher(final CavernOfSoulsWatcher watcher){
  super(watcher);
}

Fixed version (ground truth):
public CavernOfSoulsWatcher(final CavernOfSoulsWatcher watcher){
  super(watcher);
  this.spells.addAll(watcher.spells);
}
Program: 158991
Project: 158991
Buggy source:
@Override public boolean applies(GameEvent event,Ability source,Game game){
  if (event.getType() == GameEvent.EventType.COUNTER) {
    CavernOfSoulsWatcher watcher=(CavernOfSoulsWatcher)game.getState().getWatchers().get("String_Node_Str");
    Spell spell=game.getStack().getSpell(event.getTargetId());
    if (spell != null && watcher.spells.contains(spell.getId())) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(GameEvent event,Ability source,Game game){
  CavernOfSoulsWatcher watcher=(CavernOfSoulsWatcher)game.getState().getWatchers().get("String_Node_Str");
  Spell spell=game.getStack().getSpell(event.getTargetId());
  return spell != null && watcher.spells.contains(spell.getId());
}
Program: 158992
Project: 158992
Buggy source:
@Override public PredatoryRampageEffect copy(){
  return new PredatoryRampageEffect(this);
}

Fixed version (ground truth):
@Override public PredatoryRampage copy(){
  return new PredatoryRampage(this);
}
Program: 158995
Project: 158995
Buggy source:
@Override public boolean applies(GameEvent event,Ability source,Game game){
  return event.getPlayerId().equals(source.getSourceId());
}

Fixed version (ground truth):
@Override public boolean applies(GameEvent event,Ability source,Game game){
  Player controller=game.getPlayer(source.getControllerId());
  return controller != null && controller.hasOpponent(event.getPlayerId(),game);
}
Program: 158996
Project: 158996
Buggy source:
@Override public boolean applies(GameEvent event,Ability source,Game game){
  if (event.getType() == GameEvent.EventType.ADD_COUNTER && event.getData().equals(CounterType.P1P1.getName())) {
    Permanent target=game.getPermanent(event.getTargetId());
    if (target != null && target.getControllerId().equals(source.getControllerId()) && target.getCardType().contains(CardType.CREATURE)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(GameEvent event,Ability source,Game game){
  if (event.getData().equals(CounterType.P1P1.getName())) {
    Permanent target=game.getPermanent(event.getTargetId());
    if (target != null && target.getControllerId().equals(source.getControllerId()) && target.getCardType().contains(CardType.CREATURE)) {
      return true;
    }
  }
  return false;
}
Program: 158998
Project: 158998
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (!event.getTargetId().equals(getSourceId())) {
    Permanent sourcePermanent=game.getPermanentOrLKIBattlefield(getSourceId());
    if (sourcePermanent != null) {
      if (sourcePermanent.isFaceDown(game)) {
        return false;
      }
    }
 else {
      return false;
    }
  }
  Permanent permanent=game.getPermanent(event.getTargetId());
  if (filter.match(permanent,getSourceId(),getControllerId(),game)) {
    if (setTargetPointer) {
      for (      Effect effect : getEffects()) {
        effect.setTargetPointer(new FixedTarget(event.getTargetId()));
      }
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (!event.getTargetId().equals(getSourceId())) {
    MageObject sourceObj=this.getSourceObject(game);
    if (sourceObj != null) {
      if (sourceObj instanceof Card && ((Card)sourceObj).isFaceDown(game)) {
        return false;
      }
    }
 else {
      return false;
    }
  }
  Permanent permanent=game.getPermanent(event.getTargetId());
  if (filter.match(permanent,getSourceId(),getControllerId(),game)) {
    if (setTargetPointer) {
      for (      Effect effect : getEffects()) {
        effect.setTargetPointer(new FixedTarget(event.getTargetId()));
      }
    }
    return true;
  }
  return false;
}
Program: 158999
Project: 158999
Buggy source:
public static void scan(){
  if (scanned) {
    return;
  }
  scanned=true;
  List<CardInfo> cardsToAdd=new ArrayList<>();
  List<String> packages=new ArrayList<>();
  for (  ExpansionSet set : Sets.getInstance().values()) {
    packages.add(set.getPackageName());
    ExpansionRepository.instance.add(new ExpansionInfo(set));
  }
  ExpansionRepository.instance.setContentVersion(CardRepository.instance.getContentVersionConstant());
  for (  Class c : ClassScanner.findClasses(packages,CardImpl.class)) {
    if (!CardRepository.instance.cardExists(c.getCanonicalName())) {
      Card card=CardImpl.createCard(c);
      if (card != null) {
        cardsToAdd.add(new CardInfo(card));
        if (card instanceof SplitCard) {
          SplitCard splitCard=(SplitCard)card;
          cardsToAdd.add(new CardInfo(splitCard.getLeftHalfCard()));
          cardsToAdd.add(new CardInfo(splitCard.getRightHalfCard()));
        }
      }
    }
  }
  if (!cardsToAdd.isEmpty()) {
    logger.info("String_Node_Str" + cardsToAdd.size());
    CardRepository.instance.addCards(cardsToAdd);
  }
  CardRepository.instance.setContentVersion(CardRepository.instance.getContentVersionConstant());
}

Fixed version (ground truth):
public static void scan(){
  if (scanned) {
    return;
  }
  scanned=true;
  List<CardInfo> cardsToAdd=new ArrayList<>();
  List<String> packages=new ArrayList<>();
  for (  ExpansionSet set : Sets.getInstance().values()) {
    packages.add(set.getPackageName());
    ExpansionRepository.instance.add(new ExpansionInfo(set));
  }
  ExpansionRepository.instance.setContentVersion(ExpansionRepository.instance.getContentVersionConstant());
  for (  Class c : ClassScanner.findClasses(packages,CardImpl.class)) {
    if (!CardRepository.instance.cardExists(c.getCanonicalName())) {
      Card card=CardImpl.createCard(c);
      if (card != null) {
        cardsToAdd.add(new CardInfo(card));
        if (card instanceof SplitCard) {
          SplitCard splitCard=(SplitCard)card;
          cardsToAdd.add(new CardInfo(splitCard.getLeftHalfCard()));
          cardsToAdd.add(new CardInfo(splitCard.getRightHalfCard()));
        }
      }
    }
  }
  if (!cardsToAdd.isEmpty()) {
    logger.info("String_Node_Str" + cardsToAdd.size());
    CardRepository.instance.addCards(cardsToAdd);
  }
  CardRepository.instance.setContentVersion(CardRepository.instance.getContentVersionConstant());
}
Program: 159001
Project: 159001
Buggy source:
/** 
 * Name of Tiny Leader comes from the deck name (it's not in the sideboard) Additionally, it was taken into account that WOTC had missed a few color combinations when making Legendary Creatures at 3 CMC. There are three Commanders available to use  for the missing color identities:  Mardu [WBR 2/2],  Sultai [UBG 2/2], and  Jeskai [WUR 2/2]. 
 * @param commanderName
 * @param ownerId
 * @return 
 */
public static Card getCommanderCard(String commanderName,UUID ownerId){
  Card commander=null;
switch (commanderName) {
case "String_Node_Str":
    commander=new DefaultCommander(ownerId,commanderName,"String_Node_Str");
  break;
default :
CardInfo cardInfo=CardRepository.instance.findCard(commanderName);
if (cardInfo != null) {
commander=cardInfo.getCard();
}
}
return commander;
}

Fixed version (ground truth):
/** 
 * Name of Tiny Leader comes from the deck name (it's not in the sideboard) Additionally, it was taken into account that WOTC had missed a few color combinations when making Legendary Creatures at 3 CMC. There are three Commanders available to use  for the missing color identities:  Mardu [WBR 2/2],  Sultai [UBG 2/2], and  Jeskai [WUR 2/2]. 
 * @param commanderName
 * @param ownerId
 * @return 
 */
public static Card getCommanderCard(String commanderName,UUID ownerId){
  Card commander=null;
  if (commanderName != null) {
switch (commanderName) {
case "String_Node_Str":
      commander=new DefaultCommander(ownerId,commanderName,"String_Node_Str");
    break;
default :
  CardInfo cardInfo=CardRepository.instance.findCard(commanderName);
if (cardInfo != null) {
  commander=cardInfo.getCard();
}
}
}
return commander;
}
Program: 159002
Project: 159002
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Permanent p=game.getPermanent(source.getFirstTarget());
  if (p != null) {
    p.destroy(source.getSourceId(),game,false);
  }
  Permanent s=game.getPermanent(source.getSourceId());
  if (s != null) {
    s.destroy(source.getSourceId(),game,false);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Permanent p=game.getPermanent(getTargetPointer().getFirst(game,source));
  if (p != null) {
    p.destroy(source.getSourceId(),game,false);
  }
  Permanent s=game.getPermanent(source.getSourceId());
  if (s != null) {
    s.destroy(source.getSourceId(),game,false);
  }
  return true;
}
Program: 159004
Project: 159004
Buggy source:
@Override public String getText(Mode mode){
  if (staticText != null && !staticText.isEmpty()) {
    return staticText;
  }
  if (targetName.length() > 0) {
    return targetName + "String_Node_Str";
  }
 else {
    return "String_Node_Str" + mode.getTargets().get(0).getTargetName() + "String_Node_Str";
  }
}

Fixed version (ground truth):
@Override public String getText(Mode mode){
  if (staticText != null && !staticText.isEmpty()) {
    return staticText;
  }
  if (targetName != null && targetName.length() > 0) {
    return targetName + "String_Node_Str";
  }
 else {
    return "String_Node_Str" + mode.getTargets().get(0).getTargetName() + "String_Node_Str";
  }
}
Program: 159005
Project: 159005
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (game.getPlayer(this.getControllerId()).hasOpponent(event.getPlayerId(),game)) {
    MageObject object=game.getLastKnownInformation(event.getTargetId(),Zone.BATTLEFIELD);
    if (object instanceof Permanent && !(object instanceof PermanentToken)) {
      for (      Effect effect : getEffects()) {
        effect.setTargetPointer(new FixedTarget(event.getTargetId()));
      }
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (game.getPlayer(getControllerId()).hasOpponent(event.getPlayerId(),game)) {
    Permanent permanent=(Permanent)game.getLastKnownInformation(event.getTargetId(),Zone.BATTLEFIELD);
    if (permanent != null && !(permanent instanceof PermanentToken)) {
      for (      Effect effect : getEffects()) {
        effect.setTargetPointer(new FixedTarget(event.getTargetId()));
      }
      return true;
    }
  }
  return false;
}
Program: 159006
Project: 159006
Buggy source:
@Override public boolean moveToZone(Zone toZone,UUID sourceId,Game game,boolean flag,ArrayList<UUID> appliedEffects){
  Zone fromZone=game.getState().getZone(objectId);
  Player controller=game.getPlayer(controllerId);
  if (controller != null && controller.removeFromBattlefield(this,game)) {
    Card originalCard=game.getCard(this.getId());
    ZoneChangeEvent event=new ZoneChangeEvent(this,sourceId,controllerId,fromZone,toZone,appliedEffects);
    if (!game.replaceEvent(event)) {
      Player owner=game.getPlayer(ownerId);
      game.rememberLKI(objectId,Zone.BATTLEFIELD,this);
      if (owner != null) {
        this.setControllerId(ownerId);
        if (originalCard != null) {
          originalCard.updateZoneChangeCounter();
        }
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 COMMAND:
game.addCommander(new Commander(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.addSimultaneousEvent(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,ArrayList<UUID> appliedEffects){
  Zone fromZone=game.getState().getZone(objectId);
  Player controller=game.getPlayer(controllerId);
  if (controller != null && controller.removeFromBattlefield(this,game)) {
    Card originalCard=game.getCard(this.getId());
    ZoneChangeEvent event=new ZoneChangeEvent(this,sourceId,controllerId,fromZone,toZone,appliedEffects);
    if (!game.replaceEvent(event)) {
      Player owner=game.getPlayer(ownerId);
      game.rememberLKI(objectId,Zone.BATTLEFIELD,this);
      if (owner != null) {
        if (originalCard != null) {
          originalCard.updateZoneChangeCounter();
        }
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 COMMAND:
game.addCommander(new Commander(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.addSimultaneousEvent(event);
return game.getState().getZone(objectId) == toZone;
}
}
}
return false;
}
Program: 159007
Project: 159007
Buggy source:
@Override public boolean apply(Game game,Ability source){
  ExileZone exileZone=game.getExile().getExileZone(source.getSourceId());
  if (exileZone != null) {
    for (    Card card : exileZone.getCards(game)) {
      Player player=game.getPlayer(card.getOwnerId());
      if (player != null) {
        player.putOntoBattlefieldWithInfo(card,game,Zone.EXILED,source.getSourceId());
      }
    }
    exileZone.clear();
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  MageObject sourceObject=source.getSourceObject(game);
  if (sourceObject != null) {
    UUID exileZoneId=CardUtil.getObjectExileZoneId(game,sourceObject);
    if (exileZoneId != null) {
      ExileZone exileZone=game.getExile().getExileZone(exileZoneId);
      if (exileZone != null) {
        for (        Card card : exileZone.getCards(game)) {
          Player player=game.getPlayer(card.getOwnerId());
          if (player != null) {
            player.putOntoBattlefieldWithInfo(card,game,Zone.EXILED,source.getSourceId());
          }
        }
        exileZone.clear();
      }
      return true;
    }
  }
  return false;
}
Program: 159009
Project: 159009
Buggy source:
public ExileView(ExileZone exileZone,Game game){
  this.name=exileZone.getName();
  this.id=exileZone.getId();
  for (  Card card : exileZone.getCards(game)) {
    this.put(card.getId(),new CardView(card));
  }
}

Fixed version (ground truth):
public ExileView(ExileZone exileZone,Game game){
  this.name=exileZone.getName();
  this.id=exileZone.getId();
  for (  Card card : exileZone.getCards(game)) {
    this.put(card.getId(),new CardView(card,game,card.getId(),false));
  }
}
Program: 159010
Project: 159010
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Card card=game.getCard(getTargetPointer().getFirst(game,source));
  if (card != null) {
    Effect effect=new ReturnFromGraveyardToBattlefieldTargetEffect();
    effect.setTargetPointer(new FixedTarget(card.getId()));
    effect.setText("String_Node_Str");
    DelayedTriggeredAbility delayedAbility=new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
    delayedAbility.setSourceId(source.getSourceId());
    delayedAbility.setControllerId(source.getControllerId());
    delayedAbility.setSourceObject(source.getSourceObject(game));
    game.addDelayedTriggeredAbility(delayedAbility);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Card card=game.getCard(getTargetPointer().getFirst(game,source));
  if (card != null) {
    Effect effect=new ReturnFromGraveyardToBattlefieldTargetEffect();
    effect.setTargetPointer(new FixedTarget(card.getId()));
    effect.setText("String_Node_Str");
    DelayedTriggeredAbility delayedAbility=new AtTheBeginOfNextEndStepDelayedTriggeredAbility(Zone.COMMAND,effect,TargetController.ANY);
    delayedAbility.setSourceId(source.getSourceId());
    delayedAbility.setControllerId(source.getControllerId());
    delayedAbility.setSourceObject(source.getSourceObject(game));
    game.addDelayedTriggeredAbility(delayedAbility);
    return true;
  }
  return false;
}
Program: 159011
Project: 159011
Buggy source:
public AtTheBeginOfNextEndStepDelayedTriggeredAbility(AtTheBeginOfNextEndStepDelayedTriggeredAbility ability){
  super(ability);
  this.targetController=ability.targetController;
}

Fixed version (ground truth):
public AtTheBeginOfNextEndStepDelayedTriggeredAbility(final AtTheBeginOfNextEndStepDelayedTriggeredAbility ability){
  super(ability);
  this.targetController=ability.targetController;
}
Program: 159012
Project: 159012
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Card card;
  Player player=game.getPlayer(source.getControllerId());
  if (player == null) {
    return false;
  }
  ExileZone exile=game.getExile().createZone(source.getSourceId(),player.getName() + "String_Node_Str");
  Card stackCard=game.getCard(targetPointer.getFirst(game,source));
  if (stackCard == null) {
    return false;
  }
  int sourceCost=stackCard.getManaCost().convertedManaCost();
  do {
    card=player.getLibrary().removeFromTop(game);
    if (card == null) {
      break;
    }
    player.moveCardToExileWithInfo(card,source.getSourceId(),exile.getName(),source.getSourceId(),game,Zone.LIBRARY);
  }
 while (card.getCardType().contains(CardType.LAND) || card.getManaCost().convertedManaCost() >= sourceCost);
  if (card != null) {
    if (player.chooseUse(outcome,"String_Node_Str" + card.getName() + "String_Node_Str",game)) {
      player.cast(card.getSpellAbility(),game,true);
      exile.remove(card.getId());
    }
  }
  while (exile.size() > 0) {
    card=exile.getRandom(game);
    exile.remove(card.getId());
    player.moveCardToLibraryWithInfo(card,source.getSourceId(),game,Zone.EXILED,false,false);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  return CascadeAbility.applyCascade(outcome,game,source);
}
Program: 159014
Project: 159014
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Card card;
  Player player=game.getPlayer(source.getControllerId());
  if (player == null) {
    return false;
  }
  ExileZone exile=game.getExile().createZone(source.getSourceId(),player.getName() + "String_Node_Str");
  int sourceCost=game.getCard(source.getSourceId()).getManaCost().convertedManaCost();
  do {
    card=player.getLibrary().getFromTop(game);
    if (card == null) {
      break;
    }
    player.moveCardToExileWithInfo(card,exile.getId(),exile.getName(),source.getSourceId(),game,Zone.LIBRARY);
  }
 while (player.isInGame() && card.getCardType().contains(CardType.LAND) || card.getManaCost().convertedManaCost() >= sourceCost);
  if (card != null) {
    if (player.chooseUse(outcome,"String_Node_Str" + card.getName() + "String_Node_Str",game)) {
      if (player.cast(card.getSpellAbility(),game,true)) {
        exile.remove(card.getId());
      }
    }
  }
  while (exile.size() > 0) {
    card=exile.getRandom(game);
    exile.remove(card.getId());
    player.moveCardToLibraryWithInfo(card,source.getSourceId(),game,Zone.EXILED,false,false);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  return CascadeAbility.applyCascade(outcome,game,source);
}