nus-yam/ex-repair huggingface dataset:
Program: 159384
Project: 159384
Buggy source:
/** 
 * Various AI optimizations for actions.
 * @param allActions
 */
protected void optimize(Game game,List<Ability> allActions){
  for (  TreeOptimizer optimizer : optimizers) {
    optimizer.optimize(game,allActions);
  }
  Collections.sort(allActions,new Comparator<Ability>(){
    @Override public int compare(    Ability ability,    Ability ability1){
      String rule=ability.toString();
      String rule1=ability1.toString();
      if (rule.equals("String_Node_Str")) {
        return 1;
      }
      if (rule1.equals("String_Node_Str")) {
        return -1;
      }
      if (rule.startsWith("String_Node_Str")) {
        return -1;
      }
      if (rule1.startsWith("String_Node_Str")) {
        return 1;
      }
      if (rule.startsWith("String_Node_Str")) {
        return -1;
      }
      if (rule1.startsWith("String_Node_Str")) {
        return 1;
      }
      return ability.getRule().compareTo(ability1.getRule());
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Various AI optimizations for actions.
 * @param game
 * @param allActions
 */
protected void optimize(Game game,List<Ability> allActions){
  for (  TreeOptimizer optimizer : optimizers) {
    optimizer.optimize(game,allActions);
  }
  Collections.sort(allActions,new Comparator<Ability>(){
    @Override public int compare(    Ability ability,    Ability ability1){
      String rule=ability.toString();
      String rule1=ability1.toString();
      if (rule.equals("String_Node_Str")) {
        return 1;
      }
      if (rule1.equals("String_Node_Str")) {
        return -1;
      }
      if (rule.startsWith("String_Node_Str")) {
        return -1;
      }
      if (rule1.startsWith("String_Node_Str")) {
        return 1;
      }
      if (rule.startsWith("String_Node_Str")) {
        return -1;
      }
      if (rule1.startsWith("String_Node_Str")) {
        return 1;
      }
      return ability.getRule().compareTo(ability1.getRule());
    }
  }
);
}
Program: 159385
Project: 159385
Buggy source:
protected void calculateActions(Game game){
  if (!getNextAction(game)) {
    Game sim=createSimulation(game);
    SimulationNode2.resetCount();
    root=new SimulationNode2(null,sim,maxDepth,playerId);
    logger.info("String_Node_Str");
    currentScore=GameStateEvaluator2.evaluate(playerId,game);
    addActionsTimed();
    if (root.children.size() > 0) {
      root=root.children.get(0);
      int bestScore=root.getScore();
      actions=new LinkedList<Ability>(root.abilities);
      combat=root.combat;
    }
 else {
      logger.info("String_Node_Str" + game.getPlayer(playerId).getName() + "String_Node_Str"+ root.getScore()+ "String_Node_Str"+ currentScore);
    }
  }
}

Fixed version (ground truth):
protected void calculateActions(Game game){
  if (!getNextAction(game)) {
    Game sim=createSimulation(game);
    SimulationNode2.resetCount();
    root=new SimulationNode2(null,sim,maxDepth,playerId);
    logger.info("String_Node_Str");
    currentScore=GameStateEvaluator2.evaluate(playerId,game);
    addActionsTimed();
    if (root.children.size() > 0) {
      root=root.children.get(0);
      int bestScore=root.getScore();
      actions=new LinkedList<>(root.abilities);
      combat=root.combat;
    }
 else {
      logger.info("String_Node_Str" + game.getPlayer(playerId).getName() + "String_Node_Str"+ root.getScore()+ "String_Node_Str"+ currentScore);
    }
  }
}
Program: 159386
Project: 159386
Buggy source:
protected boolean getNextAction(Game game){
  if (root != null && root.children.size() > 0) {
    SimulationNode2 test=root;
    root=root.children.get(0);
    while (root.children.size() > 0 && !root.playerId.equals(playerId)) {
      test=root;
      root=root.children.get(0);
    }
    logger.trace("String_Node_Str" + game.getState().getValue(true) + "String_Node_Str"+ test.gameValue);
    if (!suggested.isEmpty()) {
      return false;
    }
    if (root.playerId.equals(playerId) && root.abilities != null && game.getState().getValue(true).hashCode() == test.gameValue) {
      logger.info("String_Node_Str");
      actions=new LinkedList<Ability>(root.abilities);
      combat=root.combat;
      return true;
    }
 else {
      return false;
    }
  }
  return false;
}

Fixed version (ground truth):
protected boolean getNextAction(Game game){
  if (root != null && root.children.size() > 0) {
    SimulationNode2 test=root;
    root=root.children.get(0);
    while (root.children.size() > 0 && !root.playerId.equals(playerId)) {
      test=root;
      root=root.children.get(0);
    }
    logger.trace("String_Node_Str" + game.getState().getValue(true) + "String_Node_Str"+ test.gameValue);
    if (!suggested.isEmpty()) {
      return false;
    }
    if (root.playerId.equals(playerId) && root.abilities != null && game.getState().getValue(true).hashCode() == test.gameValue) {
      logger.info("String_Node_Str");
      actions=new LinkedList<>(root.abilities);
      combat=root.combat;
      return true;
    }
 else {
      return false;
    }
  }
  return false;
}
Program: 159387
Project: 159387
Buggy source:
/** 
 * Mark an ability to be removed Not thread-safe for performance reasons.
 * @param ability
 */
protected void removeAbility(Ability ability){
  if (toRemove == null) {
    toRemove=new ArrayList<Ability>();
  }
  toRemove.add(ability);
}

Fixed version (ground truth):
/** 
 * Mark an ability to be removed Not thread-safe for performance reasons.
 * @param ability
 */
protected void removeAbility(Ability ability){
  if (toRemove == null) {
    toRemove=new ArrayList<>();
  }
  toRemove.add(ability);
}
Program: 159388
Project: 159388
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getControllerId());
  if (player == null) {
    return false;
  }
  Card card=player.getLibrary().getFromTop(game);
  if (card != null) {
    Cards cards=new CardsImpl(Zone.PICK);
    cards.add(card);
    player.lookAtCards("String_Node_Str",cards,game);
  }
 else {
    return false;
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getControllerId());
  if (player == null) {
    return false;
  }
  Card card=player.getLibrary().getFromTop(game);
  if (card != null) {
    Cards cards=new CardsImpl(card);
    player.lookAtCards("String_Node_Str",cards,game);
  }
 else {
    return false;
  }
  return true;
}
Program: 159389
Project: 159389
Buggy source:
public MaritLageToken(){
  super("String_Node_Str","String_Node_Str");
  cardType.add(CardType.CREATURE);
  subtype.add("String_Node_Str");
  supertype.add("String_Node_Str");
  color=ObjectColor.BLACK;
  power=new MageInt(20);
  toughness=new MageInt(20);
  this.addAbility(FlyingAbility.getInstance());
  this.addAbility(IndestructibleAbility.getInstance());
  this.setOriginalExpansionSetCode("String_Node_Str");
}

Fixed version (ground truth):
public MaritLageToken(){
  super("String_Node_Str","String_Node_Str");
  this.setOriginalExpansionSetCode("String_Node_Str");
  cardType.add(CardType.CREATURE);
  subtype.add("String_Node_Str");
  supertype.add("String_Node_Str");
  color.setBlack(true);
  power=new MageInt(20);
  toughness=new MageInt(20);
  this.addAbility(FlyingAbility.getInstance());
  this.addAbility(IndestructibleAbility.getInstance());
}
Program: 159390
Project: 159390
Buggy source:
@Override public boolean applies(GameEvent event,Ability source,Game game){
  if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).getToZone() == Zone.BATTLEFIELD && ((ZoneChangeEvent)event).getFromZone() != Zone.HAND) {
    Card card=game.getCard(event.getTargetId());
    if (card != null && card.getCardType().contains(CardType.ENCHANTMENT) && card.hasSubtype("String_Node_Str")) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(GameEvent event,Ability source,Game game){
  if (event.getType().equals(GameEvent.EventType.ZONE_CHANGE)) {
    if (((ZoneChangeEvent)event).getToZone().equals(Zone.BATTLEFIELD) && !(((ZoneChangeEvent)event).getFromZone().equals(Zone.HAND))) {
      Card card=game.getCard(event.getTargetId());
      if (card != null && card.getCardType().contains(CardType.ENCHANTMENT) && card.hasSubtype("String_Node_Str")) {
        return true;
      }
    }
  }
  return false;
}
Program: 159392
Project: 159392
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller == null) {
    return false;
  }
  for (  UUID playerId : controller.getInRange()) {
    Player player=game.getPlayer(playerId);
    if (player != null) {
      TargetCardInHand target=new TargetCardInHand(filter);
      if (player.choose(Outcome.PutCreatureInPlay,target,source.getSourceId(),game)) {
        Card card=game.getCard(target.getFirstTarget());
        if (card != null) {
          card.putOntoBattlefield(game,Zone.HAND,source.getId(),player.getId());
        }
      }
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller == null) {
    return false;
  }
  for (  UUID playerId : controller.getInRange()) {
    Player player=game.getPlayer(playerId);
    if (player != null) {
      TargetCardInHand target=new TargetCardInHand(filter);
      if (player.choose(Outcome.PutCreatureInPlay,target,source.getSourceId(),game)) {
        Card card=game.getCard(target.getFirstTarget());
        if (card != null) {
          player.putOntoBattlefieldWithInfo(card,game,Zone.HAND,source.getSourceId());
        }
      }
    }
  }
  return true;
}
Program: 159393
Project: 159393
Buggy source:
@Override public boolean applies(Ability abilityToModify,Ability source,Game game){
  Permanent permanent=game.getPermanent(abilityToModify.getSourceId());
  if (abilityToModify instanceof ActivatedAbility && permanent != null && filter.match(permanent,source.getId(),source.getControllerId(),game)) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(Ability abilityToModify,Ability source,Game game){
  if (abilityToModify instanceof ActivatedAbility) {
    Permanent permanent=game.getPermanent(abilityToModify.getSourceId());
    if (permanent != null && filter.match(permanent,source.getSourceId(),source.getControllerId(),game)) {
      return true;
    }
  }
  return false;
}
Program: 159394
Project: 159394
Buggy source:
@Override public boolean apply(Game game,Ability source,Ability abilityToModify){
  Mana mana=abilityToModify.getManaCostsToPay().getMana();
  int reduceMax=mana.getColorless();
  if (mana.count() == mana.getColorless()) {
    reduceMax--;
  }
  if (reduceMax > 2) {
    reduceMax=2;
  }
  Player player=game.getPlayer(abilityToModify.getControllerId());
  if (player != null) {
    ChoiceImpl choice=new ChoiceImpl(true);
    LinkedHashSet<String> set=new LinkedHashSet<String>();
    for (int i=0; i <= reduceMax; i++) {
      set.add(String.valueOf(i));
    }
    choice.setChoices(set);
    choice.setMessage("String_Node_Str");
    if (player.choose(Outcome.Benefit,choice,game)) {
      int reduce=Integer.parseInt(choice.getChoice());
      mana.setColorless(mana.getColorless() - reduce);
      abilityToModify.getManaCostsToPay().load(mana.toString());
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source,Ability abilityToModify){
  Player controller=game.getPlayer(abilityToModify.getControllerId());
  if (controller != null) {
    Mana mana=abilityToModify.getManaCostsToPay().getMana();
    int reduceMax=mana.getColorless();
    if (reduceMax > 0 && mana.count() == mana.getColorless()) {
      reduceMax--;
    }
    if (reduceMax > 2) {
      reduceMax=2;
    }
    if (reduceMax > 0) {
      ChoiceImpl choice=new ChoiceImpl(true);
      Set<String> set=new LinkedHashSet<>();
      for (int i=0; i <= reduceMax; i++) {
        set.add(String.valueOf(i));
      }
      choice.setChoices(set);
      choice.setMessage("String_Node_Str");
      if (controller.choose(Outcome.Benefit,choice,game)) {
        int reduce=Integer.parseInt(choice.getChoice());
        mana.setColorless(mana.getColorless() - reduce);
        abilityToModify.getManaCostsToPay().load(mana.toString());
      }
    }
    return true;
  }
  return false;
}
Program: 159397
Project: 159397
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player targetPlayer=game.getPlayer(this.getTargetPointer().getFirst(game,source));
  if (targetPlayer != null) {
    Target target=new TargetCardInHand(new FilterArtifactCard());
    target.setRequired(true);
    if (target.canChoose(source.getSourceId(),targetPlayer.getId(),game) && targetPlayer.chooseUse(outcome,"String_Node_Str",game) && targetPlayer.chooseTarget(outcome,target,source,game)) {
      return targetPlayer.discard(targetPlayer.getHand().get(target.getFirstTarget(),game),source,game);
    }
 else {
      targetPlayer.discard(Math.min(targetPlayer.getHand().size(),2),source,game);
    }
    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));
  if (targetPlayer != null && !targetPlayer.getHand().isEmpty()) {
    TargetDiscard target=new TargetDiscard(targetPlayer.getId());
    targetPlayer.choose(Outcome.Discard,target,source.getSourceId(),game);
    Card card=targetPlayer.getHand().get(target.getFirstTarget(),game);
    if (card != null) {
      targetPlayer.discard(card,source,game);
      if (!card.getCardType().contains(CardType.ARTIFACT) && !targetPlayer.getHand().isEmpty()) {
        targetPlayer.discard(1,source,game);
      }
      return true;
    }
  }
  return false;
}
Program: 159398
Project: 159398
Buggy source:
@Override public void discardToMax(Game game){
  int cardsStart=hand.size();
  if (cardsStart > this.maxHandSize) {
    while (hand.size() > this.maxHandSize) {
      TargetDiscard target=new TargetDiscard(playerId);
      target.setTargetName(new StringBuilder("String_Node_Str").append(hand.size() - this.maxHandSize).append("String_Node_Str").toString());
      choose(Outcome.Discard,target,null,game);
      discard(hand.get(target.getFirstTarget(),game),null,game);
    }
    int discarded=cardsStart - hand.size();
    game.informPlayers(new StringBuilder(getName()).append("String_Node_Str").append(discarded).append(discarded == 1 ? "String_Node_Str" : "String_Node_Str").append("String_Node_Str").toString());
  }
}

Fixed version (ground truth):
@Override public void discardToMax(Game game){
  if (hand.size() > this.maxHandSize) {
    game.informPlayers(new StringBuilder(getName()).append("String_Node_Str").append(this.maxHandSize).append(this.maxHandSize == 1 ? "String_Node_Str" : "String_Node_Str").toString());
    while (hand.size() > this.maxHandSize) {
      TargetDiscard target=new TargetDiscard(playerId);
      target.setTargetName(new StringBuilder("String_Node_Str").append(hand.size() - this.maxHandSize).append("String_Node_Str").toString());
      choose(Outcome.Discard,target,null,game);
      discard(hand.get(target.getFirstTarget(),game),null,game);
    }
  }
}
Program: 159401
Project: 159401
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.ZONE_CHANGE && event.getSourceId() != null && event.getSourceId().equals(getSourceId())) {
    ZoneChangeEvent zEvent=(ZoneChangeEvent)event;
    if (zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getToZone() == Zone.EXILED) {
      MageObject object=game.getObject(event.getTargetId());
      if (object != null && object.getSubtype().contains("String_Node_Str")) {
        return true;
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.ZONE_CHANGE && event.getSourceId() != null && event.getSourceId().equals(getSourceId())) {
    ZoneChangeEvent zEvent=(ZoneChangeEvent)event;
    if (zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getToZone() == Zone.EXILED) {
      if (zEvent.getTarget() != null && zEvent.getTarget().getSubtype().contains("String_Node_Str")) {
        return true;
      }
    }
  }
  return false;
}
Program: 159403
Project: 159403
Buggy source:
public Spell(final Spell<T> spell){
  this.id=spell.id;
  for (  SpellAbility spellAbility : spell.spellAbilities) {
    this.spellAbilities.add(spellAbility.copy());
  }
  for (  Card spellCard : spell.spellCards) {
    this.spellCards.add(spellCard.copy());
  }
  if (spell.spellAbilities.get(0).equals(spell.ability)) {
    this.ability=spellAbilities.get(0);
  }
 else {
    this.ability=spell.ability.copy();
  }
  if (spell.spellCards.get(0).equals(spell.card)) {
    this.card=spellCards.get(0);
  }
 else {
    this.card=spell.card.copy();
  }
  this.controllerId=spell.controllerId;
  this.fromZone=spell.fromZone;
  this.copiedSpell=spell.copiedSpell;
}

Fixed version (ground truth):
public Spell(final Spell<T> spell){
  this.id=spell.id;
  for (  SpellAbility spellAbility : spell.spellAbilities) {
    this.spellAbilities.add(spellAbility.copy());
  }
  for (  Card spellCard : spell.spellCards) {
    this.spellCards.add(spellCard.copy());
  }
  if (spell.spellAbilities.get(0).equals(spell.ability)) {
    this.ability=this.spellAbilities.get(0);
  }
 else {
    this.ability=spell.ability.copy();
  }
  if (spell.spellCards.get(0).equals(spell.card)) {
    this.card=spellCards.get(0);
  }
 else {
    this.card=spell.card.copy();
  }
  this.controllerId=spell.controllerId;
  this.fromZone=spell.fromZone;
  this.copiedSpell=spell.copiedSpell;
}
Program: 159404
Project: 159404
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
    Permanent triggeringCreature=game.getPermanent(event.getTargetId());
    if (triggeringCreature != null && triggeringCreature.getCardType().contains(CardType.CREATURE) && triggeringCreature.getControllerId().equals(this.controllerId)) {
      Permanent sourceCreature=game.getPermanent(sourceId);
      if (sourceCreature != null && isPowerOrThoughnessGreater(sourceCreature,triggeringCreature)) {
        this.getEffects().get(0).setValue("String_Node_Str",event.getTargetId());
        return true;
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD && !event.getTargetId().equals(this.getSourceId())) {
    Permanent triggeringCreature=game.getPermanent(event.getTargetId());
    if (triggeringCreature != null && triggeringCreature.getCardType().contains(CardType.CREATURE) && triggeringCreature.getControllerId().equals(this.controllerId)) {
      Permanent sourceCreature=game.getPermanent(sourceId);
      if (sourceCreature != null && isPowerOrThoughnessGreater(sourceCreature,triggeringCreature)) {
        this.getEffects().get(0).setValue("String_Node_Str",event.getTargetId());
        return true;
      }
    }
  }
  return false;
}
Program: 159407
Project: 159407
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(targetPointer.getFirst(game,source));
  if (player != null) {
    int cardsCount=Math.min(amount.calculate(game,source),player.getLibrary().size());
    for (int i=0; i < cardsCount; i++) {
      Card card=player.getLibrary().removeFromTop(game);
      if (card != null) {
        card.moveToZone(Zone.GRAVEYARD,source.getId(),game,false);
      }
 else {
        break;
      }
    }
    return true;
  }
  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) {
    int cardsCount=Math.min(amount.calculate(game,source),player.getLibrary().size());
    for (int i=0; i < cardsCount; i++) {
      Card card=player.getLibrary().getFromTop(game);
      if (card != null) {
        player.moveCardToGraveyardWithInfo(card,source.getId(),game,Zone.LIBRARY);
      }
 else {
        break;
      }
    }
    return true;
  }
  return false;
}
Program: 159408
Project: 159408
Buggy source:
private SplitSecondAbility(){
  super(Zone.STACK,new SplitSecondEffect());
  this.setRuleAtTheTop(true);
}

