nus-yam/ex-repair huggingface dataset:
Program: 160002
Project: 160002
Buggy source:
@Override public void mouseExited(MouseEvent e,final TransferData data){
  hidePopup();
  startHideTimeout();
  this.state=false;
  ArrowBuilder.removeArrowsByType(ArrowBuilder.Type.TARGET);
  ArrowBuilder.removeArrowsByType(ArrowBuilder.Type.PAIRED);
  ArrowBuilder.removeArrowsByType(ArrowBuilder.Type.SOURCE);
}

Fixed version (ground truth):
@Override public void mouseExited(MouseEvent e,final TransferData data){
  hideAll();
}
Program: 160003
Project: 160003
Buggy source:
/** 
 * Creates new form GamePanel 
 */
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);
  try {
    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);
        sizeToScreen();
        if (!initialized) {
          String state=PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BIG_CARD_TOGGLED,null);
          if (state != null) {
            if (state.equals("String_Node_Str")) {
              jSplitPane0.setDividerLocation(1.0);
            }
          }
          initialized=true;
        }
      }
    }
);
  }
 catch (  Exception e) {
    e.printStackTrace();
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
/** 
 * Creates new form GamePanel 
 */
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);
  try {
    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) {
            if (state.equals("String_Node_Str")) {
              jSplitPane0.setDividerLocation(1.0);
            }
          }
          initialized=true;
        }
      }
    }
);
  }
 catch (  Exception e) {
    e.printStackTrace();
    throw new RuntimeException(e);
  }
}
Program: 160004
Project: 160004
Buggy source:
@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);
  sizeToScreen();
  if (!initialized) {
    String state=PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BIG_CARD_TOGGLED,null);
    if (state != null) {
      if (state.equals("String_Node_Str")) {
        jSplitPane0.setDividerLocation(1.0);
      }
    }
    initialized=true;
  }
}

Fixed version (ground truth):
@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) {
      if (state.equals("String_Node_Str")) {
        jSplitPane0.setDividerLocation(1.0);
      }
    }
    initialized=true;
  }
}
Program: 160005
Project: 160005
Buggy source:
private void sizeToScreen(){
  Rectangle rect=this.getBounds();
  if (rect.height < 650) {
    if (smallMode == false) {
      smallMode=true;
      Dimension bbDimension=new Dimension(128,184);
      bigCard.setMaximumSize(bbDimension);
      bigCard.setMinimumSize(bbDimension);
      bigCard.setPreferredSize(bbDimension);
      pnlGameInfo.revalidate();
      pnlGameInfo.repaint();
      this.handContainer.sizeHand(0.8,smallMode);
      for (      PlayAreaPanel p : players.values()) {
        p.sizePlayer(smallMode);
      }
    }
  }
 else {
    if (smallMode == true) {
      smallMode=false;
      Dimension bbDimension=new Dimension(256,367);
      bigCard.setMaximumSize(bbDimension);
      bigCard.setMinimumSize(bbDimension);
      bigCard.setPreferredSize(bbDimension);
      pnlGameInfo.revalidate();
      pnlGameInfo.repaint();
      this.handContainer.sizeHand(1,smallMode);
      for (      PlayAreaPanel p : players.values()) {
        p.sizePlayer(smallMode);
      }
    }
  }
  int height=pnlBattlefield.getHeight();
  phasesContainer.setPreferredSize(new Dimension(X_PHASE_WIDTH,height));
  DialogManager.getManager(gameId).setScreenWidth(rect.width);
  DialogManager.getManager(gameId).setScreenHeight(rect.height);
  DialogManager.getManager(gameId).setBounds(0,0,rect.width,rect.height);
}

Fixed version (ground truth):
private void sizeToScreen(){
  Rectangle rect=this.getBounds();
  if (rect.height < 720) {
    if (!smallMode) {
      smallMode=true;
      Dimension bbDimension=new Dimension(128,184);
      bigCard.setMaximumSize(bbDimension);
      bigCard.setMinimumSize(bbDimension);
      bigCard.setPreferredSize(bbDimension);
      pnlGameInfo.revalidate();
      pnlGameInfo.repaint();
      this.handContainer.sizeHand(0.8,smallMode);
      for (      PlayAreaPanel p : players.values()) {
        p.sizePlayer(smallMode);
      }
    }
  }
 else {
    if (smallMode) {
      smallMode=false;
      Dimension bbDimension=new Dimension(256,367);
      bigCard.setMaximumSize(bbDimension);
      bigCard.setMinimumSize(bbDimension);
      bigCard.setPreferredSize(bbDimension);
      pnlGameInfo.revalidate();
      pnlGameInfo.repaint();
      this.handContainer.sizeHand(1,smallMode);
      for (      PlayAreaPanel p : players.values()) {
        p.sizePlayer(smallMode);
      }
    }
  }
  DialogManager.getManager(gameId).setScreenWidth(rect.width);
  DialogManager.getManager(gameId).setScreenHeight(rect.height);
  DialogManager.getManager(gameId).setBounds(0,0,rect.width,rect.height);
}
Program: 160006
Project: 160006
Buggy source:
/** 
 * Checks if there are enough   {@link Permanent} that can be selected.  Should not be usedfor Ability targets since this does not check for protection, shroud etc.
 * @param sourceControllerId - controller of the select event
 * @param game
 * @return - true if enough valid {@link Permanent} exist
 */
