nus-yam/ex-repair huggingface dataset:
Program: 159793
Project: 159793
Buggy source:
public GameImpl(final GameImpl<T> game){
  long t1=0;
  if (logger.isDebugEnabled()) {
    t1=System.currentTimeMillis();
  }
  this.id=game.id;
  this.ready=game.ready;
  this.startingPlayerId=game.startingPlayerId;
  this.winnerId=game.winnerId;
  this.range=game.range;
  this.attackOption=game.attackOption;
  this.state=game.state.copy();
  this.gameCards=game.gameCards;
  this.simulation=game.simulation;
  this.gameOptions=game.gameOptions;
  this.lki.putAll(game.lki);
  this.shortLivingLKI.putAll(game.shortLivingLKI);
  if (logger.isDebugEnabled()) {
    copyCount++;
    copyTime+=(System.currentTimeMillis() - t1);
  }
  this.actions=new LinkedList<MageAction>();
  this.stateCheckRequired=game.stateCheckRequired;
  this.scorePlayer=game.scorePlayer;
  this.scopeRelevant=game.scopeRelevant;
}

Fixed version (ground truth):
public GameImpl(final GameImpl<T> game){
  long t1=0;
  if (logger.isDebugEnabled()) {
    t1=System.currentTimeMillis();
  }
  this.id=game.id;
  this.ready=game.ready;
  this.startingPlayerId=game.startingPlayerId;
  this.winnerId=game.winnerId;
  this.range=game.range;
  this.attackOption=game.attackOption;
  this.state=game.state.copy();
  for (  Map.Entry<UUID,Card> entry : game.gameCards.entrySet()) {
    this.gameCards.put(entry.getKey(),entry.getValue().copy());
  }
  this.simulation=game.simulation;
  this.gameOptions=game.gameOptions;
  this.lki.putAll(game.lki);
  this.shortLivingLKI.putAll(game.shortLivingLKI);
  if (logger.isDebugEnabled()) {
    copyCount++;
    copyTime+=(System.currentTimeMillis() - t1);
  }
  this.actions=new LinkedList<MageAction>();
  this.stateCheckRequired=game.stateCheckRequired;
  this.scorePlayer=game.scorePlayer;
  this.scopeRelevant=game.scopeRelevant;
}
Program: 159794
Project: 159794
Buggy source:
protected String getMessageText(Game game){
  StringBuilder sb=new StringBuilder();
  MageObject object=game.getObject(this.sourceId);
  if (object != null) {
    if (object instanceof StackAbility) {
      Card card=game.getCard(((StackAbility)object).getSourceId());
      if (card != null) {
        sb.append(card.getName());
      }
 else {
        sb.append(object.getName());
      }
    }
 else {
      if (object instanceof Spell) {
        Spell<?> spell=(Spell<?>)object;
        String castText=spell.getSpellAbility().toString();
        sb.append((castText.startsWith("String_Node_Str") ? castText.substring(5) : castText));
        if (spell.getFromZone() == Zone.GRAVEYARD) {
          sb.append("String_Node_Str");
        }
        sb.append(getOptionalTextSuffix(game,spell));
      }
 else {
        sb.append(object.getName());
      }
    }
  }
 else {
    sb.append("String_Node_Str");
  }
  if (getTargets().size() > 0) {
    sb.append("String_Node_Str");
    for (    Target target : getTargets()) {
      sb.append(target.getTargetedName(game));
    }
  }
  return sb.toString();
}