Fixed version (ground truth):
public SplitSecondAbility(SplitSecondAbility ability){
  super(ability);
}
Program: 159409
Project: 159409
Buggy source:
@Override public boolean canPay(UUID sourceId,UUID controllerId,Game game){
  if (!game.getPlayer(controllerId).canPaySacrificeCost()) {
    return false;
  }
  Permanent permanent=game.getPermanent(sourceId);
  if (permanent != null) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean canPay(UUID sourceId,UUID controllerId,Game game){
  if (!game.getPlayer(controllerId).canPaySacrificeCost()) {
    return false;
  }
  Permanent permanent=game.getPermanent(sourceId);
  return permanent != null;
}
Program: 159410
Project: 159410
Buggy source:
@Override public boolean sacrifice(UUID sourceId,Game game){
  if (!game.replaceEvent(GameEvent.getEvent(EventType.SACRIFICE_PERMANENT,objectId,sourceId,controllerId))) {
    if (moveToZone(Zone.GRAVEYARD,sourceId,game,true) || game.getState().getZone(this.getId()).equals(Zone.COMMAND)) {
      Player player=game.getPlayer(getControllerId());
      if (player != null) {
        game.informPlayers(new StringBuilder(player.getName()).append("String_Node_Str").append(this.getName()).toString());
      }
      game.fireEvent(GameEvent.getEvent(EventType.SACRIFICED_PERMANENT,objectId,sourceId,controllerId));
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean sacrifice(UUID sourceId,Game game){
  if (!game.replaceEvent(GameEvent.getEvent(EventType.SACRIFICE_PERMANENT,objectId,sourceId,controllerId))) {
    moveToZone(Zone.GRAVEYARD,sourceId,game,true);
    Player player=game.getPlayer(getControllerId());
    if (player != null) {
      game.informPlayers(new StringBuilder(player.getName()).append("String_Node_Str").append(this.getName()).toString());
    }
    game.fireEvent(GameEvent.getEvent(EventType.SACRIFICED_PERMANENT,objectId,sourceId,controllerId));
    return true;
  }
  return false;
}
Program: 159411
Project: 159411
Buggy source:
@Override public void init(Ability source,Game game){
  super.init(source,game);
  FilterLandPermanent filter=new FilterLandPermanent("String_Node_Str");
  filter.add(new SubtypePredicate("String_Node_Str"));
  filter.add(new ControllerPredicate(TargetController.YOU));
  this.amount=game.getBattlefield().count(filter,source.getSourceId(),source.getControllerId(),game);
  Player player=game.getPlayer(source.getControllerId());
  String message="String_Node_Str";
  if (player != null && player.chooseUse(Outcome.Neutral,message,game)) {
    this.amount*=-1;
  }
  targetPointer.init(game,source);
}

Fixed version (ground truth):
@Override public void init(Ability source,Game game){
  super.init(source,game);
  FilterLandPermanent filter=new FilterLandPermanent("String_Node_Str");
  filter.add(new SubtypePredicate("String_Node_Str"));
  filter.add(new ControllerPredicate(TargetController.YOU));
  this.amount=game.getBattlefield().count(filter,source.getSourceId(),source.getControllerId(),game);
  Player player=game.getPlayer(source.getControllerId());
  String message="String_Node_Str";
  if (player != null && player.chooseUse(Outcome.Neutral,message,game)) {
    this.amount*=-1;
  }
}
Program: 159412
Project: 159412
Buggy source:
@Override public void init(Ability source,Game game){
  super.init(source,game);
  Permanent permanent=game.getPermanent(this.targetPointer.getFirst(game,source));
  if (permanent != null) {
    FilterCreaturePermanent filter=new FilterCreaturePermanent();
    filter.add(Predicates.not(new PermanentIdPredicate(this.targetPointer.getFirst(game,source))));
    filter.add(new AttackingPredicate());
    boolean isChangeling=false;
    for (    Ability ability : permanent.getAbilities()) {
      if (ability instanceof ChangelingAbility) {
        isChangeling=true;
      }
    }
    if (!isChangeling) {
      ArrayList<Predicate<MageObject>> predicateList=new ArrayList<Predicate<MageObject>>();
      for (      String subtype : permanent.getSubtype()) {
        predicateList.add(new SubtypePredicate(subtype));
      }
      filter.add(Predicates.or(predicateList));
    }
    power=game.getBattlefield().getActivePermanents(filter,source.getControllerId(),source.getId(),game).size();
  }
  targetPointer.init(game,source);
}

Fixed version (ground truth):
@Override public void init(Ability source,Game game){
  super.init(source,game);
  Permanent permanent=game.getPermanent(this.targetPointer.getFirst(game,source));
  if (permanent != null) {
    FilterCreaturePermanent filter=new FilterCreaturePermanent();
    filter.add(Predicates.not(new PermanentIdPredicate(this.targetPointer.getFirst(game,source))));
    filter.add(new AttackingPredicate());
    boolean isChangeling=false;
    for (    Ability ability : permanent.getAbilities()) {
      if (ability instanceof ChangelingAbility) {
        isChangeling=true;
      }
    }
    if (!isChangeling) {
      ArrayList<Predicate<MageObject>> predicateList=new ArrayList<>();
      for (      String subtype : permanent.getSubtype()) {
        predicateList.add(new SubtypePredicate(subtype));
      }
      filter.add(Predicates.or(predicateList));
    }
    power=game.getBattlefield().getActivePermanents(filter,source.getControllerId(),source.getId(),game).size();
  }
}
Program: 159413
Project: 159413
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE && event.getPlayerId().equals(this.controllerId)) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  return event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE && event.getPlayerId().equals(this.controllerId);
}
Program: 159414
Project: 159414
Buggy source:
@Override public void init(Ability source,Game game){
  if (source instanceof ActivatedAbility || source instanceof TriggeredAbility) {
    if (layer != null) {
switch (layer) {
case CopyEffects_1:
case ControlChangingEffects_2:
case TextChangingEffects_3:
case TypeChangingEffects_4:
case ColorChangingEffects_5:
case AbilityAddingRemovingEffects_6:
case PTChangingEffects_7:
        this.affectedObjectsSet=true;
    }
  }
 else {
    if (hasLayer(Layer.CopyEffects_1) || hasLayer(Layer.ControlChangingEffects_2) || hasLayer(Layer.TextChangingEffects_3)|| hasLayer(Layer.TypeChangingEffects_4)|| hasLayer(Layer.ColorChangingEffects_5)|| hasLayer(Layer.AbilityAddingRemovingEffects_6)|| hasLayer(Layer.PTChangingEffects_7)) {
      this.affectedObjectsSet=true;
    }
  }
}
}

Fixed version (ground truth):
@Override public void init(Ability source,Game game){
  targetPointer.init(game,source);
  if (source instanceof ActivatedAbility || source instanceof TriggeredAbility) {
    if (layer != null) {
switch (layer) {
case CopyEffects_1:
case ControlChangingEffects_2:
case TextChangingEffects_3:
case TypeChangingEffects_4:
case ColorChangingEffects_5:
case AbilityAddingRemovingEffects_6:
case PTChangingEffects_7:
        this.affectedObjectsSet=true;
    }
  }
 else {
    if (hasLayer(Layer.CopyEffects_1) || hasLayer(Layer.ControlChangingEffects_2) || hasLayer(Layer.TextChangingEffects_3)|| hasLayer(Layer.TypeChangingEffects_4)|| hasLayer(Layer.ColorChangingEffects_5)|| hasLayer(Layer.AbilityAddingRemovingEffects_6)|| hasLayer(Layer.PTChangingEffects_7)) {
      this.affectedObjectsSet=true;
    }
  }
}
}
Program: 159415
Project: 159415
Buggy source:
public EffectImpl(final EffectImpl effect){
  this.id=effect.id;
  this.outcome=effect.outcome;
  this.effectType=effect.effectType;
  this.staticText=effect.staticText;
  this.targetPointer=effect.targetPointer.copy();
  if (effect.values != null) {
    values=new HashMap<String,Object>();
    Map<String,Object> map=effect.values;
    for (    Map.Entry<String,Object> entry : map.entrySet()) {
      values.put(entry.getKey(),entry.getValue());
    }
  }
  this.applyEffectsAfter=effect.applyEffectsAfter;
}

Fixed version (ground truth):
public EffectImpl(final EffectImpl effect){
  this.id=effect.id;
  this.outcome=effect.outcome;
  this.effectType=effect.effectType;
  this.staticText=effect.staticText;
  this.targetPointer=effect.targetPointer.copy();
  if (effect.values != null) {
    values=new HashMap<>();
    Map<String,Object> map=effect.values;
    for (    Map.Entry<String,Object> entry : map.entrySet()) {
      values.put(entry.getKey(),entry.getValue());
    }
  }
  this.applyEffectsAfter=effect.applyEffectsAfter;
}
Program: 159416
Project: 159416
Buggy source:
@Override public void setValue(String key,Object value){
synchronized (this) {
    if (values == null) {
      values=new HashMap<String,Object>();
    }
  }
  values.put(key,value);
}

Fixed version (ground truth):
@Override public void setValue(String key,Object value){
synchronized (this) {
    if (values == null) {
      values=new HashMap<>();
    }
  }
  values.put(key,value);
}
Program: 159417
Project: 159417
Buggy source:
@Override public boolean apply(Game game,Ability source){
  List<FixedTarget> detainedObjects=new ArrayList<FixedTarget>();
  for (  Permanent permanent : game.getBattlefield().getActivePermanents(filter,source.getControllerId(),source.getSourceId(),game)) {
    game.informPlayers("String_Node_Str" + permanent.getName());
    FixedTarget fixedTarget=new FixedTarget(permanent.getId());
    fixedTarget.init(game,source);
    detainedObjects.add(fixedTarget);
  }
  game.addEffect(new DetainAllRestrictionEffect(detainedObjects),source);
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  List<FixedTarget> detainedObjects=new ArrayList<>();
  for (  Permanent permanent : game.getBattlefield().getActivePermanents(filter,source.getControllerId(),source.getSourceId(),game)) {
    game.informPlayers("String_Node_Str" + permanent.getName());
    FixedTarget fixedTarget=new FixedTarget(permanent.getId());
    fixedTarget.init(game,source);
    detainedObjects.add(fixedTarget);
  }
  game.addEffect(new DetainAllRestrictionEffect(detainedObjects),source);
  return false;
}
Program: 159418
Project: 159418
Buggy source:
@Override public boolean apply(Game game,Ability source){
  for (  UUID target : this.getTargetPointer().getTargets(game,source)) {
    Permanent permanent=game.getPermanent(target);
    if (permanent != null) {
      game.informPlayers("String_Node_Str" + permanent.getName());
    }
  }
  DetainRestrictionEffect effect=new DetainRestrictionEffect();
  effect.getTargetPointer().init(game,source);
  game.addEffect(effect,source);
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  for (  UUID target : this.getTargetPointer().getTargets(game,source)) {
    Permanent permanent=game.getPermanent(target);
    if (permanent != null) {
      game.informPlayers("String_Node_Str" + permanent.getName());
    }
  }
  DetainRestrictionEffect effect=new DetainRestrictionEffect();
  game.addEffect(effect,source);
  return true;
}
Program: 159419
Project: 159419
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Permanent permanent=game.getPermanent(targetPointer.getFirst(game,source));
  UUID exileId=source.getSourceId();
  if (permanent != null) {
    return permanent.moveToExile(exileId,exileZone,source.getId(),game);
  }
 else {
    Card card=game.getCard(targetPointer.getFirst(game,source));
    if (card != null) {
      return card.moveToExile(exileId,exileZone,source.getId(),game);
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    Permanent permanent=game.getPermanent(targetPointer.getFirst(game,source));
    UUID exileId=source.getSourceId();
    if (permanent != null) {
      return controller.moveCardToExileWithInfo(permanent,exileId,exileZone,source.getSourceId(),game,Zone.BATTLEFIELD);
    }
 else {
      Card card=game.getCard(targetPointer.getFirst(game,source));
      if (card != null) {
        return controller.moveCardToExileWithInfo(card,exileId,exileZone,source.getSourceId(),game,game.getState().getZone(card.getId()));
      }
    }
  }
  return false;
}
Program: 159420
Project: 159420
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Card card=game.getCard(targetPointer.getFirst(game,source));
  if (card != null) {
    Zone currentZone=game.getState().getZone(card.getId());
    if (card.putOntoBattlefield(game,currentZone,source.getId(),source.getControllerId())) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    Card card=game.getCard(targetPointer.getFirst(game,source));
    if (card != null) {
      Zone currentZone=game.getState().getZone(card.getId());
      if (controller.putOntoBattlefieldWithInfo(card,game,currentZone,source.getSourceId())) {
        return true;
      }
    }
  }
  return false;
}
Program: 159421
Project: 159421
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));
  }
  targetPointer.init(game,source);
}

