nus-yam/ex-repair huggingface dataset:
Program: 159586
Project: 159586
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    Card card=controller.getLibrary().getFromTop(game);
    controller.drawCards(1,game);
    controller.revealCards("String_Node_Str",new CardsImpl(card),game);
    if (filter.match(card,game)) {
      controller.discard(card,source,game);
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    Card card=controller.getLibrary().getFromTop(game);
    controller.drawCards(1,game);
    controller.revealCards("String_Node_Str",new CardsImpl(card),game);
    if (!filter.match(card,game)) {
      controller.discard(card,source,game);
    }
    return true;
  }
  return false;
}
Program: 159587
Project: 159587
Buggy source:
public synchronized void leaveTable(UUID userId){
  UUID playerId=userPlayerMap.get(userId);
  if (playerId != null) {
    if (table.getState() == TableState.WAITING || table.getState() == TableState.STARTING) {
      table.leaveNotStartedTable(playerId);
      if (table.isTournament()) {
        TournamentManager.getInstance().quit(tournament.getId(),userId);
      }
 else {
        match.leave(playerId);
      }
      User user=UserManager.getInstance().getUser(userId);
      user.removeTable(playerId);
      userPlayerMap.remove(userId);
    }
 else     if (!table.getState().equals(TableState.FINISHED)) {
      if (table.isTournament()) {
        TableManager.getInstance().userQuitTournamentSubTables(userId);
        TournamentManager.getInstance().quit(tournament.getId(),userId);
      }
 else {
        match.leave(playerId);
      }
    }
  }
}

Fixed version (ground truth):
public synchronized void leaveTable(UUID userId){
  UUID playerId=userPlayerMap.get(userId);
  if (playerId != null) {
    if (table.getState() == TableState.WAITING || table.getState() == TableState.STARTING) {
      table.leaveNotStartedTable(playerId);
      if (table.isTournament()) {
        tournament.removePlayer(playerId);
      }
 else {
        match.leave(playerId);
      }
      User user=UserManager.getInstance().getUser(userId);
      user.removeTable(playerId);
      userPlayerMap.remove(userId);
    }
 else     if (!table.getState().equals(TableState.FINISHED)) {
      if (table.isTournament()) {
        TableManager.getInstance().userQuitTournamentSubTables(userId);
        TournamentManager.getInstance().quit(tournament.getId(),userId);
      }
 else {
        match.leave(playerId);
      }
    }
  }
}
Program: 159588
Project: 159588
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);
  if (player != null) {
    tournament.addPlayer(player,seat.getPlayerType());
    table.joinTable(player,seat);
    User user=UserManager.getInstance().getUser(userId);
    if (user == null) {
      logger.fatal(new StringBuilder("String_Node_Str").append(name).append("String_Node_Str").append(userId).toString());
      return false;
    }
    if (!player.canJoinTable(table)) {
      user.showUserMessage("String_Node_Str",new StringBuilder("String_Node_Str").append(seat.getPlayerType()).append("String_Node_Str").toString());
      return false;
    }
    user.addTable(player.getId(),table);
    logger.debug("String_Node_Str" + player.getId());
    if (seat.getPlayer().isHuman()) {
      user.joinedTable(table.getRoomId(),table.getId(),true);
      userPlayerMap.put(userId,player.getId());
    }
    return true;
  }
 else {
    throw new GameException("String_Node_Str" + seat.getPlayerType().toString() + "String_Node_Str");
  }
}

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);
  if (player != null) {
    User user=UserManager.getInstance().getUser(userId);
    if (user == null) {
      logger.fatal(new StringBuilder("String_Node_Str").append(name).append("String_Node_Str").append(userId).toString());
      return false;
    }
    if (!player.canJoinTable(table)) {
      user.showUserMessage("String_Node_Str",new StringBuilder("String_Node_Str").append(seat.getPlayerType()).append("String_Node_Str").toString());
      return false;
    }
    tournament.addPlayer(player,seat.getPlayerType());
    table.joinTable(player,seat);
    user.addTable(player.getId(),table);
    logger.debug("String_Node_Str" + player.getId());
    if (seat.getPlayer().isHuman()) {
      user.joinedTable(table.getRoomId(),table.getId(),true);
      userPlayerMap.put(userId,player.getId());
    }
    return true;
  }
 else {
    throw new GameException("String_Node_Str" + seat.getPlayerType().toString() + "String_Node_Str");
  }
}
Program: 159589
Project: 159589
Buggy source:
public synchronized void startMatch(){
  if (table.getState() == TableState.STARTING) {
    try {
      User user=UserManager.getInstance().getUser(userId);
      logger.info(new StringBuilder("String_Node_Str").append(user.getName()).append("String_Node_Str").append(match.getId()));
      match.startMatch();
      startGame(null);
    }
 catch (    GameException ex) {
      logger.fatal("String_Node_Str",ex);
      match.endGame();
    }
  }
}

Fixed version (ground truth):
public synchronized void startMatch(){
  if (table.getState() == TableState.STARTING) {
    try {
      String tableInfo;
      if (table.isTournamentSubTable()) {
        tableInfo="String_Node_Str" + table.getTournament().getId() + "String_Node_Str";
      }
 else {
        User user=UserManager.getInstance().getUser(userId);
        tableInfo="String_Node_Str" + user.getName();
      }
      logger.info(new StringBuilder(tableInfo).append("String_Node_Str").append(match.getId()));
      match.startMatch();
      startGame(null);
    }
 catch (    GameException ex) {
      logger.fatal("String_Node_Str",ex);
      match.endGame();
    }
  }
}
Program: 159590
Project: 159590
Buggy source:
protected void play(UUID nextPlayerId){
  if (!isPaused() && !isGameOver()) {
    PlayerList players=state.getPlayerList(nextPlayerId);
    Player player=getPlayer(players.get());
    while (!isPaused() && !isGameOver()) {
      if (!playTurn(player)) {
        break;
      }
      state.setTurnNum(state.getTurnNum() + 1);
      while (getState().getTurnMods().extraTurn(player.getId())) {
        state.setExtraTurn(true);
        playTurn(player);
        state.setTurnNum(state.getTurnNum() + 1);
      }
      state.setExtraTurn(false);
      player=players.getNext(this);
    }
  }
  if (isGameOver()) {
    winnerId=findWinnersAndLosers();
  }
}