@Override public boolean canChoose(UUID sourceControllerId,Game game){
  int remainingTargets=this.minNumberOfTargets - targets.size();
  if (remainingTargets == 0) {
    return true;
  }
  int count=0;
  for (  Permanent permanent : game.getBattlefield().getActivePermanents(filter,sourceControllerId,game)) {
    if (!targets.containsKey(permanent.getId())) {
      count++;
      if (count >= remainingTargets)       return true;
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Checks if there are enough   {@link Permanent} that can be selected.  Should not be usedfor Ability targets since this does not check for protection, shroud etc.
 * @param sourceControllerId - controller of the select event
 * @param game
 * @return - true if enough valid {@link Permanent} exist
 */
@Override public boolean canChoose(UUID sourceControllerId,Game game){
  int remainingTargets=this.minNumberOfTargets - targets.size();
  if (remainingTargets == 0) {
    return true;
  }
  int count=0;
  for (  Permanent permanent : game.getBattlefield().getActivePermanents(filter,sourceControllerId,game)) {
    if (!targets.containsKey(permanent.getId())) {
      count++;
      if (count >= remainingTargets) {
        return true;
      }
    }
  }
  return false;
}
Program: 160008
Project: 160008
Buggy source:
@Override public MarkOfTheOniTriggeredAbility copy(){
  return new MarkOfTheOniTriggeredAbility(this);
}

Fixed version (ground truth):
@Override public MarkOfTheOni copy(){
  return new MarkOfTheOni(this);
}
Program: 160009
Project: 160009
Buggy source:
@Override public boolean apply(Game game,Ability source){
  for (  Permanent creature : game.getBattlefield().getAllActivePermanents(filter,game)) {
    AttacksIfAbleTargetEffect effect=new AttacksIfAbleTargetEffect(Duration.EndOfTurn);
    effect.setTargetPointer(new FixedTarget(creature.getId()));
    game.addEffect(effect,source);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  for (  Permanent creature : game.getBattlefield().getActivePermanents(filter,source.getControllerId(),source.getSourceId(),game)) {
    AttacksIfAbleTargetEffect effect=new AttacksIfAbleTargetEffect(Duration.EndOfTurn);
    effect.setTargetPointer(new FixedTarget(creature.getId()));
    game.addEffect(effect,source);
  }
  return true;
}
Program: 160010
Project: 160010
Buggy source:
@Override public boolean applies(Permanent permanent,Ability source,Game game){
  Permanent creature=game.getPermanent(source.getFirstTarget());
  if (creature != null && creature.getId().equals(permanent.getId())) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(Permanent permanent,Ability source,Game game){
  if (this.getTargetPointer().getTargets(game,source).contains(permanent.getId())) {
    return true;
  }
  return false;
}
Program: 160011
Project: 160011
Buggy source:
@Override public String getText(Mode mode){
  if (this.duration == Duration.EndOfTurn)   return "String_Node_Str" + mode.getTargets().get(0).getTargetName() + "String_Node_Str";
 else   return "String_Node_Str" + mode.getTargets().get(0).getTargetName() + "String_Node_Str";
}

Fixed version (ground truth):
@Override public String getText(Mode mode){
  if (this.duration == Duration.EndOfTurn) {
    return new StringBuilder("String_Node_Str").append(mode.getTargets().get(0).getTargetName()).append("String_Node_Str").toString();
  }
 else {
    return new StringBuilder("String_Node_Str").append(mode.getTargets().get(0).getTargetName()).append("String_Node_Str").toString();
  }
}
Program: 160014
Project: 160014
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE) {
switch (targetController) {
case YOU:
      boolean yours=event.getPlayerId().equals(this.controllerId);
    if (yours) {
      if (getTargets().size() == 0) {
        for (        Effect effect : this.getEffects()) {
          effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
        }
      }
    }
  return yours;
case OPPONENT:
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
  if (getTargets().size() == 0) {
    for (    Effect effect : this.getEffects()) {
      effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
    }
  }
  return true;
}
break;
case ANY:
if (getTargets().size() == 0) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
}
}
return true;
case CONTROLLER_ATTACHED_TO:
Permanent attachment=game.getPermanent(sourceId);
if (attachment != null && attachment.getAttachedTo() != null) {
Permanent attachedTo=game.getPermanent(attachment.getAttachedTo());
if (attachedTo != null && attachedTo.getControllerId().equals(event.getPlayerId())) {
if (getTargets().size() == 0) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
}
}
return true;
}
}
}
}
return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE) {
switch (targetController) {
case YOU:
      boolean yours=event.getPlayerId().equals(this.controllerId);
    if (yours && setTargetPointer) {
      if (getTargets().size() == 0) {
        for (        Effect effect : this.getEffects()) {
          effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
        }
      }
    }
  return yours;
case OPPONENT:
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
  if (setTargetPointer && getTargets().size() == 0) {
    for (    Effect effect : this.getEffects()) {
      effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
    }
  }
  return true;
}
break;
case ANY:
if (setTargetPointer && getTargets().size() == 0) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
}
}
return true;
case CONTROLLER_ATTACHED_TO:
Permanent attachment=game.getPermanent(sourceId);
if (attachment != null && attachment.getAttachedTo() != null) {
Permanent attachedTo=game.getPermanent(attachment.getAttachedTo());
if (attachedTo != null && attachedTo.getControllerId().equals(event.getPlayerId())) {
if (setTargetPointer && getTargets().size() == 0) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
}
}
return true;
}
}
}
}
return false;
}
Program: 160015
Project: 160015
Buggy source:
public BeginningOfUpkeepTriggeredAbility(final BeginningOfUpkeepTriggeredAbility ability){
  super(ability);
  this.targetController=ability.targetController;
}