Fixed version (ground truth):
@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));
  }
}
Program: 159423
Project: 159423
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  Permanent sourcePermanent=game.getPermanent(source.getSourceId());
  if (controller != null && sourcePermanent != null) {
    Choice cardChoice=new ChoiceImpl();
    cardChoice.setChoices(CardRepository.instance.getNames());
    cardChoice.clearChoice();
    while (!controller.choose(Outcome.Detriment,cardChoice,game)) {
      if (!controller.isInGame()) {
        return false;
      }
    }
    String cardName=cardChoice.getChoice();
    game.informPlayers("String_Node_Str" + cardName + "String_Node_Str");
    FilterCard filter=new FilterCard(cardName);
    filter.add(new NamePredicate(cardName));
    for (    Ability ability : sourcePermanent.getAbilities()) {
      if (ability instanceof ProtectionAbility) {
        ((ProtectionAbility)ability).setFilter(filter);
      }
    }
    sourcePermanent.addInfo("String_Node_Str",new StringBuilder("String_Node_Str").append(cardName).append("String_Node_Str").toString());
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  return true;
}
Program: 159424
Project: 159424
Buggy source:
@Override public NameCard copy(){
  return new NameCard(this);
}

Fixed version (ground truth):
@Override public RunedHaloRuleTextEffect copy(){
  return new RunedHaloRuleTextEffect(this);
}
Program: 159425
Project: 159425
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getControllerId());
  if (player != null) {
    player.addAbility(ability);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getControllerId());
  if (player != null) {
    player.addAbility(ability);
    if (duration.equals(Duration.Custom)) {
      if (game.getPermanent(source.getSourceId()) == null) {
        discard();
      }
    }
    return true;
  }
 else {
    discard();
  }
  return false;
}
Program: 159426
Project: 159426
Buggy source:
public HashMap<RequirementEffect,HashSet<Ability>> getApplicableRequirementEffects(Permanent permanent,Game game){
  HashMap<RequirementEffect,HashSet<Ability>> effects=new HashMap<>();
  for (  RequirementEffect effect : requirementEffects) {
    HashSet<Ability> abilities=requirementEffects.getAbility(effect.getId());
    HashSet<Ability> applicableAbilities=new HashSet<>();
    for (    Ability ability : abilities) {
      if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game,null,false)) {
        if (effect.applies(permanent,ability,game)) {
          applicableAbilities.add(ability);
        }
      }
    }
    if (!applicableAbilities.isEmpty()) {
      effects.put(effect,abilities);
    }
  }
  return effects;
}