Fixed version (ground truth):
protected void play(UUID nextPlayerId){
  if (!isPaused() && !isGameOver()) {
    PlayerList players=state.getPlayerList(nextPlayerId);
    Player player=getPlayer(players.get());
    while (!isPaused() && !isGameOver()) {
      if (!playTurn(player)) {
        break;
      }
      state.setTurnNum(state.getTurnNum() + 1);
      while (getState().getTurnMods().extraTurn(player.getId())) {
        state.setExtraTurn(true);
        playTurn(player);
        state.setTurnNum(state.getTurnNum() + 1);
      }
      state.setExtraTurn(false);
      player=players.getNext(this);
    }
  }
  if (isGameOver()) {
    winnerId=findWinnersAndLosers();
    logger.info(new StringBuilder("String_Node_Str").append(this.getId()).append("String_Node_Str"));
  }
}
Program: 159591
Project: 159591
Buggy source:
@Override public synchronized void concede(UUID playerId){
  Player player=state.getPlayer(playerId);
  if (player != null) {
    logger.info(new StringBuilder("String_Node_Str").append(player.getName()).append("String_Node_Str").append(this.getId()));
    player.concede(this);
    fireInformEvent(player.getName() + "String_Node_Str");
  }
}

Fixed version (ground truth):
@Override public synchronized void concede(UUID playerId){
  Player player=state.getPlayer(playerId);
  if (player != null) {
    logger.debug(new StringBuilder("String_Node_Str").append(player.getName()).append("String_Node_Str").append(this.getId()));
    player.concede(this);
    fireInformEvent(player.getName() + "String_Node_Str");
  }
}
Program: 159592
Project: 159592
Buggy source:
@Override public boolean isGameOver(){
  if (state.isGameOver()) {
    return true;
  }
  int remainingPlayers=0;
  int numLosers=0;
  for (  Player player : state.getPlayers().values()) {
    if (!player.hasLeft()) {
      remainingPlayers++;
    }
    if (player.hasLost()) {
      numLosers++;
    }
  }
  if (remainingPlayers <= 1 || numLosers >= state.getPlayers().size() - 1) {
    for (    Player player : state.getPlayers().values()) {
      if (!player.hasLeft() && !player.hasLost()) {
        logger.info(new StringBuilder("String_Node_Str").append(player.getName()).append("String_Node_Str").append(this.getId()));
        player.won(this);
      }
    }
    end();
    endTime=new Date();
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public synchronized boolean isGameOver(){
  if (state.isGameOver()) {
    return true;
  }
  int remainingPlayers=0;
  int numLosers=0;
  for (  Player player : state.getPlayers().values()) {
    if (!player.hasLeft()) {
      remainingPlayers++;
    }
    if (player.hasLost()) {
      numLosers++;
    }
  }
  if (remainingPlayers <= 1 || numLosers >= state.getPlayers().size() - 1) {
    end();
    for (    Player player : state.getPlayers().values()) {
      if (!player.hasLeft() && !player.hasLost()) {
        logger.debug(new StringBuilder("String_Node_Str").append(player.getName()).append("String_Node_Str").append(this.getId()));
        player.won(this);
      }
    }
    endTime=new Date();
    return true;
  }
  return false;
}
Program: 159594
Project: 159594
Buggy source:
@Override public boolean cast(SpellAbility ability,Game game,boolean noMana){
  if (!ability.getSpellAbilityType().equals(SpellAbilityType.BASE)) {
    ability=chooseSpellAbilityForCast(ability,game,noMana);
  }
  Card card=game.getCard(ability.getSourceId());
  if (card != null) {
    if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.CAST_SPELL,ability.getId(),ability.getSourceId(),playerId))) {
      int bookmark=game.bookmarkState();
      Zone fromZone=game.getState().getZone(card.getId());
      card.cast(game,fromZone,ability,playerId);
      Spell spell=game.getStack().getSpell(ability.getId());
      if (spell.activate(game,noMana)) {
        GameEvent event=GameEvent.getEvent(GameEvent.EventType.SPELL_CAST,spell.getSpellAbility().getId(),spell.getSpellAbility().getSourceId(),playerId);
        event.setZone(fromZone);
        game.fireEvent(event);
        game.fireInformEvent(new StringBuilder(name).append(spell.getActivatedMessage(game)).toString());
        game.removeBookmark(bookmark);
        resetStoredBookmark(game);
        return true;
      }
      game.restoreState(bookmark);
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean cast(SpellAbility ability,Game game,boolean noMana){
  if (!ability.getSpellAbilityType().equals(SpellAbilityType.BASE)) {
    ability=chooseSpellAbilityForCast(ability,game,noMana);
  }
  Card card=game.getCard(ability.getSourceId());
  if (card != null) {
    if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.CAST_SPELL,ability.getId(),ability.getSourceId(),playerId))) {
      int bookmark=game.bookmarkState();
      Zone fromZone=game.getState().getZone(card.getId());
      card.cast(game,fromZone,ability,playerId);
      Spell spell=game.getStack().getSpell(ability.getId());
      if (spell.activate(game,noMana)) {
        GameEvent event=GameEvent.getEvent(GameEvent.EventType.SPELL_CAST,spell.getSpellAbility().getId(),spell.getSpellAbility().getSourceId(),playerId);
        event.setZone(fromZone);
        game.fireEvent(event);
        game.fireInformEvent(new StringBuilder(name).append(spell.getActivatedMessage(game)).toString());
        game.removeBookmark(bookmark);
        resetStoredBookmark(game);
        return true;
      }
      if (!game.isGameOver()) {
        game.restoreState(bookmark);
      }
    }
  }
  return false;
}
Program: 159595
Project: 159595
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(targetPointer.getFirst(game,source));
  Permanent permanent=game.getPermanent(source.getSourceId());
  if (player == null || permanent == null) {
    return false;
  }
  int targetCount=game.getBattlefield().countAll(filter,player.getId(),game);
  int counterCount=permanent.getCounters().getCount(CounterType.FADE);
  int amount=Math.min(counterCount,targetCount);
  Target target=new TargetControlledPermanent(amount,amount,filter,false);
  target.setRequired(true);
  target.setNotTarget(true);
  if (player.chooseTarget(Outcome.Tap,target,source,game)) {
    boolean abilityApplied=false;
    for (    UUID uuid : target.getTargets()) {
      Permanent selectedPermanent=game.getPermanent(uuid);
      if (selectedPermanent != null) {
        abilityApplied|=selectedPermanent.tap(game);
      }
    }
    return abilityApplied;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(targetPointer.getFirst(game,source));
  Permanent permanent=game.getPermanent(source.getSourceId());
  if (player == null || permanent == null) {
    return false;
  }
  int targetCount=game.getBattlefield().countAll(filter,player.getId(),game);
  int counterCount=permanent.getCounters().getCount(CounterType.FADE);
  int amount=Math.min(counterCount,targetCount);
  Target target=new TargetControlledPermanent(amount,amount,filter,false);
  target.setRequired(true);
  target.setNotTarget(true);
  if (amount > 0 && player.chooseTarget(Outcome.Tap,target,source,game)) {
    boolean abilityApplied=false;
    for (    UUID uuid : target.getTargets()) {
      Permanent selectedPermanent=game.getPermanent(uuid);
      if (selectedPermanent != null) {
        abilityApplied|=selectedPermanent.tap(game);
      }
    }
    return abilityApplied;
  }
  return false;
}
Program: 159596
Project: 159596
Buggy source:
private int getManaCostScore(Card card,List<ColoredManaSymbol> allowedColors){
  int converted=card.getManaCost().convertedManaCost();
  final Map<String,Integer> singleCount=new HashMap<String,Integer>();
  int maxSingleCount=0;
  int multicolor=0;
  Set<String> colors=new HashSet<String>();
  for (  String symbol : card.getManaCost().getSymbols()) {
    int count=0;
    symbol=symbol.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
    if (isColoredMana(symbol)) {
      for (      ColoredManaSymbol allowed : allowedColors) {
        if (allowed.toString().equals(symbol)) {
          count++;
        }
      }
      if (count == 0) {
        return -30;
      }
      if (!colors.contains(symbol)) {
        multicolor+=1;
      }
      Integer typeCount=singleCount.get(symbol);
      if (typeCount == null) {
        typeCount=new Integer(0);
      }
      typeCount+=1;
      singleCount.put(symbol,typeCount);
      maxSingleCount=Math.max(maxSingleCount,typeCount);
    }
  }
  int multicolorBonus=multicolor > 1 ? 30 : 0;
  maxSingleCount=Math.min(maxSingleCount,SINGLE_PENALTY.length - 1);
  return 2 * converted + 3 * (10 - SINGLE_PENALTY[maxSingleCount]) + multicolorBonus;
}