Fixed version (ground truth):
public BeginningOfUpkeepTriggeredAbility(final BeginningOfUpkeepTriggeredAbility ability){
  super(ability);
  this.targetController=ability.targetController;
  this.setTargetPointer=ability.setTargetPointer;
}
Program: 160016
Project: 160016
Buggy source:
public boolean putOntoBattlefield(int amount,Game game,UUID sourceId,UUID controllerId){
  Card source=game.getCard(sourceId);
  String setCode=source != null ? source.getExpansionSetCode() : null;
  GameEvent event=GameEvent.getEvent(EventType.CREATE_TOKEN,null,sourceId,controllerId,amount);
  if (!game.replaceEvent(event)) {
    amount=event.getAmount();
    for (int i=0; i < amount; i++) {
      PermanentToken permanent=new PermanentToken(this,controllerId,setCode,game);
      game.getState().addCard(permanent);
      game.getBattlefield().addPermanent(permanent);
      this.lastAddedTokenId=permanent.getId();
      permanent.entersBattlefield(sourceId,game);
      game.applyEffects();
      game.fireEvent(new ZoneChangeEvent(permanent,controllerId,Zone.OUTSIDE,Zone.BATTLEFIELD));
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
public boolean putOntoBattlefield(int amount,Game game,UUID sourceId,UUID controllerId){
  Card source=game.getCard(sourceId);
  String setCode=source != null ? source.getExpansionSetCode() : null;
  GameEvent event=GameEvent.getEvent(EventType.CREATE_TOKEN,null,sourceId,controllerId,amount);
  if (!game.replaceEvent(event)) {
    amount=event.getAmount();
    for (int i=0; i < amount; i++) {
      PermanentToken permanent=new PermanentToken(this,controllerId,setCode,game);
      game.getState().addCard(permanent);
      game.addPermanent(permanent);
      this.lastAddedTokenId=permanent.getId();
      permanent.entersBattlefield(sourceId,game);
      game.applyEffects();
      game.fireEvent(new ZoneChangeEvent(permanent,controllerId,Zone.OUTSIDE,Zone.BATTLEFIELD));
    }
    return true;
  }
  return false;
}
Program: 160017
Project: 160017
Buggy source:
public boolean replaceEvent(GameEvent event,Game game){
  boolean caught=false;
  List<UUID> consumed=new ArrayList<UUID>();
  do {
    List<ReplacementEffect> rEffects=getApplicableReplacementEffects(event,game);
    for (Iterator<ReplacementEffect> i=rEffects.iterator(); i.hasNext(); ) {
      ReplacementEffect entry=i.next();
      if (consumed.contains(entry.getId()))       i.remove();
    }
    if (rEffects.isEmpty())     break;
    int index;
    if (rEffects.size() == 1) {
      index=0;
    }
 else {
      Player player=game.getPlayer(event.getPlayerId());
      index=player.chooseEffect(rEffects,game);
    }
    ReplacementEffect rEffect=rEffects.get(index);
    caught=rEffect.replaceEvent(event,this.getAbility(rEffect.getId()),game);
    if (caught)     break;
    consumed.add(rEffect.getId());
    game.applyEffects();
  }
 while (true);
  return caught;
}

Fixed version (ground truth):
public boolean replaceEvent(GameEvent event,Game game){
  boolean caught=false;
  List<UUID> consumed=new ArrayList<UUID>();
  do {
    List<ReplacementEffect> rEffects=getApplicableReplacementEffects(event,game);
    for (Iterator<ReplacementEffect> i=rEffects.iterator(); i.hasNext(); ) {
      ReplacementEffect entry=i.next();
      if (consumed.contains(entry.getId())) {
        i.remove();
      }
    }
    if (rEffects.isEmpty()) {
      break;
    }
    int index;
    if (rEffects.size() == 1) {
      index=0;
    }
 else {
      Player player=game.getPlayer(event.getPlayerId());
      index=player.chooseEffect(rEffects,game);
    }
    ReplacementEffect rEffect=rEffects.get(index);
    caught=rEffect.replaceEvent(event,this.getAbility(rEffect.getId()),game);
    if (caught) {
      break;
    }
    consumed.add(rEffect.getId());
    game.applyEffects();
  }
 while (true);
  return caught;
}
Program: 160018
Project: 160018
Buggy source:
public List<RestrictionEffect> getApplicableRestrictionEffects(Permanent permanent,Game game){
  List<RestrictionEffect> effects=new ArrayList<RestrictionEffect>();
  for (  RestrictionEffect effect : restrictionEffects) {
    Ability ability=restrictionEffects.getAbility(effect.getId());
    if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game,permanent,false)) {
      if (effect.applies(permanent,ability,game))       effects.add(effect);
    }
  }
  return effects;
}

Fixed version (ground truth):
public List<RestrictionEffect> getApplicableRestrictionEffects(Permanent permanent,Game game){
  List<RestrictionEffect> effects=new ArrayList<RestrictionEffect>();
  for (  RestrictionEffect effect : restrictionEffects) {
    Ability ability=restrictionEffects.getAbility(effect.getId());
    if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game,permanent,false)) {
      if (effect.applies(permanent,ability,game)) {
        effects.add(effect);
      }
    }
  }
  return effects;
}
Program: 160019
Project: 160019
Buggy source:
public Ability getAbility(UUID effectId){
  Ability ability=layeredEffects.getAbility(effectId);
  if (ability == null)   ability=replacementEffects.getAbility(effectId);
  if (ability == null)   ability=preventionEffects.getAbility(effectId);
  if (ability == null)   ability=requirementEffects.getAbility(effectId);
  if (ability == null)   ability=restrictionEffects.getAbility(effectId);
  if (ability == null)   ability=asThoughEffects.getAbility(effectId);
  if (ability == null)   ability=costModificationEffects.getAbility(effectId);
  return ability;
}