Fixed version (ground truth):
public HashMap<RequirementEffect,HashSet<Ability>> getApplicableRequirementEffects(Permanent permanent,Game game){
  HashMap<RequirementEffect,HashSet<Ability>> effects=new HashMap<>();
  for (  RequirementEffect effect : requirementEffects) {
    HashSet<Ability> abilities=requirementEffects.getAbility(effect.getId());
    HashSet<Ability> applicableAbilities=new HashSet<>();
    for (    Ability ability : abilities) {
      if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game,ability instanceof MageSingleton ? permanent : null,false)) {
        if (effect.applies(permanent,ability,game)) {
          applicableAbilities.add(ability);
        }
      }
    }
    if (!applicableAbilities.isEmpty()) {
      effects.put(effect,abilities);
    }
  }
  return effects;
}
Program: 159427
Project: 159427
Buggy source:
@Override public void mousePressed(MouseEvent e){
  this.hideDialog();
}

Fixed version (ground truth):
@Override public void mousePressed(MouseEvent e){
  if (e.getSource() instanceof CardPanel) {
    this.hideDialog();
  }
}
Program: 159428
Project: 159428
Buggy source:
public void pickTarget(String message,CardsView cardView,GameView gameView,Set<UUID> targets,boolean required,Map<String,Serializable> options,int messageId){
  ShowCardsDialog dialog=null;
  updateGame(gameView);
  Map<String,Serializable> options0=options == null ? new HashMap<String,Serializable>() : options;
  if (cardView != null && cardView.size() > 0) {
    dialog=showCards(message,cardView,required,options0);
    options0.put("String_Node_Str",dialog);
  }
  this.feedbackPanel.getFeedback(required ? FeedbackMode.INFORM : FeedbackMode.CANCEL,message,gameView.getSpecial(),options0,messageId);
  if (dialog != null) {
    this.pickTarget.add(dialog);
  }
}