Fixed version (ground truth):
private int getManaCostScore(Card card,List<ColoredManaSymbol> allowedColors){
  int converted=card.getManaCost().convertedManaCost();
  final Map<String,Integer> singleCount=new HashMap<String,Integer>();
  int maxSingleCount=0;
  int multicolor=0;
  Set<String> colors=new HashSet<String>();
  for (  String symbol : card.getManaCost().getSymbols()) {
    int count=0;
    symbol=symbol.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
    if (isColoredMana(symbol)) {
      for (      ColoredManaSymbol allowed : allowedColors) {
        if (symbol.contains(allowed.toString())) {
          count++;
        }
      }
      if (count == 0) {
        return -30;
      }
      if (!colors.contains(symbol)) {
        multicolor+=1;
        colors.add(symbol);
      }
      Integer typeCount=singleCount.get(symbol);
      if (typeCount == null) {
        typeCount=new Integer(0);
      }
      typeCount+=1;
      singleCount.put(symbol,typeCount);
      maxSingleCount=Math.max(maxSingleCount,typeCount);
    }
  }
  int multicolorBonus=multicolor > 1 ? 30 : 0;
  maxSingleCount=Math.min(maxSingleCount,SINGLE_PENALTY.length - 1);
  return 2 * converted + 3 * (10 - SINGLE_PENALTY[maxSingleCount]) + multicolorBonus;
}
Program: 159598
Project: 159598
Buggy source:
protected static boolean isColoredMana(String symbol){
  return symbol.equals("String_Node_Str") || symbol.equals("String_Node_Str") || symbol.equals("String_Node_Str")|| symbol.equals("String_Node_Str")|| symbol.equals("String_Node_Str");
}