Fixed version (ground truth):
public Ability getAbility(UUID effectId){
  Ability ability=layeredEffects.getAbility(effectId);
  if (ability == null) {
    ability=replacementEffects.getAbility(effectId);
  }
  if (ability == null) {
    ability=preventionEffects.getAbility(effectId);
  }
  if (ability == null) {
    ability=requirementEffects.getAbility(effectId);
  }
  if (ability == null) {
    ability=restrictionEffects.getAbility(effectId);
  }
  if (ability == null) {
    ability=asThoughEffects.getAbility(effectId);
  }
  if (ability == null) {
    ability=costModificationEffects.getAbility(effectId);
  }
  return ability;
}
Program: 160020
Project: 160020
Buggy source:
public ContinuousEffects(final ContinuousEffects effect){
  this.applyCounters=effect.applyCounters.copy();
  this.planeswalkerRedirectionEffect=effect.planeswalkerRedirectionEffect.copy();
  this.auraReplacementEffect=effect.auraReplacementEffect.copy();
  layeredEffects=effect.layeredEffects.copy();
  replacementEffects=effect.replacementEffects.copy();
  preventionEffects=effect.preventionEffects.copy();
  requirementEffects=effect.requirementEffects.copy();
  restrictionEffects=effect.restrictionEffects.copy();
  asThoughEffects=effect.asThoughEffects.copy();
  costModificationEffects=effect.costModificationEffects.copy();
  for (  Map.Entry<Effect,UUID> entry : effect.sources.entrySet()) {
    sources.put(entry.getKey(),entry.getValue());
  }
  collectAllEffects();
}

Fixed version (ground truth):
public ContinuousEffects(final ContinuousEffects effect){
  this.applyCounters=effect.applyCounters.copy();
  this.planeswalkerRedirectionEffect=effect.planeswalkerRedirectionEffect.copy();
  this.auraReplacementEffect=effect.auraReplacementEffect.copy();
  layeredEffects=effect.layeredEffects.copy();
  replacementEffects=effect.replacementEffects.copy();
  preventionEffects=effect.preventionEffects.copy();
  requirementEffects=effect.requirementEffects.copy();
  restrictionEffects=effect.restrictionEffects.copy();
  asThoughEffects=effect.asThoughEffects.copy();
  costModificationEffects=effect.costModificationEffects.copy();
  for (  Map.Entry<Effect,UUID> entry : effect.sources.entrySet()) {
    sources.put(entry.getKey(),entry.getValue());
  }
  collectAllEffects();
  lastSetTimestamp=effect.lastSetTimestamp;
}
Program: 160021
Project: 160021
Buggy source:
/** 
 * Initially effect timestamp is set when game starts in game.loadCard method. After that timestamp should be updated whenever effect becomes "actual" meaning it becomes turned on that is defined by Ability.#isInUseableZone(Game, boolean) method in #getLayeredEffects(Game).
 * @param layerEffects
 */
private void updateTimestamps(List<ContinuousEffect> layerEffects){
  for (  ContinuousEffect continuousEffect : layerEffects) {
    if (!previous.contains(continuousEffect)) {
      continuousEffect.setTimestamp();
    }
  }
  previous.clear();
  previous.addAll(layerEffects);
}

Fixed version (ground truth):
/** 
 * Initially effect timestamp is set when game starts in game.loadCard method. After that timestamp should be updated whenever effect becomes "actual" meaning it becomes turned on that is defined by Ability.#isInUseableZone(Game, boolean) method in #getLayeredEffects(Game).
 * @param layerEffects
 */
private void updateTimestamps(List<ContinuousEffect> layerEffects){
  for (  ContinuousEffect continuousEffect : layerEffects) {
    if (!previous.contains(continuousEffect)) {
      setUniqueTimesstamp(continuousEffect);
    }
  }
  previous.clear();
  previous.addAll(layerEffects);
}
Program: 160022
Project: 160022
Buggy source:
/** 
 * @param event
 * @param game
 * @return a list of all {@link ReplacementEffect} that apply to the current event
 */
private List<ReplacementEffect> getApplicableReplacementEffects(GameEvent event,Game game){
  List<ReplacementEffect> replaceEffects=new ArrayList<ReplacementEffect>();
  if (planeswalkerRedirectionEffect.applies(event,null,game))   replaceEffects.add(planeswalkerRedirectionEffect);
  if (auraReplacementEffect.applies(event,null,game))   replaceEffects.add(auraReplacementEffect);
  for (  ReplacementEffect effect : replacementEffects) {
    Ability ability=replacementEffects.getAbility(effect.getId());
    if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game,null,false)) {
      if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
        if (effect.applies(event,ability,game)) {
          replaceEffects.add(effect);
        }
      }
    }
  }
  for (  PreventionEffect effect : preventionEffects) {
    Ability ability=preventionEffects.getAbility(effect.getId());
    if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game,null,false)) {
      if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
        if (effect.applies(event,ability,game)) {
          replaceEffects.add(effect);
        }
      }
    }
  }
  return replaceEffects;
}

Fixed version (ground truth):
/** 
 * @param event
 * @param game
 * @return a list of all {@link ReplacementEffect} that apply to the current event
 */