Fixed version (ground truth):
/** 
 * Shows a pick target dialog  and allows the player to pick a target (e.g. the pick triggered ability)
 * @param message
 * @param cardView
 * @param gameView
 * @param targets
 * @param required
 * @param options
 * @param messageId 
 */
public void pickTarget(String message,CardsView cardView,GameView gameView,Set<UUID> targets,boolean required,Map<String,Serializable> options,int messageId){
  ShowCardsDialog dialog=null;
  updateGame(gameView);
  Map<String,Serializable> options0=options == null ? new HashMap<String,Serializable>() : options;
  if (cardView != null && cardView.size() > 0) {
    dialog=showCards(message,cardView,required,options0);
    options0.put("String_Node_Str",dialog);
  }
  this.feedbackPanel.getFeedback(required ? FeedbackMode.INFORM : FeedbackMode.CANCEL,message,gameView.getSpecial(),options0,messageId);
  if (dialog != null) {
    this.pickTarget.add(dialog);
  }
}
Program: 159429
Project: 159429
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    Choice cardChoice=new ChoiceImpl();
    cardChoice.setChoices(CardRepository.instance.getNames());
    cardChoice.clearChoice();
    while (!controller.choose(Outcome.Detriment,cardChoice,game)) {
      if (!controller.isInGame()) {
        return false;
      }
    }
    String cardName=cardChoice.getChoice();
    game.informPlayers("String_Node_Str" + cardName + "String_Node_Str");
    FilterCard filter=new FilterCard(cardName);
    filter.add(new NamePredicate(cardName));
    Permanent permanent=game.getPermanent(source.getSourceId());
    if (permanent != null) {
      for (      Ability ability : permanent.getAbilities()) {
        if (ability instanceof ProtectionAbility) {
          ((ProtectionAbility)ability).setFilter(filter);
        }
      }
    }
    permanent.addInfo("String_Node_Str",new StringBuilder("String_Node_Str").append(cardName).append("String_Node_Str").toString());
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  Permanent sourcePermanent=game.getPermanent(source.getSourceId());
  if (controller != null && sourcePermanent != null) {
    Choice cardChoice=new ChoiceImpl();
    cardChoice.setChoices(CardRepository.instance.getNames());
    cardChoice.clearChoice();
    while (!controller.choose(Outcome.Detriment,cardChoice,game)) {
      if (!controller.isInGame()) {
        return false;
      }
    }
    String cardName=cardChoice.getChoice();
    game.informPlayers("String_Node_Str" + cardName + "String_Node_Str");
    FilterCard filter=new FilterCard(cardName);
    filter.add(new NamePredicate(cardName));
    for (    Ability ability : sourcePermanent.getAbilities()) {
      if (ability instanceof ProtectionAbility) {
        ((ProtectionAbility)ability).setFilter(filter);
      }
    }
    sourcePermanent.addInfo("String_Node_Str",new StringBuilder("String_Node_Str").append(cardName).append("String_Node_Str").toString());
  }
  return false;
}
Program: 159430
Project: 159430
Buggy source:
@Override public void loadCards(CardsView showCards,SortSetting sortSetting,BigCard bigCard,UUID gameId,boolean merge){
  boolean drawImage=showCards.size() < MAX_IMAGES;
  this.bigCard=bigCard;
  this.gameId=gameId;
  if (merge) {
    for (    CardView card : showCards.values()) {
      if (!cards.containsKey(card.getId())) {
        addCard(card,bigCard,gameId,drawImage);
      }
    }
    for (Iterator<Entry<UUID,MageCard>> i=cards.entrySet().iterator(); i.hasNext(); ) {
      Entry<UUID,MageCard> entry=i.next();
      if (!showCards.containsKey(entry.getKey())) {
        removeCardImg(entry.getKey());
        i.remove();
      }
    }
  }
 else {
    this.clearCards();
    for (    CardView card : showCards.values()) {
      addCard(card,bigCard,gameId,drawImage);
    }
  }
  drawCards(sortSetting);
  this.setVisible(true);
}