Fixed version (ground truth):
protected static boolean isColoredMana(String symbol){
  return symbol.equals("String_Node_Str") || symbol.equals("String_Node_Str") || symbol.equals("String_Node_Str")|| symbol.equals("String_Node_Str")|| symbol.equals("String_Node_Str")|| symbol.contains("String_Node_Str");
}
Program: 159599
Project: 159599
Buggy source:
@Override public boolean apply(Game game,Ability source){
  for (  Permanent permanent : game.getBattlefield().getActivePermanents(filter,source.getControllerId(),source.getSourceId(),game)) {
    permanent.destroy(source.getId(),game,noRegen);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  for (  Permanent permanent : game.getBattlefield().getActivePermanents(filter,source.getControllerId(),source.getSourceId(),game)) {
    permanent.destroy(source.getSourceId(),game,noRegen);
  }
  return true;
}
Program: 159600
Project: 159600
Buggy source:
public DestroyAllEffect(final DestroyAllEffect effect){
  super(effect);
  this.filter=effect.filter.copy();
}

Fixed version (ground truth):
public DestroyAllEffect(final DestroyAllEffect effect){
  super(effect);
  this.filter=effect.filter.copy();
  this.noRegen=effect.noRegen;
}
Program: 159601
Project: 159601
Buggy source:
@Override public BeginningOfYourUpkeepdelayTriggeredAbility copy(){
  return new BeginningOfYourUpkeepdelayTriggeredAbility(this);
}

Fixed version (ground truth):
@Override public ObzedatGhostCouncilReturnEffect copy(){
  return new ObzedatGhostCouncilReturnEffect(this);
}
Program: 159602
Project: 159602
Buggy source:
@Override public boolean applies(Permanent permanent,Ability source,Game game){
  return true;
}

Fixed version (ground truth):
@Override public boolean applies(Permanent permanent,Ability source,Game game){
  return permanent.canBlock(source.getFirstTarget(),game);
}
Program: 159603
Project: 159603
Buggy source:
@Override public boolean applies(Permanent permanent,Ability source,Game game){
  Permanent creature=game.getPermanent(source.getTargets().get(1).getFirstTarget());
  if (creature != null) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(Permanent permanent,Ability source,Game game){
  if (permanent.getId().equals(source.getTargets().get(1).getFirstTarget())) {
    return permanent.canBlock(source.getFirstTarget(),game);
  }
  return false;
}
Program: 159604
Project: 159604
Buggy source:
@Override public boolean applies(Permanent permanent,Ability source,Game game){
  if (permanent.getId().equals(source.getFirstTarget())) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(Permanent permanent,Ability source,Game game){
  if (permanent.getId().equals(source.getFirstTarget())) {
    Permanent equipment=game.getPermanent(source.getSourceId());
    if (equipment != null && equipment.getAttachedTo() != null) {
      return permanent.canBlock(equipment.getAttachedTo(),game);
    }
  }
  return false;
}
Program: 159605
Project: 159605
Buggy source:
@Override public boolean applies(Permanent permanent,Ability source,Game game){
  return true;
}

Fixed version (ground truth):
@Override public boolean applies(Permanent permanent,Ability source,Game game){
  Permanent attachment=game.getPermanent(source.getSourceId());
  if (attachment != null && attachment.getAttachedTo() != null) {
    return permanent.canBlock(attachment.getAttachedTo(),game);
  }
  return true;
}
Program: 159606
Project: 159606
Buggy source:
@Override public boolean applies(Permanent permanent,Ability source,Game game){
  return true;
}

Fixed version (ground truth):
@Override public boolean applies(Permanent permanent,Ability source,Game game){
  return permanent.canBlock(source.getSourceId(),game);
}
Program: 159607
Project: 159607
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 (permanent.getId().equals(source.getFirstTarget())) {
    Permanent blocker=game.getPermanent(source.getFirstTarget());
    if (blocker != null && blocker.canBlock(source.getSourceId(),game)) {
      return true;
    }
  }
  return false;
}
Program: 159608
Project: 159608
Buggy source:
@Override public boolean canBlock(UUID attackerId,Game game){
  if (tapped && !game.getState().getContinuousEffects().asThough(this.getId(),AsThoughEffectType.BLOCK_TAPPED,game)) {
    return false;
  }
  Permanent attacker=game.getPermanent(attackerId);
  for (  Map.Entry entry : game.getContinuousEffects().getApplicableRestrictionEffects(this,game).entrySet()) {
    RestrictionEffect effect=(RestrictionEffect)entry.getKey();
    for (    Ability ability : (HashSet<Ability>)entry.getValue()) {
      if (!effect.canBlock(attacker,this,ability,game)) {
        return false;
      }
    }
  }
  for (  Map.Entry entry : game.getContinuousEffects().getApplicableRestrictionEffects(attacker,game).entrySet()) {
    RestrictionEffect effect=(RestrictionEffect)entry.getKey();
    for (    Ability ability : (HashSet<Ability>)entry.getValue()) {
      if (!effect.canBeBlocked(attacker,this,ability,game)) {
        return false;
      }
    }
  }
  if (attacker != null && attacker.hasProtectionFrom(this,game)) {
    return false;
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean canBlock(UUID attackerId,Game game){
  if (tapped && !game.getState().getContinuousEffects().asThough(this.getId(),AsThoughEffectType.BLOCK_TAPPED,game)) {
    return false;
  }
  Permanent attacker=game.getPermanent(attackerId);
  if (!game.getOpponents(this.getControllerId()).contains(attacker.getControllerId())) {
    return false;
  }
  for (  Map.Entry entry : game.getContinuousEffects().getApplicableRestrictionEffects(this,game).entrySet()) {
    RestrictionEffect effect=(RestrictionEffect)entry.getKey();
    for (    Ability ability : (HashSet<Ability>)entry.getValue()) {
      if (!effect.canBlock(attacker,this,ability,game)) {
        return false;
      }
    }
  }
  for (  Map.Entry entry : game.getContinuousEffects().getApplicableRestrictionEffects(attacker,game).entrySet()) {
    RestrictionEffect effect=(RestrictionEffect)entry.getKey();
    for (    Ability ability : (HashSet<Ability>)entry.getValue()) {
      if (!effect.canBeBlocked(attacker,this,ability,game)) {
        return false;
      }
    }
  }
  if (attacker != null && attacker.hasProtectionFrom(this,game)) {
    return false;
  }
  return true;
}
Program: 159610
Project: 159610
Buggy source:
private boolean checkSpell(Spell spell,Game game){
  if (spell != null) {
    SpellAbility sa=spell.getSpellAbility();
    for (    Effect effect : sa.getEffects()) {
      for (      UUID targetId : effect.getTargetPointer().getTargets(game,sa)) {
        if (targetId.equals(this.getSourceId())) {
          return true;
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean checkSpell(Spell spell,Game game){
  if (spell != null) {
    SpellAbility sa=spell.getSpellAbility();
    for (    Target target : sa.getTargets()) {
      if (!target.isNotTarget() && target.getTargets().contains(this.getSourceId())) {
        return true;
      }
    }
    for (    Effect effect : sa.getEffects()) {
      for (      UUID targetId : effect.getTargetPointer().getTargets(game,sa)) {
        if (targetId.equals(this.getSourceId())) {
          return true;
        }
      }
    }
  }
  return false;
}
Program: 159611
Project: 159611
Buggy source:
public Mana computeMana(Game game,Ability source){
  this.computedMana.clear();
  if (!source.getChoices().isEmpty()) {
    Choice choice=source.getChoices().get(0);
    if (choice != null && choice instanceof ChoiceColor) {
      String color=choice.getChoice();
      if (color.equals("String_Node_Str")) {
        computedMana.setRed(new DevotionCount(ManaType.RED).calculate(game,source));
      }
 else       if (color.equals("String_Node_Str")) {
        computedMana.setBlue(new DevotionCount(ManaType.BLUE).calculate(game,source));
      }
 else       if (color.equals("String_Node_Str")) {
        computedMana.setWhite(new DevotionCount(ManaType.WHITE).calculate(game,source));
      }
 else       if (color.equals("String_Node_Str")) {
        computedMana.setBlack(new DevotionCount(ManaType.BLACK).calculate(game,source));
      }
 else       if (color.equals("String_Node_Str")) {
        computedMana.setGreen(new DevotionCount(ManaType.GREEN).calculate(game,source));
      }
    }
  }
  return computedMana;
}

Fixed version (ground truth):
public Mana computeMana(Game game,Ability source){
  this.computedMana.clear();
  if (!source.getChoices().isEmpty()) {
    Choice choice=source.getChoices().get(0);
    if (choice != null && choice instanceof ChoiceColor && choice.getChoice() != null) {
      String color=choice.getChoice();
      if (color.equals("String_Node_Str")) {
        computedMana.setRed(new DevotionCount(ManaType.RED).calculate(game,source));
      }
 else       if (color.equals("String_Node_Str")) {
        computedMana.setBlue(new DevotionCount(ManaType.BLUE).calculate(game,source));
      }
 else       if (color.equals("String_Node_Str")) {
        computedMana.setWhite(new DevotionCount(ManaType.WHITE).calculate(game,source));
      }
 else       if (color.equals("String_Node_Str")) {
        computedMana.setBlack(new DevotionCount(ManaType.BLACK).calculate(game,source));
      }
 else       if (color.equals("String_Node_Str")) {
        computedMana.setGreen(new DevotionCount(ManaType.GREEN).calculate(game,source));
      }
    }
  }
  return computedMana;
}
Program: 159612
Project: 159612
Buggy source:
@Override public boolean apply(Game game,Ability source){
  DelayedTriggeredAbility delayedAbility=(DelayedTriggeredAbility)ability.copy();
  delayedAbility.setSourceId(source.getSourceId());
  delayedAbility.setControllerId(source.getControllerId());
  if (this.copyTargets) {
    delayedAbility.getTargets().addAll(source.getTargets());
    for (    Effect effect : ability.getEffects()) {
      effect.setTargetPointer(targetPointer);
    }
  }
  game.addDelayedTriggeredAbility(delayedAbility);
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  DelayedTriggeredAbility delayedAbility=(DelayedTriggeredAbility)ability.copy();
  delayedAbility.setSourceId(source.getSourceId());
  delayedAbility.setControllerId(source.getControllerId());
  if (this.copyTargets) {
    delayedAbility.getTargets().addAll(source.getTargets());
    for (    Effect effect : delayedAbility.getEffects()) {
      effect.setTargetPointer(targetPointer);
      effect.getTargetPointer().init(game,source);
    }
  }
  game.addDelayedTriggeredAbility(delayedAbility);
  return true;
}
Program: 159613
Project: 159613
Buggy source:
@Override public boolean apply(Game game,Ability source){
  boolean applied=false;
  List<Permanent> permanents=game.getBattlefield().getActivePermanents(filter,source.getControllerId(),source.getSourceId(),game);
  if (permanents != null && !permanents.isEmpty()) {
    for (    Permanent permanent : permanents) {
      for (      Ability ability : permanent.getAbilities()) {
        if (!(ability instanceof SpellAbility) && ability.getManaCosts() != null) {
          int costCount=ability.getManaCosts().size();
          for (          Cost cost : ability.getManaCosts()) {
            if (cost instanceof GenericManaCost) {
              GenericManaCost costCasted=(GenericManaCost)cost;
              int amount=costCasted.convertedManaCost();
              int adjustedAmount=0;
              if (costCount == 1 && (amount - 2) <= 0) {
                adjustedAmount=1;
              }
 else {
                adjustedAmount=Math.max(0,amount - 2);
              }
              costCasted.setMana(adjustedAmount);
              applied=true;
            }
          }
        }
      }
    }
  }
  return applied;
}

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

Fixed version (ground truth):
@Override public TrainingGroundsEffect copy(){
  return new TrainingGroundsEffect(this);
}
Program: 159615
Project: 159615
Buggy source:
public Player getNext(Game game){
  Player player;
  UUID start=this.get();
  while (true) {
    player=game.getPlayer(super.getNext());
    if (!player.hasLeft() && !player.hasLost()) {
      if (!player.hasReachedNextTurnAfterLeaving()) {
        player.setReachedNextTurnAfterLeaving(true);
      }
      break;
    }
    if (player.getId().equals(start)) {
      return null;
    }
  }
  return player;
}

Fixed version (ground truth):
public Player getNext(Game game){
  Player player;
  UUID start=this.get();
  while (true) {
    player=game.getPlayer(super.getNext());
    if (!player.hasLeft() && !player.hasLost()) {
      break;
    }
    if (!player.hasReachedNextTurnAfterLeaving()) {
      player.setReachedNextTurnAfterLeaving(true);
    }
    if (player.getId().equals(start)) {
      return null;
    }
  }
  return player;
}
Program: 159616
Project: 159616
Buggy source:
@Override public void start(UUID choosingPlayerId,GameOptions options){
  startTime=new Date();
  this.gameOptions=options;
  scorePlayer=state.getPlayers().values().iterator().next();
  init(choosingPlayerId,options);
  play(startingPlayerId);
}

Fixed version (ground truth):
@Override public void start(UUID choosingPlayerId,GameOptions options){
  startTime=new Date();
  this.gameOptions=options;
  if (state.getPlayers().values().iterator().hasNext()) {
    scorePlayer=state.getPlayers().values().iterator().next();
    init(choosingPlayerId,options);
    play(startingPlayerId);
  }
}
Program: 159617
Project: 159617
Buggy source:
public void leaveTable(UUID playerId){
  for (int i=0; i < numSeats; i++) {
    Player player=seats[i].getPlayer();
    if (player != null && player.getId().equals(playerId)) {
      if (match != null) {
        match.leave(playerId);
      }
 else {
        seats[i].setPlayer(null);
        if (state == TableState.STARTING) {
          state=TableState.WAITING;
        }
      }
      break;
    }
  }
}

Fixed version (ground truth):
public void leaveTable(UUID playerId){
  for (int i=0; i < numSeats; i++) {
    Player player=seats[i].getPlayer();
    if (player != null && player.getId().equals(playerId)) {
      seats[i].setPlayer(null);
      if (state == TableState.STARTING) {
        state=TableState.WAITING;
      }
      break;
    }
  }
}
Program: 159618
Project: 159618
Buggy source:
@Override public boolean leave(UUID playerId){
  MatchPlayer mPlayer=getPlayer(playerId);
  if (mPlayer != null) {
    mPlayer.setQuit(true);
synchronized (this) {
      this.notifyAll();
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean leave(UUID playerId){
  MatchPlayer mPlayer=getPlayer(playerId);
  if (mPlayer != null) {
    if (games.isEmpty()) {
      return players.remove(mPlayer);
    }
    mPlayer.setQuit(true);
synchronized (this) {
      this.notifyAll();
    }
    return true;
  }
  return false;
}
Program: 159619
Project: 159619
Buggy source:
@Test public void testCard3(){
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerB,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerB,"String_Node_Str");
  addCounters(1,PhaseStep.UPKEEP,playerA,"String_Node_Str",CounterType.LOYALTY,3);
  activateAbility(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str","String_Node_Str");
  setStopAt(1,PhaseStep.BEGIN_COMBAT);
  execute();
  assertPermanentCount(playerA,"String_Node_Str",1);
  assertPermanentCount(playerA,"String_Node_Str",1);
  assertLife(playerA,23);
  assertLife(playerB,20);
  assertPermanentCount(playerA,"String_Node_Str",0);
  assertPermanentCount(playerB,"String_Node_Str",0);
  assertPermanentCount(playerB,"String_Node_Str",0);
  assertPermanentCount(playerA,"String_Node_Str",1);
  assertPermanentCount(playerA,"String_Node_Str",1);
}

Fixed version (ground truth):
@Test public void testCard3(){
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerB,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerB,"String_Node_Str");
  addCounters(1,PhaseStep.UPKEEP,playerA,"String_Node_Str",CounterType.LOYALTY,3);
  activateAbility(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str","String_Node_Str");
  setStopAt(1,PhaseStep.BEGIN_COMBAT);
  execute();
  assertPermanentCount(playerA,"String_Node_Str",1);
  assertPermanentCount(playerA,"String_Node_Str",1);
  assertLife(playerB,20);
  assertLife(playerA,23);
  assertPermanentCount(playerA,"String_Node_Str",0);
  assertPermanentCount(playerB,"String_Node_Str",0);
  assertPermanentCount(playerB,"String_Node_Str",0);
  assertPermanentCount(playerA,"String_Node_Str",1);
  assertPermanentCount(playerA,"String_Node_Str",1);
}
Program: 159620
Project: 159620
Buggy source:
public void checkTriggers(GameEvent event,Game game){
  for (  TriggeredAbility ability : this.values()) {
    if (ability.isInUseableZone(game,null,true)) {
      MageObject object=getMageObject(event,game,ability);
      if (object != null) {
        if (checkAbilityStillExists(ability,event,object)) {
          if (object instanceof Permanent) {
            ability.setControllerId(((Permanent)object).getControllerId());
          }
          if (ability.checkTrigger(event,game)) {
            UUID controllerId=ability.getControllerId();
            ability.trigger(game,controllerId);
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
public void checkTriggers(GameEvent event,Game game){
  for (  TriggeredAbility ability : this.values()) {
    if (ability.isInUseableZone(game,null,true)) {
      MageObject object=null;
      if (!ability.getZone().equals(Zone.COMMAND) && !game.getState().getZone(ability.getSourceId()).equals(ability.getZone())) {
        object=game.getShortLivingLKI(ability.getSourceId(),ability.getZone());
      }
      if (object == null) {
        object=getMageObject(event,game,ability);
      }
      if (object != null) {
        if (checkAbilityStillExists(ability,event,object)) {
          if (object instanceof Permanent) {
            ability.setControllerId(((Permanent)object).getControllerId());
          }
          if (ability.checkTrigger(event,game)) {
            UUID controllerId=ability.getControllerId();
            ability.trigger(game,controllerId);
          }
        }
      }
    }
  }
}
Program: 159621
Project: 159621
Buggy source:
/** 
 * Remembers object state to be used as Last Known Information.
 * @param objectId
 * @param zone
 * @param object
 */
@Override public void rememberLKI(UUID objectId,Zone zone,MageObject object){
  if (object instanceof Permanent || object instanceof StackObject) {
    MageObject copy=object.copy();
    lki.put(objectId,copy);
    shortLivingLKI.put(objectId,copy);
  }
}

Fixed version (ground truth):
/** 
 * Remembers object state to be used as Last Known Information.
 * @param objectId
 * @param zone
 * @param object
 */
@Override public void rememberLKI(UUID objectId,Zone zone,MageObject object){
  if (object instanceof Permanent || object instanceof StackObject) {
    MageObject copy=object.copy();
    Map<UUID,MageObject> lkiMap=lki.get(zone);
    if (lkiMap != null) {
      lkiMap.put(objectId,copy);
    }
 else {
      HashMap<UUID,MageObject> newMap=new HashMap<UUID,MageObject>();
      newMap.put(objectId,copy);
      lki.put(zone,newMap);
    }
    Map<UUID,MageObject> shortLivingLkiMap=shortLivingLKI.get(zone);
    if (shortLivingLkiMap != null) {
      shortLivingLkiMap.put(objectId,copy);
    }
 else {
      HashMap<UUID,MageObject> newMap=new HashMap<UUID,MageObject>();
      newMap.put(objectId,copy);
      shortLivingLKI.put(zone,newMap);
    }
  }
}
Program: 159622
Project: 159622
Buggy source:
/** 
 * Gets last known information about object in the zone. At the moment doesn't take into account zone (it is expected that it doesn't really matter, if not, then Map<UUID, Map<Zone, Card>> should be used instead). Can return null.
 * @param objectId
 * @param zone
 * @return
 */
@Override public MageObject getLastKnownInformation(UUID objectId,Zone zone){
  MageObject object=lki.get(objectId);
  if (object != null) {
    return object.copy();
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Gets last known information about object in the zone. At the moment doesn't take into account zone (it is expected that it doesn't really matter, if not, then Map<UUID, Map<Zone, Card>> should be used instead). Can return null.
 * @param objectId
 * @param zone
 * @return
 */
@Override public MageObject getLastKnownInformation(UUID objectId,Zone zone){
  Map<UUID,MageObject> lkiMap=lki.get(zone);
  if (lkiMap != null) {
    MageObject object=lkiMap.get(objectId);
    if (object != null) {
      return object.copy();
    }
  }
  return null;
}
Program: 159623
Project: 159623
Buggy source:
@Override public MageObject getShortLivingLKI(UUID objectId,Zone zone){
  MageObject object=shortLivingLKI.get(objectId);
  if (object != null) {
    return object.copy();
  }
  return null;
}

Fixed version (ground truth):
@Override public MageObject getShortLivingLKI(UUID objectId,Zone zone){
  Map<UUID,MageObject> shortLivingLkiMap=shortLivingLKI.get(zone);
  if (shortLivingLkiMap != null) {
    MageObject object=shortLivingLkiMap.get(objectId);
    if (object != null) {
      return object.copy();
    }
  }
  return null;
}
Program: 159624
Project: 159624
Buggy source:
@Override public boolean moveToZone(Zone toZone,UUID sourceId,Game game,boolean flag,ArrayList<UUID> appliedEffects){
  Zone fromZone=game.getState().getZone(objectId);
  Player controller=game.getPlayer(controllerId);
  if (controller != null && controller.removeFromBattlefield(this,game)) {
    ZoneChangeEvent event=new ZoneChangeEvent(this,sourceId,controllerId,fromZone,toZone,appliedEffects);
    if (!game.replaceEvent(event)) {
      Player owner=game.getPlayer(ownerId);
      game.rememberLKI(objectId,Zone.BATTLEFIELD,this);
      if (owner != null) {
switch (event.getToZone()) {
case GRAVEYARD:
          owner.putInGraveyard(card,game,!flag);
        break;
case HAND:
      owner.getHand().add(card);
    break;
case EXILED:
  game.getExile().getPermanentExile().add(card);
break;
case COMMAND:
game.addCommander(new Commander(card));
break;
case LIBRARY:
if (flag) owner.getLibrary().putOnTop(card,game);
 else owner.getLibrary().putOnBottom(card,game);
break;
case BATTLEFIELD:
break;
}
game.setZone(objectId,event.getToZone());
game.fireEvent(event);
if (event.getFromZone().equals(Zone.BATTLEFIELD)) {
game.resetForSourceId(getId());
game.applyEffects();
}
return game.getState().getZone(objectId) == toZone;
}
}
}
return false;
}

Fixed version (ground truth):
@Override public boolean moveToZone(Zone toZone,UUID sourceId,Game game,boolean flag,ArrayList<UUID> appliedEffects){
  Zone fromZone=game.getState().getZone(objectId);
  Player controller=game.getPlayer(controllerId);
  if (controller != null && controller.removeFromBattlefield(this,game)) {
    ZoneChangeEvent event=new ZoneChangeEvent(this,sourceId,controllerId,fromZone,toZone,appliedEffects);
    if (!game.replaceEvent(event)) {
      Player owner=game.getPlayer(ownerId);
      game.rememberLKI(objectId,Zone.BATTLEFIELD,this);
      if (owner != null) {
        this.setControllerId(ownerId);
switch (event.getToZone()) {
case GRAVEYARD:
          owner.putInGraveyard(card,game,!flag);
        break;
case HAND:
      owner.getHand().add(card);
    break;
case EXILED:
  game.getExile().getPermanentExile().add(card);
break;
case COMMAND:
game.addCommander(new Commander(card));
break;
case LIBRARY:
if (flag) {
owner.getLibrary().putOnTop(card,game);
}
 else {
owner.getLibrary().putOnBottom(card,game);
}
break;
case BATTLEFIELD:
break;
}
game.setZone(objectId,event.getToZone());
game.fireEvent(event);
if (event.getFromZone().equals(Zone.BATTLEFIELD)) {
game.resetForSourceId(getId());
game.applyEffects();
}
return game.getState().getZone(objectId) == toZone;
}
}
}
return false;
}
Program: 159625
Project: 159625
Buggy source:
@Override public boolean canChoose(UUID sourceId,UUID sourceControllerId,Game game){
  int remainingTargets=this.minNumberOfTargets - targets.size();
  if (remainingTargets == 0)   return true;
  int count=0;
  MageObject targetSource=game.getObject(sourceId);
  PlayerDamagedBySourceWatcher watcher=(PlayerDamagedBySourceWatcher)game.getState().getWatchers().get("String_Node_Str",sourceControllerId);
  for (  Permanent permanent : game.getBattlefield().getActivePermanents(filter,sourceControllerId,sourceId,game)) {
    if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource,sourceControllerId,game) && watcher != null && watcher.damageSources.contains(permanent.getId())) {
      count++;
      if (count >= remainingTargets)       return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean canChoose(UUID sourceId,UUID sourceControllerId,Game game){
  int remainingTargets=this.minNumberOfTargets - targets.size();
  if (remainingTargets == 0) {
    return true;
  }
  int count=0;
  MageObject targetSource=game.getObject(sourceId);
  PlayerDamagedBySourceWatcher watcher=(PlayerDamagedBySourceWatcher)game.getState().getWatchers().get("String_Node_Str",sourceControllerId);
  for (  Permanent permanent : game.getBattlefield().getActivePermanents(filter,sourceControllerId,sourceId,game)) {
    if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource,sourceControllerId,game) && watcher != null && watcher.damageSources.contains(permanent.getId())) {
      count++;
      if (count >= remainingTargets) {
        return true;
      }
    }
  }
  return false;
}
Program: 159626
Project: 159626
Buggy source:
@Override public boolean canChoose(UUID sourceId,UUID sourceControllerId,Game game){
  int remainingTargets=this.minNumberOfTargets - targets.size();
  if (remainingTargets == 0)   return true;
  int count=0;
  MageObject targetSource=game.getObject(sourceId);
  PlayerDamagedBySourceWatcher watcher=(PlayerDamagedBySourceWatcher)game.getState().getWatchers().get("String_Node_Str",sourceControllerId);
  for (  Permanent permanent : game.getBattlefield().getActivePermanents(filter,sourceControllerId,sourceId,game)) {
    if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource,sourceControllerId,game) && watcher != null && watcher.damageSources.contains(permanent.getId())) {
      count++;
      if (count >= remainingTargets)       return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean canChoose(UUID sourceId,UUID sourceControllerId,Game game){
  int remainingTargets=this.minNumberOfTargets - targets.size();
  if (remainingTargets == 0) {
    return true;
  }
  int count=0;
  MageObject targetSource=game.getObject(sourceId);
  PlayerDamagedBySourceWatcher watcher=(PlayerDamagedBySourceWatcher)game.getState().getWatchers().get("String_Node_Str",sourceControllerId);
  for (  Permanent permanent : game.getBattlefield().getActivePermanents(filter,sourceControllerId,sourceId,game)) {
    if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource,sourceControllerId,game) && watcher != null && watcher.damageSources.contains(permanent.getId())) {
      count++;
      if (count >= remainingTargets) {
        return true;
      }
    }
  }
  return false;
}
Program: 159627
Project: 159627
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.SPELL_CAST && game.getOpponents(controllerId).contains(event.getPlayerId())) {
    Spell spell=game.getStack().getSpell(event.getTargetId());
    if (spell != null && filter.match(spell,game)) {
      if (setTargetPointerPlayer) {
        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.SPELL_CAST && game.getOpponents(controllerId).contains(event.getPlayerId())) {
    Spell spell=game.getStack().getSpell(event.getTargetId());
    if (spell != null && filter.match(spell,game)) {
      if (setTargetPointerPlayer) {
        for (        Effect effect : this.getEffects()) {
          effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
        }
      }
      return true;
    }
  }
  return false;
}
Program: 159628
Project: 159628
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.SPELL_CAST) {
    Spell spell=game.getStack().getSpell(event.getTargetId());
    FirstSpellCastThisTurnWatcher watcher=(FirstSpellCastThisTurnWatcher)game.getState().getWatchers().get("String_Node_Str",this.getSourceId());
    if (spell != null && watcher != null && watcher.conditionMet()) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getType() == GameEvent.EventType.SPELL_CAST) {
    Spell spell=game.getStack().getSpell(event.getTargetId());
    FirstSpellCastThisTurnWatcher watcher=(FirstSpellCastThisTurnWatcher)game.getState().getWatchers().get("String_Node_Str",this.getSourceId());
    if (spell != null && watcher != null && watcher.conditionMet()) {
      this.getEffects().get(0).setTargetPointer(new FixedTarget(spell.getSourceId()));
      return true;
    }
  }
  return false;
}