private List<ReplacementEffect> getApplicableReplacementEffects(GameEvent event,Game game){
  List<ReplacementEffect> replaceEffects=new ArrayList<ReplacementEffect>();
  if (planeswalkerRedirectionEffect.applies(event,null,game)) {
    replaceEffects.add(planeswalkerRedirectionEffect);
  }
  if (auraReplacementEffect.applies(event,null,game)) {
    replaceEffects.add(auraReplacementEffect);
  }
  for (  ReplacementEffect effect : replacementEffects) {
    Ability ability=replacementEffects.getAbility(effect.getId());
    if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game,null,false)) {
      if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
        if (effect.applies(event,ability,game)) {
          replaceEffects.add(effect);
        }
      }
    }
  }
  for (  PreventionEffect effect : preventionEffects) {
    Ability ability=preventionEffects.getAbility(effect.getId());
    if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game,null,false)) {
      if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
        if (effect.applies(event,ability,game)) {
          replaceEffects.add(effect);
        }
      }
    }
  }
  return replaceEffects;
}
Program: 160023
Project: 160023
Buggy source:
private List<ContinuousEffect> filterLayeredEffects(List<ContinuousEffect> effects,Layer layer){
  List<ContinuousEffect> layerEffects=new ArrayList<ContinuousEffect>();
  for (  ContinuousEffect effect : effects) {
    if (effect.hasLayer(layer))     layerEffects.add(effect);
  }
  return layerEffects;
}

Fixed version (ground truth):
private List<ContinuousEffect> filterLayeredEffects(List<ContinuousEffect> effects,Layer layer){
  List<ContinuousEffect> layerEffects=new ArrayList<ContinuousEffect>();
  for (  ContinuousEffect effect : effects) {
    if (effect.hasLayer(layer)) {
      layerEffects.add(effect);
    }
  }
  return layerEffects;
}
Program: 160024
Project: 160024
Buggy source:
public List<ContinuousEffect> getLayeredEffects(Game game){
  List<ContinuousEffect> layerEffects=new ArrayList<ContinuousEffect>();
  for (  ContinuousEffect effect : layeredEffects) {
switch (effect.getDuration()) {
case WhileOnBattlefield:
case WhileOnStack:
case WhileInGraveyard:
      Ability ability=layeredEffects.getAbility(effect.getId());
    if (ability.isInUseableZone(game,null,false))     layerEffects.add(effect);
  break;
default :
layerEffects.add(effect);
}
}
updateTimestamps(layerEffects);
Collections.sort(layerEffects,new TimestampSorter());
return layerEffects;
}

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