Fixed version (ground truth):
@Override public void loadCards(CardsView showCards,SortSetting sortSetting,BigCard bigCard,UUID gameId,boolean merge){
  boolean drawImage=showCards.size() <= MAX_IMAGES;
  this.bigCard=bigCard;
  this.gameId=gameId;
  if (merge) {
    for (    CardView card : showCards.values()) {
      if (!cards.containsKey(card.getId())) {
        addCard(card,bigCard,gameId,drawImage);
      }
    }
    for (Iterator<Entry<UUID,MageCard>> i=cards.entrySet().iterator(); i.hasNext(); ) {
      Entry<UUID,MageCard> entry=i.next();
      if (!showCards.containsKey(entry.getKey())) {
        removeCardImg(entry.getKey());
        i.remove();
      }
    }
  }
 else {
    this.clearCards();
    for (    CardView card : showCards.values()) {
      addCard(card,bigCard,gameId,drawImage);
    }
  }
  drawCards(sortSetting);
  this.setVisible(true);
}
Program: 159431
Project: 159431
Buggy source:
private void setReminderText(Card card){
  StringBuilder sb=new StringBuilder("String_Node_Str");
  int i=0;
  for (  String subtype : card.getSubtype()) {
    i++;
    sb.append(subtype);
    if (card.getSupertype().size() > 1 && i < card.getSupertype().size()) {
      sb.append("String_Node_Str");
    }
  }
  reminderText=sb.toString();
}