Fixed version (ground truth):
protected String getMessageText(Game game){
  StringBuilder sb=new StringBuilder();
  MageObject object=game.getObject(this.sourceId);
  if (object == null) {
    object=game.getLastKnownInformation(this.sourceId,Zone.BATTLEFIELD);
  }
  if (object != null) {
    if (object instanceof StackAbility) {
      Card card=game.getCard(((StackAbility)object).getSourceId());
      if (card != null) {
        sb.append(card.getName());
      }
 else {
        sb.append(object.getName());
      }
    }
 else {
      if (object instanceof Spell) {
        Spell<?> spell=(Spell<?>)object;
        String castText=spell.getSpellAbility().toString();
        sb.append((castText.startsWith("String_Node_Str") ? castText.substring(5) : castText));
        if (spell.getFromZone() == Zone.GRAVEYARD) {
          sb.append("String_Node_Str");
        }
        sb.append(getOptionalTextSuffix(game,spell));
      }
 else {
        sb.append(object.getName());
      }
    }
  }
 else {
    sb.append("String_Node_Str");
  }
  if (getTargets().size() > 0) {
    sb.append("String_Node_Str");
    for (    Target target : getTargets()) {
      sb.append(target.getTargetedName(game));
    }
  }
  return sb.toString();
}
Program: 159795
Project: 159795
Buggy source:
private void checkMiracleAbility(GameEvent event,Game game){
  Card card=game.getCard(event.getTargetId());
  if (card != null) {
    for (    Ability ability : card.getAbilities()) {
      if (ability instanceof MiracleAbility) {
        Player controller=game.getPlayer(ability.getControllerId());
        if (controller != null) {
          game.getContinuousEffects().costModification(ability,game);
          ManaCosts<ManaCost> manaCostsToPay=ability.getManaCostsToPay();
          Cards cards=new CardsImpl(Zone.PICK);
          cards.add(card);
          controller.lookAtCards("String_Node_Str",cards,game);
          if (controller.chooseUse(Outcome.Benefit,"String_Node_Str" + manaCostsToPay.getText() + "String_Node_Str",game)) {
            controller.revealCards("String_Node_Str",cards,game);
            ManaCosts costRef=card.getSpellAbility().getManaCostsToPay();
            costRef.clear();
            for (            ManaCost manaCost : manaCostsToPay) {
              costRef.add(manaCost);
            }
            controller.cast(card.getSpellAbility(),game,false);
            break;
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
private void checkMiracleAbility(GameEvent event,Game game){
  Card card=game.getCard(event.getTargetId());
  if (card != null) {
    for (    Ability ability : card.getAbilities()) {
      if (ability instanceof MiracleAbility) {
        Player controller=game.getPlayer(ability.getControllerId());
        if (controller != null) {
          game.getContinuousEffects().costModification(ability,game);
          ManaCosts<ManaCost> manaCostsToPay=ability.getManaCostsToPay();
          Cards cards=new CardsImpl(Zone.PICK);
          cards.add(card);
          controller.lookAtCards("String_Node_Str",cards,game);
          if (controller.chooseUse(Outcome.Benefit,"String_Node_Str" + manaCostsToPay.getText() + "String_Node_Str",game)) {
            controller.revealCards("String_Node_Str",cards,game);
            ManaCosts costRef=card.getSpellAbility().getManaCostsToPay();
            costRef.clear();
            for (            ManaCost manaCost : manaCostsToPay) {
              costRef.add(manaCost);
            }
            controller.cast(card.getSpellAbility(),game,false);
            costRef.clear();
            for (            ManaCost manaCost : card.getSpellAbility().getManaCosts()) {
              costRef.add(manaCost);
            }
            break;
          }
        }
      }
    }
  }
}
Program: 159796
Project: 159796
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
    ZoneChangeEvent zEvent=(ZoneChangeEvent)event;
    if (zEvent.getFromZone() == null && this.echoPaid) {
      this.echoPaid=false;
    }
  }
  if (event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE) {
    if (lastController != null) {
      if (!lastController.equals(this.controllerId)) {
        this.echoPaid=false;
      }
    }
    lastController=this.getControllerId();
  }
  if (event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE && event.getPlayerId().equals(this.controllerId) && lastController.equals(this.controllerId) && !this.echoPaid) {
    this.echoPaid=true;
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
    EntersTheBattlefieldEvent zEvent=(EntersTheBattlefieldEvent)event;
    if (zEvent.getFromZone() == null && this.echoPaid) {
      this.echoPaid=false;
    }
  }
  if (event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE) {
    if (lastController != null) {
      if (!lastController.equals(this.controllerId)) {
        this.echoPaid=false;
      }
    }
    lastController=this.getControllerId();
  }
  if (event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE && event.getPlayerId().equals(this.controllerId) && lastController.equals(this.controllerId) && !this.echoPaid) {
    this.echoPaid=true;
    return true;
  }
  return false;
}
Program: 159797
Project: 159797
Buggy source:
@Override public boolean apply(Game game,Ability source){
  ObjectColor chosenColor=(ObjectColor)game.getState().getValue(source.getSourceId() + "String_Node_Str");
  filter2.add(new ColorPredicate(chosenColor));
  filter2.setMessage(chosenColor.getDescription());
  setAbility(new ProtectionAbility(new FilterCard(filter2)));
  return super.apply(game,source);
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  filter2.add(new ColorPredicate(chosenColor));
  filter2.setMessage(chosenColor.getDescription());
  setAbility(new ProtectionAbility(new FilterCard(filter2)));
  return super.apply(game,source);
}
Program: 159798
Project: 159798
Buggy source:
public GainProtectionFromChosenColorEffect(final GainProtectionFromChosenColorEffect effect){
  super(effect);
  this.filter2=effect.filter2.copy();
}

Fixed version (ground truth):
public GainProtectionFromChosenColorEffect(final GainProtectionFromChosenColorEffect effect){
  super(effect);
  this.filter2=effect.filter2.copy();
  this.chosenColor=effect.chosenColor;
}
Program: 159799
Project: 159799
Buggy source:
public List<Integer> asList(final int[] is){
  List<Integer> list=new ArrayList<Integer>();
  for (  int i : is)   list.add(i);
  return list;
}

Fixed version (ground truth):
public List<Integer> asList(final int[] is){
  List<Integer> list=new ArrayList<Integer>();
  for (  int i : is) {
    list.add(i);
  }
  return list;
}
Program: 159800
Project: 159800
Buggy source:
@Override public void mousePressed(MouseEvent e){
  if (e.getClickCount() == 2 && !e.isConsumed()) {
    e.consume();
    Object obj=e.getSource();
    if (obj instanceof Card) {
      if (e.isShiftDown())       cardEventSource.shiftDoubleClick(((Card)obj).getOriginal(),"String_Node_Str");
 else       cardEventSource.doubleClick(((Card)obj).getOriginal(),"String_Node_Str");
    }
 else     if (obj instanceof MageCard) {
      if (e.isShiftDown())       cardEventSource.shiftDoubleClick(((MageCard)obj).getOriginal(),"String_Node_Str");
 else       cardEventSource.doubleClick(((MageCard)obj).getOriginal(),"String_Node_Str");
    }
  }
}

Fixed version (ground truth):
@Override public void mousePressed(MouseEvent e){
  if (e.getClickCount() == 2 && !e.isConsumed()) {
    e.consume();
    Object obj=e.getSource();
    if (obj instanceof Card) {
      if (e.isShiftDown()) {
        cardEventSource.shiftDoubleClick(((Card)obj).getOriginal(),"String_Node_Str");
      }
 else {
        cardEventSource.doubleClick(((Card)obj).getOriginal(),"String_Node_Str");
      }
    }
 else     if (obj instanceof MageCard) {
      if (e.isShiftDown()) {
        cardEventSource.shiftDoubleClick(((MageCard)obj).getOriginal(),"String_Node_Str");
      }
 else {
        cardEventSource.doubleClick(((MageCard)obj).getOriginal(),"String_Node_Str");
      }
    }
  }
}
Program: 159801
Project: 159801
Buggy source:
private void redrawCards(){
  if (cards == null)   cards=new CardsView();
  currentView.loadCards(cards,null,false,bigCard,gameId);
}

Fixed version (ground truth):
private void redrawCards(){
  if (cards == null) {
    cards=new CardsView();
  }
  currentView.loadCards(cards,null,false,bigCard,gameId);
}
Program: 159802
Project: 159802
Buggy source:
/** 
 * Creates new form Cards 
 */
public CardsList(){
  initComponents();
  makeTransparent();
  initListViewComponents();
  currentView=mainModel;
}

Fixed version (ground truth):
/** 
 * Creates new form Cards 
 */
public CardsList(){
  initComponents();
  makeTransparent();
  initListViewComponents();
}
Program: 159804
Project: 159804
Buggy source:
public void disconnect(){
  if (session != null)   session.leaveChat(chatId);
}

Fixed version (ground truth):
public void disconnect(){
  if (session != null) {
    session.leaveChat(chatId);
  }
}
Program: 159805
Project: 159805
Buggy source:
public void setPlayers(Collection<String> players){
  if (players != null) {
    boolean update=false;
    int size=players.size();
    List<String> list=new ArrayList<String>(players);
    Collections.sort(list);
    if (size != this.players.size()) {
      update=true;
    }
 else {
      update=true;
      for (int i=0; i < size; i++) {
        if (!list.get(i).equals(this.players.get(i))) {
          update=false;
          break;
        }
      }
    }
    if (update && list != null) {
synchronized (tableModel) {
        this.players=list;
        tableModel.loadData(this.players);
      }
    }
  }
 else {
    this.players.clear();
  }
}

Fixed version (ground truth):
public void setPlayers(Collection<String> players){
  if (players != null) {
    boolean update;
    int size=players.size();
    List<String> list=new ArrayList<String>(players);
    Collections.sort(list);
    if (size != this.players.size()) {
      update=true;
    }
 else {
      update=false;
      for (int i=0; i < size; i++) {
        if (!list.get(i).equals(this.players.get(i))) {
          update=true;
          break;
        }
      }
    }
    if (update && list != null) {
synchronized (tableModel) {
        this.players=list;
        tableModel.loadData(this.players);
      }
    }
  }
 else {
    this.players.clear();
  }
}
Program: 159806
Project: 159806
Buggy source:
@Override public String getColumnName(int columnIndex){
  String colName="String_Node_Str";
  if (columnIndex <= getColumnCount())   colName=columnNames[columnIndex];
  return colName;
}

Fixed version (ground truth):
@Override public String getColumnName(int columnIndex){
  String colName="String_Node_Str";
  if (columnIndex <= getColumnCount()) {
    colName=columnNames[columnIndex];
  }
  return colName;
}
Program: 159807
Project: 159807
Buggy source:
/** 
 * Creates new form ChatPanel 
 */
public ChatPanel(boolean addPlayersTab){
  tableModel=new TableModel();
  initComponents();
  jTable1.setBackground(new Color(0,0,0,0));
  jTable1.setForeground(Color.white);
  setBackground(new Color(0,0,0,100));
  if (jScrollPane1 != null) {
    jScrollPane1.setBackground(new Color(0,0,0,100));
    jScrollPane1.getViewport().setBackground(new Color(0,0,0,100));
  }
  if (jScrollPane2 != null) {
    jScrollPane2.setBackground(new Color(0,0,0,100));
    jScrollPane2.getViewport().setBackground(new Color(0,0,0,100));
  }
  if (!addPlayersTab)   simplifyComponents();
}

Fixed version (ground truth):
/** 
 * Creates new form ChatPanel 
 */
public ChatPanel(boolean addPlayersTab){
  tableModel=new TableModel();
  initComponents();
  jTable1.setBackground(new Color(0,0,0,0));
  jTable1.setForeground(Color.white);
  setBackground(new Color(0,0,0,100));
  if (jScrollPane1 != null) {
    jScrollPane1.setBackground(new Color(0,0,0,100));
    jScrollPane1.getViewport().setBackground(new Color(0,0,0,100));
  }
  if (jScrollPane2 != null) {
    jScrollPane2.setBackground(new Color(0,0,0,100));
    jScrollPane2.getViewport().setBackground(new Color(0,0,0,100));
  }
  if (!addPlayersTab) {
    simplifyComponents();
  }
}
Program: 159809
Project: 159809
Buggy source:
@Override public void fireUpdatePlayersEvent(){
  if (simulation) {
    return;
  }
  tableEventSource.fireTableEvent(EventType.UPDATE,null,this);
}

Fixed version (ground truth):
@Override public void fireUpdatePlayersEvent(){
  if (simulation) {
    return;
  }
  logger.trace("String_Node_Str");
  tableEventSource.fireTableEvent(EventType.UPDATE,null,this);
}
Program: 159810
Project: 159810
Buggy source:
@Override public boolean apply(Game game,Ability source,Ability abilityToModify){
  MageObject sourceObject=game.getObject(abilityToModify.getSourceId());
  if (sourceObject != null) {
    int amount=0;
    for (    UUID cardId : game.getState().getPlayer(source.getControllerId()).getGraveyard()) {
      Card card=game.getPermanent(cardId);
      if (card != null && card.getName().equals(sourceObject.getName())) {
        amount++;
      }
    }
    if (amount > 0) {
      SpellAbility spellAbility=(SpellAbility)abilityToModify;
      CardUtil.adjustCost(spellAbility,amount);
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source,Ability abilityToModify){
  MageObject sourceObject=game.getObject(abilityToModify.getSourceId());
  if (sourceObject != null) {
    int amount=0;
    for (    UUID cardId : game.getState().getPlayer(source.getControllerId()).getGraveyard()) {
      Card card=game.getCard(cardId);
      if (card != null && card.getName().equals(sourceObject.getName())) {
        amount++;
      }
    }
    if (amount > 0) {
      SpellAbility spellAbility=(SpellAbility)abilityToModify;
      CardUtil.adjustCost(spellAbility,amount);
    }
    return true;
  }
  return false;
}
Program: 159811
Project: 159811
Buggy source:
@Override public DreadSlaver copy(){
  return new DreadSlaver(this);
}

Fixed version (ground truth):
@Override public DreadSlaverContiniousEffect copy(){
  return new DreadSlaverContiniousEffect(this);
}
Program: 159814
Project: 159814
Buggy source:
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  boolean retValue=false;
  GameEvent preventEvent=new GameEvent(GameEvent.EventType.PREVENT_DAMAGE,source.getFirstTarget(),source.getId(),source.getControllerId(),event.getAmount(),false);
  int damage=event.getAmount();
  if (!game.replaceEvent(preventEvent)) {
    event.setAmount(0);
    game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE,source.getFirstTarget(),source.getId(),source.getControllerId(),damage));
    retValue=true;
  }
  Permanent permanent=game.getPermanent(source.getSourceId());
  if (permanent != null) {
    permanent.removeCounters(CounterType.P1P1.createInstance(damage),game);
  }
  return retValue;
}

Fixed version (ground truth):
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  boolean retValue=false;
  GameEvent preventEvent=new GameEvent(GameEvent.EventType.PREVENT_DAMAGE,source.getFirstTarget(),source.getId(),source.getControllerId(),event.getAmount(),false);
  int damage=event.getAmount();
  if (!game.replaceEvent(preventEvent)) {
    event.setAmount(0);
    game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE,source.getFirstTarget(),source.getId(),source.getControllerId(),damage));
    retValue=true;
  }
  Permanent permanent=game.getPermanent(source.getSourceId());
  if (permanent != null) {
    permanent.removeCounters(CounterType.P1P1.createInstance(),game);
  }
  return retValue;
}
Program: 159816
Project: 159816
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getControllerId());
  if (player != null) {
    Cost cost=new ManaCostsImpl("String_Node_Str");
    if (player.chooseUse(outcome,"String_Node_Str" + cost.getText() + "String_Node_Str"+ staticText,game)) {
      cost.clearPaid();
      if (cost.pay(source,game,source.getId(),source.getControllerId(),false)) {
        UUID targetId=targetPointer.getFirst(game,source);
        if (targetId != null) {
          MageObject target=game.getLastKnownInformation(targetId,Constants.Zone.BATTLEFIELD);
          if (target != null && target instanceof Permanent) {
            EmptyToken token=new EmptyToken();
            CardUtil.copyTo(token).from((Permanent)target);
            token.putOntoBattlefield(1,game,source.getSourceId(),source.getControllerId());
            return true;
          }
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getControllerId());
  UUID targetId=targetPointer.getFirst(game,source);
  if (targetId != null && player != null) {
    MageObject target=game.getPermanent(targetId);
    if (target == null) {
      target=game.getLastKnownInformation(targetId,Zone.BATTLEFIELD);
    }
    if (target != null) {
      Cost cost=new ManaCostsImpl("String_Node_Str");
      if (player.chooseUse(outcome,new StringBuilder("String_Node_Str").append(cost.getText()).append("String_Node_Str").append(target.getName()).append("String_Node_Str").toString(),game)) {
        cost.clearPaid();
        if (cost.pay(source,game,source.getId(),source.getControllerId(),false)) {
          if (target instanceof Permanent) {
            EmptyToken token=new EmptyToken();
            CardUtil.copyTo(token).from((Permanent)target);
            token.putOntoBattlefield(1,game,source.getSourceId(),source.getControllerId());
            return true;
          }
        }
      }
    }
  }
  return false;
}
Program: 159817
Project: 159817
Buggy source:
@Override public boolean applies(Ability abilityToModify,Ability source,Game game){
  if (abilityToModify instanceof SpellAbility) {
    Card sourceCard=game.getCard(((SpellAbility)abilityToModify).getSourceId());
    if (sourceCard != null && (sourceCard.getCardType().contains(CardType.INSTANT) || sourceCard.getCardType().contains(CardType.SORCERY))) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(Ability abilityToModify,Ability source,Game game){
  if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility || abilityToModify instanceof RetraceAbility) {
    Card sourceCard=game.getCard(((SpellAbility)abilityToModify).getSourceId());
    if (sourceCard != null && (sourceCard.getCardType().contains(CardType.INSTANT) || sourceCard.getCardType().contains(CardType.SORCERY))) {
      return true;
    }
  }
  return false;
}
Program: 159818
Project: 159818
Buggy source:
@Override public boolean applies(Ability abilityToModify,Ability source,Game game){
  if (abilityToModify instanceof SpellAbility) {
    Card sourceCard=game.getCard(((SpellAbility)abilityToModify).getSourceId());
    if (sourceCard != null && abilityToModify.getControllerId().equals(source.getControllerId()) && (sourceCard.hasSubtype("String_Node_Str") || sourceCard.hasSubtype("String_Node_Str"))) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(Ability abilityToModify,Ability source,Game game){
  if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility || abilityToModify instanceof RetraceAbility) {
    Card sourceCard=game.getCard(abilityToModify.getSourceId());
    if (sourceCard != null && abilityToModify.getControllerId().equals(source.getControllerId()) && (sourceCard.hasSubtype("String_Node_Str") || sourceCard.hasSubtype("String_Node_Str"))) {
      return true;
    }
  }
  return false;
}
Program: 159819
Project: 159819
Buggy source:
@Override public boolean applies(Ability abilityToModify,Ability source,Game game){
  if (abilityToModify instanceof SpellAbility) {
    SpellAbility spell=(SpellAbility)abilityToModify;
    if (spell.getControllerId().equals(source.getControllerId())) {
      Card sourceCard=game.getCard(spell.getSourceId());
      if (sourceCard != null && sourceCard.hasSubtype("String_Node_Str")) {
        String manaCostsString="String_Node_Str" + sourceCard.getManaCost().convertedManaCost() + "String_Node_Str";
        Player player=game.getPlayer(spell.getControllerId());
        if (player != null && player.chooseUse(Constants.Outcome.Benefit,"String_Node_Str",game)) {
          spell.getManaCostsToPay().clear();
          spell.getManaCostsToPay().load(manaCostsString);
          return true;
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(Ability abilityToModify,Ability source,Game game){
  if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility || abilityToModify instanceof RetraceAbility) {
    Ability spell=abilityToModify;
    if (spell.getControllerId().equals(source.getControllerId())) {
      Card sourceCard=game.getCard(spell.getSourceId());
      if (sourceCard != null && sourceCard.hasSubtype("String_Node_Str")) {
        String manaCostsString="String_Node_Str" + sourceCard.getManaCost().convertedManaCost() + "String_Node_Str";
        Player player=game.getPlayer(spell.getControllerId());
        if (player != null && player.chooseUse(Constants.Outcome.Benefit,"String_Node_Str",game)) {
          spell.getManaCostsToPay().clear();
          spell.getManaCostsToPay().load(manaCostsString);
          return true;
        }
      }
    }
  }
  return false;
}
Program: 159820
Project: 159820
Buggy source:
@Override public boolean applies(Ability abilityToModify,Ability source,Game game){
  if (abilityToModify instanceof SpellAbility) {
    Card card=game.getCard(abilityToModify.getSourceId());
    if (card != null && !card.getCardType().contains(CardType.CREATURE)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(Ability abilityToModify,Ability source,Game game){
  if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility || abilityToModify instanceof RetraceAbility) {
    Card card=game.getCard(abilityToModify.getSourceId());
    if (card != null && !card.getCardType().contains(CardType.CREATURE)) {
      return true;
    }
  }
  return false;
}
Program: 159821
Project: 159821
Buggy source:
@Override public boolean apply(Game game,Ability source,Ability abilityToModify){
  SpellAbility spellAbility=(SpellAbility)abilityToModify;
  spellAbility.getManaCostsToPay().add(new GenericManaCost(1));
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source,Ability abilityToModify){
  CardUtil.increaseCost(abilityToModify,1);
  return true;
}
Program: 159822
Project: 159822
Buggy source:
@Override public boolean applies(Ability abilityToModify,Ability source,Game game){
  if (abilityToModify instanceof SpellAbility) {
    SpellAbility spell=(SpellAbility)abilityToModify;
    if (spell.getControllerId().equals(source.getControllerId())) {
      Card sourceCard=game.getCard(spell.getSourceId());
      if (sourceCard != null && sourceCard.hasSubtype("String_Node_Str")) {
        Player player=game.getPlayer(spell.getControllerId());
        if (player != null && player.chooseUse(Outcome.Benefit,"String_Node_Str",game)) {
          spell.getManaCostsToPay().clear();
          spell.getManaCostsToPay().addAll(new ManaCostsImpl("String_Node_Str"));
          return true;
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(Ability abilityToModify,Ability source,Game game){
  if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility || abilityToModify instanceof RetraceAbility) {
    Ability spell=abilityToModify;
    if (spell.getControllerId().equals(source.getControllerId())) {
      Card sourceCard=game.getCard(spell.getSourceId());
      if (sourceCard != null && sourceCard.hasSubtype("String_Node_Str")) {
        Player player=game.getPlayer(spell.getControllerId());
        if (player != null && player.chooseUse(Outcome.Benefit,"String_Node_Str",game)) {
          spell.getManaCostsToPay().clear();
          spell.getManaCostsToPay().addAll(new ManaCostsImpl("String_Node_Str"));
          return true;
        }
      }
    }
  }
  return false;
}
Program: 159823
Project: 159823
Buggy source:
@Override public boolean applies(Ability abilityToModify,Ability source,Game game){
  if (abilityToModify instanceof SpellAbility) {
    Card sourceCard=game.getCard(abilityToModify.getSourceId());
    StackObject stackObject=game.getStack().getStackObject(abilityToModify.getSourceId());
    if (stackObject != null && stackObject instanceof Spell) {
      Zone zone=((Spell)stackObject).getFromZone();
      if (zone != null && zone.equals(Zone.HAND)) {
        if (sourceCard != null && sourceCard.getOwnerId().equals(source.getControllerId()) && !sourceCard.getCardType().contains(CardType.LAND)) {
          Player player=game.getPlayer(source.getControllerId());
          String message="String_Node_Str" + sourceCard.getName() + "String_Node_Str";
          if (player != null && player.chooseUse(outcome,message,game)) {
            return true;
          }
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(Ability abilityToModify,Ability source,Game game){
  if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility || abilityToModify instanceof RetraceAbility) {
    Card sourceCard=game.getCard(abilityToModify.getSourceId());
    StackObject stackObject=game.getStack().getStackObject(abilityToModify.getSourceId());
    if (stackObject != null && stackObject instanceof Spell) {
      Zone zone=((Spell)stackObject).getFromZone();
      if (zone != null && zone.equals(Zone.HAND)) {
        if (sourceCard != null && sourceCard.getOwnerId().equals(source.getControllerId()) && !sourceCard.getCardType().contains(CardType.LAND)) {
          Player player=game.getPlayer(source.getControllerId());
          String message="String_Node_Str" + sourceCard.getName() + "String_Node_Str";
          if (player != null && player.chooseUse(outcome,message,game)) {
            return true;
          }
        }
      }
    }
  }
  return false;
}
Program: 159824
Project: 159824
Buggy source:
@Override public boolean applies(Ability abilityToModify,Ability source,Game game){
  if (abilityToModify instanceof SpellAbility) {
    if (!abilityToModify.getControllerId().equals(game.getActivePlayerId())) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(Ability abilityToModify,Ability source,Game game){
  if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility || abilityToModify instanceof RetraceAbility) {
    if (!abilityToModify.getControllerId().equals(game.getActivePlayerId())) {
      return true;
    }
  }
  return false;
}
Program: 159825
Project: 159825
Buggy source:
@Override public boolean applies(Ability abilityToModify,Ability source,Game game){
  if (abilityToModify instanceof SpellAbility && abilityToModify.getSourceId().equals(source.getSourceId())) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(Ability abilityToModify,Ability source,Game game){
  if ((abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility || abilityToModify instanceof RetraceAbility) && abilityToModify.getSourceId().equals(source.getSourceId())) {
    return true;
  }
  return false;
}
Program: 159826
Project: 159826
Buggy source:
@Override public boolean applies(Ability abilityToModify,Ability source,Game game){
  if (abilityToModify instanceof SpellAbility) {
    Card sourceCard=game.getCard(((SpellAbility)abilityToModify).getSourceId());
    if (sourceCard != null && abilityToModify.getControllerId().equals(source.getControllerId()) && (sourceCard.getCardType().contains(CardType.CREATURE))) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(Ability abilityToModify,Ability source,Game game){
  if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility || abilityToModify instanceof RetraceAbility) {
    Card sourceCard=game.getCard(abilityToModify.getSourceId());
    if (sourceCard != null && abilityToModify.getControllerId().equals(source.getControllerId()) && (sourceCard.getCardType().contains(CardType.CREATURE))) {
      return true;
    }
  }
  return false;
}
Program: 159827
Project: 159827
Buggy source:
@Override public boolean apply(Game game,Ability source,Ability abilityToModify){
  SpellAbility spellAbility=(SpellAbility)abilityToModify;
  if (spellAbility != null) {
    OpponentsLostLifeCount dynamicValue=new OpponentsLostLifeCount();
    int amount=dynamicValue.calculate(game,source);
    if (amount > 0) {
      CardUtil.adjustCost(spellAbility,amount);
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source,Ability abilityToModify){
  Ability spellAbility=(SpellAbility)abilityToModify;
  if (spellAbility != null) {
    OpponentsLostLifeCount dynamicValue=new OpponentsLostLifeCount();
    int amount=dynamicValue.calculate(game,source);
    if (amount > 0) {
      CardUtil.reduceCost(spellAbility,amount);
      return true;
    }
  }
  return false;
}
Program: 159828
Project: 159828
Buggy source:
@Override public boolean applies(Ability abilityToModify,Ability source,Game game){
  if (abilityToModify instanceof SpellAbility) {
    Card sourceCard=game.getCard(((SpellAbility)abilityToModify).getSourceId());
    if (sourceCard != null && sourceCard.getOwnerId().equals(source.getControllerId())) {
      Permanent permanent=game.getPermanent(source.getSourceId());
      if (permanent != null) {
        List<UUID> imprinted=permanent.getImprinted();
        if (imprinted.size() > 0) {
          Card imprintedCard=game.getCard(imprinted.get(0));
          if (imprintedCard != null && CardUtil.shareTypes(imprintedCard,sourceCard)) {
            return true;
          }
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(Ability abilityToModify,Ability source,Game game){
  if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility || abilityToModify instanceof RetraceAbility) {
    Card sourceCard=game.getCard(abilityToModify.getSourceId());
    if (sourceCard != null && sourceCard.getOwnerId().equals(source.getControllerId())) {
      Permanent permanent=game.getPermanent(source.getSourceId());
      if (permanent != null) {
        List<UUID> imprinted=permanent.getImprinted();
        if (imprinted.size() > 0) {
          Card imprintedCard=game.getCard(imprinted.get(0));
          if (imprintedCard != null && CardUtil.shareTypes(imprintedCard,sourceCard)) {
            return true;
          }
        }
      }
    }
  }
  return false;
}
Program: 159829
Project: 159829
Buggy source:
@Override public boolean applies(Ability abilityToModify,Ability source,Game game){
  if (abilityToModify instanceof SpellAbility) {
    Card card=game.getCard(abilityToModify.getSourceId());
    if (card != null && !card.getCardType().contains(CardType.ARTIFACT)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(Ability abilityToModify,Ability source,Game game){
  if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility || abilityToModify instanceof RetraceAbility) {
    Card card=game.getCard(abilityToModify.getSourceId());
    if (card != null && !card.getCardType().contains(CardType.ARTIFACT)) {
      return true;
    }
  }
  return false;
}
Program: 159830
Project: 159830
Buggy source:
public void loadCards(String name,CardsView pile1,CardsView pile2,BigCard bigCard,CardDimensions dimension,UUID gameId){
  this.title=name;
  this.pile1.loadCardsNarrow(pile1,bigCard,dimension,gameId,null);
  this.pile2.loadCardsNarrow(pile2,bigCard,dimension,gameId,null);
  if (getParent() != MageFrame.getDesktop()) {
    MageFrame.getDesktop().add(this,JLayeredPane.POPUP_LAYER);
  }
  pack();
  Point centered=SettingsManager.getInstance().getComponentPosition(getWidth(),getHeight());
  this.setLocation(centered.x,centered.y);
  GuiDisplayUtil.keepComponentInsideScreen(centered.x,centered.y,this);
  this.revalidate();
  this.repaint();
  this.setModal(true);
  this.setVisible(true);
}

Fixed version (ground truth):
public void loadCards(String name,CardsView pile1,CardsView pile2,BigCard bigCard,CardDimensions dimension,UUID gameId){
  this.title=name;
  this.pile1.loadCardsNarrow(pile1,bigCard,dimension,gameId,null);
  this.pile2.loadCardsNarrow(pile2,bigCard,dimension,gameId,null);
  if (getParent() != MageFrame.getDesktop()) {
    MageFrame.getDesktop().add(this,JLayeredPane.MODAL_LAYER);
  }
  pack();
  Point centered=SettingsManager.getInstance().getComponentPosition(getWidth(),getHeight());
  this.setLocation(centered.x,centered.y);
  GuiDisplayUtil.keepComponentInsideScreen(centered.x,centered.y,this);
  this.revalidate();
  this.repaint();
  this.setModal(true);
  this.setVisible(true);
}
Program: 159831
Project: 159831
Buggy source:
public GamePanel(){
  initComponents();
  combat=new CombatDialog();
  pickNumber=new PickNumberDialog();
  MageFrame.getDesktop().add(combat,JLayeredPane.POPUP_LAYER);
  combat.hideDialog();
  MageFrame.getDesktop().add(pickNumber,JLayeredPane.POPUP_LAYER);
  this.feedbackPanel.setConnectedChatPanel(this.userChatPanel);
  this.setLayout(new BorderLayout());
  final JLayeredPane j=new JLayeredPane();
  j.setSize(1024,768);
  this.add(j);
  j.add(jSplitPane0,JLayeredPane.DEFAULT_LAYER);
  Map<String,JComponent> myUi=getUIComponents(j);
  Plugins.getInstance().updateGamePanel(myUi);
  addComponentListener(new ComponentAdapter(){
    @Override public void componentResized(    ComponentEvent e){
      int width=((JComponent)e.getSource()).getWidth();
      int height=((JComponent)e.getSource()).getHeight();
      j.setSize(width,height);
      jSplitPane0.setSize(width,height);
      if (height < storedHeight) {
        pnlBattlefield.setSize(0,200);
      }
      storedHeight=height;
      sizeToScreen();
      if (!initialized) {
        String state=PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BIG_CARD_TOGGLED,null);
        if (state != null && state.equals("String_Node_Str")) {
          jSplitPane0.setDividerLocation(1.0);
        }
        initialized=true;
      }
    }
  }
);
}

Fixed version (ground truth):
public GamePanel(){
  initComponents();
  combat=new CombatDialog();
  pickNumber=new PickNumberDialog();
  MageFrame.getDesktop().add(combat,JLayeredPane.MODAL_LAYER);
  combat.hideDialog();
  MageFrame.getDesktop().add(pickNumber,JLayeredPane.MODAL_LAYER);
  this.feedbackPanel.setConnectedChatPanel(this.userChatPanel);
  this.setLayout(new BorderLayout());
  final JLayeredPane j=new JLayeredPane();
  j.setSize(1024,768);
  this.add(j);
  j.add(jSplitPane0,JLayeredPane.DEFAULT_LAYER);
  Map<String,JComponent> myUi=getUIComponents(j);
  Plugins.getInstance().updateGamePanel(myUi);
  addComponentListener(new ComponentAdapter(){
    @Override public void componentResized(    ComponentEvent e){
      int width=((JComponent)e.getSource()).getWidth();
      int height=((JComponent)e.getSource()).getHeight();
      j.setSize(width,height);
      jSplitPane0.setSize(width,height);
      if (height < storedHeight) {
        pnlBattlefield.setSize(0,200);
      }
      storedHeight=height;
      sizeToScreen();
      if (!initialized) {
        String state=PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BIG_CARD_TOGGLED,null);
        if (state != null && state.equals("String_Node_Str")) {
          jSplitPane0.setDividerLocation(1.0);
        }
        initialized=true;
      }
    }
  }
);
}
Program: 159832
Project: 159832
Buggy source:
@Override public boolean applies(GameEvent event,Ability source,Game game){
  if (event.getType() == GameEvent.EventType.CAST_SPELL) {
    Permanent enchantment=game.getPermanent(source.getSourceId());
    if (enchantment != null && enchantment.getAttachedTo() != null) {
      Player player=game.getPlayer(enchantment.getAttachedTo());
      if (player != null && event.getPlayerId().equals(player.getId())) {
        Watcher watcher=game.getState().getWatchers().get("String_Node_Str",source.getControllerId());
        if (watcher != null && watcher.conditionMet())         return true;
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(GameEvent event,Ability source,Game game){
  if (event.getType() == GameEvent.EventType.CAST_SPELL) {
    Permanent enchantment=game.getPermanent(source.getSourceId());
    if (enchantment != null && enchantment.getAttachedTo() != null) {
      Player player=game.getPlayer(enchantment.getAttachedTo());
      if (player != null && event.getPlayerId().equals(player.getId())) {
        Watcher watcher=game.getState().getWatchers().get("String_Node_Str",player.getId());
        if (watcher != null && watcher.conditionMet()) {
          return true;
        }
      }
    }
  }
  return false;
}
Program: 159833
Project: 159833
Buggy source:
@Override public void watch(GameEvent event,Game game){
  if (condition == true)   return;
  if (event.getType() == GameEvent.EventType.SPELL_CAST) {
    Permanent enchantment=game.getPermanent(this.sourceId);
    if (enchantment != null && enchantment.getAttachedTo() != null) {
      Player player=game.getPlayer(enchantment.getAttachedTo());
      if (player != null && event.getPlayerId().equals(player.getId())) {
        condition=true;
      }
    }
  }
}

Fixed version (ground truth):
@Override public void watch(GameEvent event,Game game){
  if (condition == true) {
    return;
  }
  if (event.getType() == GameEvent.EventType.SPELL_CAST) {
    Permanent enchantment=game.getPermanent(this.sourceId);
    if (enchantment != null && enchantment.getAttachedTo() != null) {
      Player player=game.getPlayer(enchantment.getAttachedTo());
      if (player != null && event.getPlayerId().equals(player.getId())) {
        condition=true;
      }
    }
  }
}
Program: 159835
Project: 159835
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Permanent enchantment=game.getPermanent(source.getSourceId());
  if (enchantment != null && enchantment.getAttachedTo() != null) {
    Permanent creature=game.getPermanent(enchantment.getAttachedTo());
    if (creature != null) {
      creature.addCounters(new PlusOneCounter(amount),game);
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Permanent enchantment=game.getPermanent(source.getSourceId());
  if (enchantment == null) {
    enchantment=(Permanent)game.getLastKnownInformation(source.getSourceId(),Zone.BATTLEFIELD);
  }
  if (enchantment != null && enchantment.getAttachedTo() != null) {
    Permanent creature=game.getPermanent(enchantment.getAttachedTo());
    if (creature != null) {
      creature.addCounters(new PlusOneCounter(amount),game);
    }
  }
  return true;
}
Program: 159836
Project: 159836
Buggy source:
private void setText(){
  if (amount > 1)   staticText="String_Node_Str" + Integer.toString(amount) + "String_Node_Str";
 else   staticText="String_Node_Str";
}

Fixed version (ground truth):
private void setText(){
  if (amount > 1) {
    staticText="String_Node_Str" + Integer.toString(amount) + "String_Node_Str";
  }
 else {
    staticText="String_Node_Str";
  }
}
Program: 159837
Project: 159837
Buggy source:
protected void checkAttackRestrictions(Player player,Game game){
  int count=0;
  for (  CombatGroup group : groups) {
    count+=group.getAttackers().size();
  }
  if (count == 1) {
    for (    CombatGroup group : groups) {
      List<UUID> tobeRemoved=new ArrayList<UUID>();
      for (      UUID attackingCreatureId : group.getAttackers()) {
        Permanent attacker=game.getPermanent(attackingCreatureId);
        if (attacker != null && attacker.getAbilities().containsKey(CantAttackAloneAbility.getInstance().getId())) {
          game.informPlayers(attacker.getName() + "String_Node_Str");
          tobeRemoved.add(attackingCreatureId);
        }
      }
      for (      UUID attackingCreatureId : tobeRemoved) {
        group.remove(attackingCreatureId);
      }
    }
  }
}

Fixed version (ground truth):
protected void checkAttackRestrictions(Player player,Game game){
  int count=0;
  for (  CombatGroup group : groups) {
    count+=group.getAttackers().size();
  }
  if (count == 1) {
    List<UUID> tobeRemoved=new ArrayList<UUID>();
    for (    CombatGroup group : groups) {
      for (      UUID attackingCreatureId : group.getAttackers()) {
        Permanent attacker=game.getPermanent(attackingCreatureId);
        if (attacker != null && attacker.getAbilities().containsKey(CantAttackAloneAbility.getInstance().getId())) {
          game.informPlayers(attacker.getName() + "String_Node_Str");
          tobeRemoved.add(attackingCreatureId);
        }
      }
    }
    for (    UUID attackingCreatureId : tobeRemoved) {
      this.removeAttacker(attackingCreatureId,game);
    }
  }
}
Program: 159838
Project: 159838
Buggy source:
public void checkBlockRestrictions(Game game,int blockersCount){
  if (attackers.isEmpty()) {
    return;
  }
  if (blockersCount == 1) {
    List<UUID> toBeRemoved=new ArrayList<UUID>();
    for (    UUID blockerId : getBlockers()) {
      Permanent blocker=game.getPermanent(blockerId);
      if (blocker != null && blocker.getAbilities().containsKey(CantBlockAloneAbility.getInstance().getId())) {
        game.informPlayers(blocker.getName() + "String_Node_Str");
        toBeRemoved.add(blockerId);
      }
    }
    for (    UUID blockerId : toBeRemoved) {
      remove(blockerId);
      Permanent creature=game.getPermanent(blockerId);
      if (creature != null) {
        creature.setBlocking(creature.getBlocking() - 1);
      }
    }
    if (blockers.isEmpty()) {
      this.blocked=false;
    }
  }
  for (  UUID uuid : attackers) {
    Permanent attacker=game.getPermanent(uuid);
    if (attacker != null && this.blocked && attacker.getMinBlockedBy() > 1 && blockers.size() > 0 && blockers.size() < attacker.getMinBlockedBy()) {
      for (      UUID blockerId : blockers) {
        Permanent blocker=game.getPermanent(blockerId);
        if (blocker != null) {
          blocker.setBlocking(blocker.getBlocking() - 1);
        }
      }
      blockers.clear();
      blockerOrder.clear();
      this.blocked=false;
      game.informPlayers(attacker.getName() + "String_Node_Str" + attacker.getMinBlockedBy()+ "String_Node_Str");
      return;
    }
  }
}

Fixed version (ground truth):
public void checkBlockRestrictions(Game game,int blockersCount){
  if (attackers.isEmpty()) {
    return;
  }
  if (blockersCount == 1) {
    List<UUID> toBeRemoved=new ArrayList<UUID>();
    for (    UUID blockerId : getBlockers()) {
      Permanent blocker=game.getPermanent(blockerId);
      if (blocker != null && blocker.getAbilities().containsKey(CantBlockAloneAbility.getInstance().getId())) {
        game.informPlayers(blocker.getName() + "String_Node_Str");
        toBeRemoved.add(blockerId);
      }
    }
    for (    UUID blockerId : toBeRemoved) {
      game.getCombat().removeBlocker(blockerId,game);
    }
    if (blockers.isEmpty()) {
      this.blocked=false;
    }
  }
  for (  UUID uuid : attackers) {
    Permanent attacker=game.getPermanent(uuid);
    if (attacker != null && this.blocked && attacker.getMinBlockedBy() > 1 && blockers.size() > 0 && blockers.size() < attacker.getMinBlockedBy()) {
      for (      UUID blockerId : blockers) {
        Permanent blocker=game.getPermanent(blockerId);
        if (blocker != null) {
          blocker.setBlocking(blocker.getBlocking() - 1);
        }
      }
      blockers.clear();
      blockerOrder.clear();
      this.blocked=false;
      game.informPlayers(attacker.getName() + "String_Node_Str" + attacker.getMinBlockedBy()+ "String_Node_Str");
      return;
    }
  }
}
Program: 159839
Project: 159839
Buggy source:
@Override public void checkControlChanged(Game game){
  if (this.controllerChanged) {
    game.fireEvent(new GameEvent(EventType.LOST_CONTROL,objectId,objectId,beforeResetControllerId));
    game.fireEvent(new GameEvent(EventType.GAINED_CONTROL,objectId,objectId,controllerId));
  }
}

Fixed version (ground truth):
@Override public void checkControlChanged(Game game){
  if (this.controllerChanged) {
    game.fireEvent(new GameEvent(EventType.LOST_CONTROL,objectId,objectId,beforeResetControllerId));
    if (controllerId.equals(originalControllerId)) {
      this.abilities.setControllerId(controllerId);
      game.getContinuousEffects().setController(this.objectId,controllerId);
    }
    game.fireEvent(new GameEvent(EventType.GAINED_CONTROL,objectId,objectId,controllerId));
  }
}