Fixed version (ground truth):
public List<RequirementEffect> getApplicableRequirementEffects(Permanent permanent,Game game){
  List<RequirementEffect> effects=new ArrayList<RequirementEffect>();
  for (  RequirementEffect effect : requirementEffects) {
    Ability ability=requirementEffects.getAbility(effect.getId());
    if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game,null,false)) {
      if (effect.applies(permanent,ability,game)) {
        effects.add(effect);
      }
    }
  }
  return effects;
}
Program: 160026
Project: 160026
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Permanent permanent=game.getPermanent(source.getSourceId());
  if (permanent != null) {
    if (counter != null) {
      Counter newCounter=counter.copy();
      newCounter.add(amount.calculate(game,source));
      permanent.addCounters(counter.copy(),game);
      if (informPlayers) {
        Player player=game.getPlayer(source.getControllerId());
        if (player != null) {
          game.informPlayers(player.getName() + "String_Node_Str" + newCounter.getCount()+ "String_Node_Str"+ newCounter.getName()+ "String_Node_Str"+ permanent.getName());
        }
      }
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Permanent permanent=game.getPermanent(source.getSourceId());
  if (permanent != null) {
    if (counter != null) {
      Counter newCounter=counter.copy();
      newCounter.add(amount.calculate(game,source));
      permanent.addCounters(newCounter,game);
      if (informPlayers) {
        Player player=game.getPlayer(source.getControllerId());
        if (player != null) {
          game.informPlayers(player.getName() + "String_Node_Str" + newCounter.getCount()+ "String_Node_Str"+ newCounter.getName()+ "String_Node_Str"+ permanent.getName());
        }
      }
    }
  }
  return true;
}
Program: 160027
Project: 160027
Buggy source:
public TargetPermanentOrPlayer(final TargetPermanentOrPlayer target){
  super(target);
  this.filter=target.filter.copy();
}

Fixed version (ground truth):
public TargetPermanentOrPlayer(final TargetPermanentOrPlayer target){
  super(target);
  this.filter=target.filter.copy();
  this.filterPermanent=target.filterPermanent.copy();
}
Program: 160028
Project: 160028
Buggy source:
@Override public boolean hasLayer(Constants.Layer layer){
  return layer == Constants.Layer.RulesEffects;
}

Fixed version (ground truth):
@Override public boolean hasLayer(Layer layer){
  return layer == Layer.RulesEffects;
}
Program: 160029
Project: 160029
Buggy source:
public TargetSpellOrPermanent(final TargetSpellOrPermanent target){
  super(target);
  this.filter=target.filter.copy();
}

Fixed version (ground truth):
public TargetSpellOrPermanent(final TargetSpellOrPermanent target){
  super(target);
  this.filter=target.filter.copy();
  this.filterPermanent=target.filterPermanent.copy();
}
Program: 160030
Project: 160030
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (super.checkTrigger(event,game)) {
    FilterCreaturePermanent filter=new FilterCreaturePermanent("String_Node_Str");
    filter.add(new AnotherPredicate());
    TargetCreaturePermanent target1=new TargetCreaturePermanent(0,3,filter,false);
    game.getPlayer(getControllerId()).choose(Outcome.Exile,target1,sourceId,game);
    if (target1.getTargets().size() > 0) {
      getTargets().add(target1);
    }
    int leftTargets=3 - target1.getTargets().size();
    if (leftTargets > 0) {
      FilterCard filter2=new FilterCreatureCard("String_Node_Str" + leftTargets + "String_Node_Str"+ (leftTargets > 1 ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str");
      TargetCardInGraveyard target2=new TargetCardInGraveyard(0,leftTargets,filter2);
      game.getPlayer(getControllerId()).choose(Outcome.Exile,target2,sourceId,game);
      if (target2.getTargets().size() > 0) {
        getTargets().add(target2);
      }
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (super.checkTrigger(event,game)) {
    getTargets().clear();
    FilterCreaturePermanent filter=new FilterCreaturePermanent("String_Node_Str");
    filter.add(new AnotherPredicate());
    TargetCreaturePermanent target1=new TargetCreaturePermanent(0,3,filter,false);
    game.getPlayer(getControllerId()).chooseTarget(Outcome.Exile,target1,this,game);
    if (target1.getTargets().size() > 0) {
      getTargets().add(target1);
    }
    int leftTargets=3 - target1.getTargets().size();
    if (leftTargets > 0) {
      FilterCard filter2=new FilterCreatureCard("String_Node_Str" + leftTargets + "String_Node_Str"+ (leftTargets > 1 ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str");
      TargetCardInGraveyard target2=new TargetCardInGraveyard(0,leftTargets,filter2);
      game.getPlayer(getControllerId()).chooseTarget(Outcome.Exile,target2,this,game);
      if (target2.getTargets().size() > 0) {
        getTargets().add(target2);
      }
    }
    return true;
  }
  return false;
}
Program: 160031
Project: 160031
Buggy source:
public synchronized boolean joinTournament(UUID userId,String name,String playerType,int skill) throws GameException {
  if (table.getState() != TableState.WAITING) {
    return false;
  }
  Seat seat=table.getNextAvailableSeat(playerType);
  if (seat == null) {
    throw new GameException("String_Node_Str");
  }
  Player player=createPlayer(name,seat.getPlayerType(),skill);
  tournament.addPlayer(player,seat.getPlayerType());
  table.joinTable(player,seat);
  User user=UserManager.getInstance().getUser(userId);
  user.addTable(player.getId(),table);
  user.joinedTable(table.getRoomId(),table.getId(),true);
  logger.info("String_Node_Str" + player.getId());
  if (seat.getPlayer().isHuman()) {
    userPlayerMap.put(userId,player.getId());
  }
  return true;
}

Fixed version (ground truth):
public synchronized boolean joinTournament(UUID userId,String name,String playerType,int skill) throws GameException {
  if (table.getState() != TableState.WAITING) {
    return false;
  }
  Seat seat=table.getNextAvailableSeat(playerType);
  if (seat == null) {
    throw new GameException("String_Node_Str");
  }
  Player player=createPlayer(name,seat.getPlayerType(),skill);
  tournament.addPlayer(player,seat.getPlayerType());
  table.joinTable(player,seat);
  User user=UserManager.getInstance().getUser(userId);
  user.addTable(player.getId(),table);
  logger.info("String_Node_Str" + player.getId());
  if (seat.getPlayer().isHuman()) {
    user.joinedTable(table.getRoomId(),table.getId(),true);
    userPlayerMap.put(userId,player.getId());
  }
  return true;
}
Program: 160032
Project: 160032
Buggy source:
public synchronized boolean joinTable(UUID userId,String name,String playerType,int skill,DeckCardLists deckList) throws MageException {
  if (table.getState() != TableState.WAITING) {
    return false;
  }
  Seat seat=table.getNextAvailableSeat(playerType);
  if (seat == null) {
    throw new GameException("String_Node_Str");
  }
  Deck deck=Deck.load(deckList);
  if (!Main.isTestMode() && !table.getValidator().validate(deck)) {
    throw new InvalidDeckException(name + "String_Node_Str",table.getValidator().getInvalid());
  }
  Player player=createPlayer(name,seat.getPlayerType(),skill);
  match.addPlayer(player,deck);
  table.joinTable(player,seat);
  User user=UserManager.getInstance().getUser(userId);
  user.addTable(player.getId(),table);
  user.joinedTable(table.getRoomId(),table.getId(),false);
  logger.info("String_Node_Str" + player.getId());
  if (seat.getPlayer().isHuman()) {
    userPlayerMap.put(userId,player.getId());
  }
  return true;
}

Fixed version (ground truth):
public synchronized boolean joinTable(UUID userId,String name,String playerType,int skill,DeckCardLists deckList) throws MageException {
  if (table.getState() != TableState.WAITING) {
    return false;
  }
  Seat seat=table.getNextAvailableSeat(playerType);
  if (seat == null) {
    throw new GameException("String_Node_Str");
  }
  Deck deck=Deck.load(deckList);
  if (!Main.isTestMode() && !table.getValidator().validate(deck)) {
    throw new InvalidDeckException(name + "String_Node_Str",table.getValidator().getInvalid());
  }
  Player player=createPlayer(name,seat.getPlayerType(),skill);
  match.addPlayer(player,deck);
  table.joinTable(player,seat);
  User user=UserManager.getInstance().getUser(userId);
  user.addTable(player.getId(),table);
  logger.info("String_Node_Str" + player.getId());
  if (seat.getPlayer().isHuman()) {
    user.joinedTable(table.getRoomId(),table.getId(),false);
    userPlayerMap.put(userId,player.getId());
  }
  return true;
}
Program: 160033
Project: 160033
Buggy source:
private static String getTokenImagePath(CardInfo card){
  String filename=getImagePath(card,null);
  TFile file=new TFile(filename);
  if (!file.exists()) {
    CardInfo updated=new CardInfo(card);
    updated.setName(card.getName() + "String_Node_Str");
    filename=getImagePath(updated,null);
    file=new TFile(filename);
    if (!file.exists()) {
      updated=new CardInfo(card);
      updated.setName(card.getName() + "String_Node_Str");
      filename=getImagePath(updated,null);
    }
  }
  return filename;
}

Fixed version (ground truth):
private static String getTokenImagePath(CardInfo card){
  String useDefault=PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_USE_DEFAULT,"String_Node_Str");
  String path=useDefault.equals("String_Node_Str") ? null : PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_PATH,null);
  String filename=getImagePath(card,path);
  TFile file=new TFile(filename);
  if (!file.exists()) {
    CardInfo updated=new CardInfo(card);
    updated.setName(card.getName() + "String_Node_Str");
    filename=getImagePath(updated,path);
    file=new TFile(filename);
    if (!file.exists()) {
      updated=new CardInfo(card);
      updated.setName(card.getName() + "String_Node_Str");
      filename=getImagePath(updated,path);
    }
  }
  return filename;
}
Program: 160034
Project: 160034
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    for (    UUID playerId : controller.getInRange()) {
      if (playerId != source.getControllerId()) {
        Player opponent=game.getPlayer(playerId);
        if (opponent != null) {
          opponent.damage(2,source.getId(),game,false,true);
          Cards cards=opponent.getHand();
          for (int i=0; i < 2 && !cards.isEmpty(); i++) {
            Card card=cards.getRandom(game);
            if (card != null) {
              card.moveToZone(Constants.Zone.HAND,source.getId(),game,true);
              cards.remove(card);
            }
          }
        }
      }
    }
    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) {
    for (    UUID playerId : controller.getInRange()) {
      if (playerId != source.getControllerId()) {
        Player opponent=game.getPlayer(playerId);
        if (opponent != null) {
          opponent.damage(2,source.getId(),game,false,true);
          int amount=Math.min(2,opponent.getHand().size());
          for (int i=0; i < amount; i++) {
            Card card=opponent.getHand().getRandom(game);
            if (card != null) {
              opponent.discard(card,source,game);
            }
          }
        }
      }
    }
    return true;
  }
  return false;
}
Program: 160035
Project: 160035
Buggy source:
@Override public Token apply(Card source){
  if (target == null)   throw new IllegalArgumentException("String_Node_Str");
  target.setName(source.getName());
  target.getColor().setColor(source.getColor());
  target.getManaCost().clear();
  target.getManaCost().add(source.getManaCost());
  target.getCardType().clear();
  for (  Constants.CardType type : source.getCardType()) {
    target.getCardType().add(type);
  }
  target.getSubtype().clear();
  for (  String type : source.getSubtype()) {
    target.getSubtype().add(type);
  }
  target.getSupertype().clear();
  for (  String type : source.getSupertype()) {
    target.getSupertype().add(type);
  }
  target.getAbilities().clear();
  for (  Ability ability0 : source.getAbilities()) {
    Ability ability=ability0.copy();
    ability.newId();
    ability.setSourceId(target.getId());
    target.addAbility(ability);
  }
  target.getPower().setValue(source.getPower().getValue());
  target.getToughness().setValue(source.getToughness().getValue());
  return target;
}

Fixed version (ground truth):
@Override public Token apply(Card source){
  if (target == null)   throw new IllegalArgumentException("String_Node_Str");
  target.setName(source.getName());
  target.getColor().setColor(source.getColor());
  target.getManaCost().clear();
  target.getManaCost().add(source.getManaCost());
  target.getCardType().clear();
  for (  Constants.CardType type : source.getCardType()) {
    target.getCardType().add(type);
  }
  target.getSubtype().clear();
  for (  String type : source.getSubtype()) {
    target.getSubtype().add(type);
  }
  target.getSupertype().clear();
  for (  String type : source.getSupertype()) {
    target.getSupertype().add(type);
  }
  target.getAbilities().clear();
  for (  Ability ability0 : source.getAbilities()) {
    Ability ability=ability0.copy();
    ability.newId();
    ability.setSourceId(target.getId());
    target.addAbility(ability);
  }
  target.getPower().setValue(Integer.parseInt(source.getPower().toString()));
  target.getToughness().setValue(Integer.parseInt(source.getToughness().toString()));
  return target;
}
Program: 160036
Project: 160036
Buggy source:
@Override public boolean canPay(UUID sourceId,UUID controllerId,Game game){
  return targets.canChoose(controllerId,game);
}

Fixed version (ground truth):
@Override public boolean canPay(UUID sourceId,UUID controllerId,Game game){
  return targets.canChoose(sourceId,controllerId,game);
}
Program: 160037
Project: 160037
Buggy source:
public int count(FilterCard filter,UUID playerId,Game game);

Fixed version (ground truth):
public int count(FilterCard filter,UUID sourceId,UUID playerId,Game game);
Program: 160038
Project: 160038
Buggy source:
@Override public int count(FilterCard filter,UUID playerId,Game game){
  int result=0;
  for (  UUID card : this) {
    if (filter.match(game.getCard(card),playerId,game))     result++;
  }
  return result;
}

Fixed version (ground truth):
@Override public int count(FilterCard filter,UUID sourceId,UUID playerId,Game game){
  if (sourceId == null) {
    return count(filter,playerId,game);
  }
  int result=0;
  for (  UUID card : this) {
    if (filter.match(game.getCard(card),sourceId,playerId,game)) {
      result++;
    }
  }
  return result;
}
Program: 160039
Project: 160039
Buggy source:
public boolean match(Card card,UUID playerId,Game game){
  if (!this.match(card,game)) {
    return false;
  }
  return Predicates.and(extraPredicates).apply(new ObjectPlayer(card,playerId),game);
}

Fixed version (ground truth):
public boolean match(Card card,UUID sourceId,UUID playerId,Game game){
  if (!this.match(card,game)) {
    return false;
  }
  return Predicates.and(extraPredicates).apply(new ObjectSourcePlayer(card,sourceId,playerId),game);
}
Program: 160040
Project: 160040
Buggy source:
/** 
 * Checks if there are enough   {@link Card} that can be selected.
 * @param sourceControllerId - controller of the select event
 * @param game
 * @return - true if enough valid {@link Card} exist
 */
@Override public boolean canChoose(UUID sourceControllerId,Game game){
  for (  UUID playerId : game.getPlayer(sourceControllerId).getInRange()) {
    Player player=game.getPlayer(playerId);
    if (player != null) {
switch (zone) {
case HAND:
        if (player.getHand().count(filter,player.getId(),game) >= this.minNumberOfTargets) {
          return true;
        }
      break;
case GRAVEYARD:
    if (player.getGraveyard().count(filter,player.getId(),game) >= this.minNumberOfTargets) {
      return true;
    }
  break;
case LIBRARY:
if (player.getLibrary().count(filter,game) >= this.minNumberOfTargets) {
  return true;
}
break;
case EXILED:
if (game.getExile().getPermanentExile().count(filter,player.getId(),game) >= this.minNumberOfTargets) {
return true;
}
break;
}
}
}
return false;
}

Fixed version (ground truth):
/** 
 * Checks if there are enough   {@link Card} that can be selected.
 * @param sourceControllerId - controller of the select event
 * @param game
 * @return - true if enough valid {@link Card} exist
 */
@Override public boolean canChoose(UUID sourceControllerId,Game game){
  return canChoose(null,sourceControllerId,game);
}
Program: 160041
Project: 160041
Buggy source:
@Override public boolean apply(Game game,Ability source){
  DynamicValue amount=new DisruptingShoalVariableValue();
  Spell spell=game.getStack().getSpell(targetPointer.getFirst(game,source));
  if (spell != null && spell.getManaCost().convertedManaCost() == amount.calculate(game,source)) {
    return game.getStack().counter(source.getFirstTarget(),source.getSourceId(),game);
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  DynamicValue amount=new ExileFromHandCostCardConvertedMana();
  Spell spell=game.getStack().getSpell(targetPointer.getFirst(game,source));
  if (spell != null && spell.getManaCost().convertedManaCost() == amount.calculate(game,source)) {
    return game.getStack().counter(source.getFirstTarget(),source.getSourceId(),game);
  }
  return false;
}
Program: 160042
Project: 160042
Buggy source:
public boolean putOntoBattlefield(int amount,Game game,UUID sourceId,UUID controllerId){
  Card source=game.getCard(sourceId);
  String setCode=source != null ? source.getExpansionSetCode() : null;
  GameEvent event=GameEvent.getEvent(EventType.CREATE_TOKEN,null,sourceId,controllerId,amount);
  if (!game.replaceEvent(event)) {
    amount=event.getAmount();
    for (int i=0; i < amount; i++) {
      PermanentToken permanent=new PermanentToken(this,controllerId,setCode);
      game.getState().addCard(permanent);
      game.getBattlefield().addPermanent(permanent);
      this.lastAddedTokenId=permanent.getId();
      permanent.entersBattlefield(sourceId,game);
      game.applyEffects();
      game.fireEvent(new ZoneChangeEvent(permanent,controllerId,Zone.OUTSIDE,Zone.BATTLEFIELD));
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
public boolean putOntoBattlefield(int amount,Game game,UUID sourceId,UUID controllerId){
  Card source=game.getCard(sourceId);
  String setCode=source != null ? source.getExpansionSetCode() : null;
  GameEvent event=GameEvent.getEvent(EventType.CREATE_TOKEN,null,sourceId,controllerId,amount);
  if (!game.replaceEvent(event)) {
    amount=event.getAmount();
    for (int i=0; i < amount; i++) {
      PermanentToken permanent=new PermanentToken(this,controllerId,setCode,game);
      game.getState().addCard(permanent);
      game.getBattlefield().addPermanent(permanent);
      this.lastAddedTokenId=permanent.getId();
      permanent.entersBattlefield(sourceId,game);
      game.applyEffects();
      game.fireEvent(new ZoneChangeEvent(permanent,controllerId,Zone.OUTSIDE,Zone.BATTLEFIELD));
    }
    return true;
  }
  return false;
}
Program: 160043
Project: 160043
Buggy source:
@Override public boolean apply(Game game,Ability source){
  return game.getPermanent(source.getSourceId()).isTransformed();
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Permanent permanent=game.getPermanent(source.getSourceId());
  if (permanent != null) {
    if (notCondition) {
      return !permanent.isTransformed();
    }
 else {
      return permanent.isTransformed();
    }
  }
  return false;
}