Fixed version (ground truth):
private void setReminderText(Card card){
  StringBuilder sb=new StringBuilder("String_Node_Str");
  int i=0;
  for (  String subtype : card.getSubtype()) {
    i++;
    sb.append(subtype);
    if (card.getSubtype().size() > 1 && i < card.getSubtype().size()) {
      sb.append("String_Node_Str");
    }
  }
  sb.append("String_Node_Str");
  reminderText=sb.toString();
}
Program: 159432
Project: 159432
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(targetPointer.getFirst(game,source));
  Player controller=game.getPlayer(source.getControllerId());
  if (player != null && controller != null) {
    Choice cardChoice=new ChoiceImpl();
    cardChoice.setChoices(CardRepository.instance.getNonLandNames());
    cardChoice.clearChoice();
    while (!controller.choose(Outcome.Discard,cardChoice,game)) {
      if (!controller.isInGame()) {
        return false;
      }
    }
    String cardName=cardChoice.getChoice();
    game.informPlayers("String_Node_Str" + cardName + "String_Node_Str");
    for (    Card card : player.getHand().getCards(game)) {
      if (card.getName().equals(cardName)) {
        card.moveToZone(Zone.GRAVEYARD,source.getId(),game,false);
      }
    }
    controller.lookAtCards("String_Node_Str",player.getHand(),game);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(targetPointer.getFirst(game,source));
  Player controller=game.getPlayer(source.getControllerId());
  if (player != null && controller != null) {
    Choice cardChoice=new ChoiceImpl();
    cardChoice.setChoices(CardRepository.instance.getNonLandNames());
    cardChoice.clearChoice();
    while (!controller.choose(Outcome.Discard,cardChoice,game)) {
      if (!controller.isInGame()) {
        return false;
      }
    }
    String cardName=cardChoice.getChoice();
    game.informPlayers("String_Node_Str" + cardName + "String_Node_Str");
    for (    Card card : player.getHand().getCards(game)) {
      if (card.getName().equals(cardName)) {
        player.discard(card,source,game);
      }
    }
    controller.lookAtCards("String_Node_Str",player.getHand(),game);
  }
  return true;
}
Program: 159433
Project: 159433
Buggy source:
@Override public boolean canActivate(UUID playerId,Game game){
  if (this.spellCanBeActivatedRegularlyNow(playerId,game) || game.getContinuousEffects().asThough(sourceId,AsThoughEffectType.CAST,playerId,game)) {
    if (spellAbilityType.equals(SpellAbilityType.SPLIT)) {
      return false;
    }
    if (!controllerId.equals(playerId)) {
      return false;
    }
    if (this.getManaCosts().isEmpty()) {
      return false;
    }
    if (costs.canPay(sourceId,controllerId,game)) {
      if (getSpellAbilityType().equals(SpellAbilityType.SPLIT_FUSED)) {
        SplitCard splitCard=(SplitCard)game.getCard(getSourceId());
        if (splitCard != null) {
          return (splitCard.getLeftHalfCard().getSpellAbility().canChooseTarget(game) && splitCard.getRightHalfCard().getSpellAbility().canChooseTarget(game));
        }
        return false;
      }
 else {
        return canChooseTarget(game);
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean canActivate(UUID playerId,Game game){
  if (this.spellCanBeActivatedRegularlyNow(playerId,game) || game.getContinuousEffects().asThough(sourceId,AsThoughEffectType.CAST,playerId,game)) {
    if (spellAbilityType.equals(SpellAbilityType.SPLIT)) {
      return false;
    }
    if (!controllerId.equals(playerId)) {
      return false;
    }
    if (costs.canPay(sourceId,controllerId,game)) {
      if (getSpellAbilityType().equals(SpellAbilityType.SPLIT_FUSED)) {
        SplitCard splitCard=(SplitCard)game.getCard(getSourceId());
        if (splitCard != null) {
          return (splitCard.getLeftHalfCard().getSpellAbility().canChooseTarget(game) && splitCard.getRightHalfCard().getSpellAbility().canChooseTarget(game));
        }
        return false;
      }
 else {
        return canChooseTarget(game);
      }
    }
  }
  return false;
}