nus-yam/ex-repair huggingface dataset:
Program: 164154
Project: 164154
Buggy source:
@Override public void activate(){
  Char target=Actor.findChar(pos);
  if (target == null) {
    for (    Char ch : Actor.chars()) {
      Ballistica bolt=new Ballistica(pos,ch.pos,Ballistica.PROJECTILE);
      if (bolt.collisionPos == ch.pos && (target == null || Level.distance(pos,ch.pos) < Level.distance(pos,target.pos))) {
        target=ch;
      }
    }
  }
  if (target != null) {
    final Char finalTarget=target;
    final GrimTrap trap=this;
    MagicMissile.shadow(target.sprite.parent,pos,target.pos,new Callback(){
      @Override public void call(){
        if (finalTarget == Dungeon.hero) {
          if (((float)finalTarget.HP / finalTarget.HT) >= 0.9f) {
            finalTarget.damage((finalTarget.HP - 1),trap);
          }
 else {
            finalTarget.damage(finalTarget.HP,trap);
          }
          Sample.INSTANCE.play(Assets.SND_CURSED);
          if (!finalTarget.isAlive()) {
            Dungeon.fail(GrimTrap.class);
            GLog.n(Messages.get(GrimTrap.class,"String_Node_Str"));
          }
        }
 else {
          finalTarget.damage(finalTarget.HP,this);
          Sample.INSTANCE.play(Assets.SND_BURNING);
        }
        finalTarget.sprite.emitter().burst(ShadowParticle.UP,10);
        if (!finalTarget.isAlive())         finalTarget.next();
      }
    }
);
  }
 else {
    CellEmitter.get(pos).burst(ShadowParticle.UP,10);
    Sample.INSTANCE.play(Assets.SND_BURNING);
  }
}

Fixed version (ground truth):
@Override public void activate(){
  Char target=Actor.findChar(pos);
  if (target == null) {
    for (    Char ch : Actor.chars()) {
      Ballistica bolt=new Ballistica(pos,ch.pos,Ballistica.PROJECTILE);
      if (bolt.collisionPos == ch.pos && (target == null || Level.distance(pos,ch.pos) < Level.distance(pos,target.pos))) {
        target=ch;
      }
    }
  }
  if (target != null) {
    final Char finalTarget=target;
    final GrimTrap trap=this;
    MagicMissile.shadow(target.sprite.parent,pos,target.pos,new Callback(){
      @Override public void call(){
        if (!finalTarget.isAlive())         return;
        if (finalTarget == Dungeon.hero) {
          if (((float)finalTarget.HP / finalTarget.HT) >= 0.9f) {
            finalTarget.damage((finalTarget.HP - 1),trap);
          }
 else {
            finalTarget.damage(finalTarget.HP,trap);
          }
          Sample.INSTANCE.play(Assets.SND_CURSED);
          if (!finalTarget.isAlive()) {
            Dungeon.fail(GrimTrap.class);
            GLog.n(Messages.get(GrimTrap.class,"String_Node_Str"));
          }
        }
 else {
          finalTarget.damage(finalTarget.HP,this);
          Sample.INSTANCE.play(Assets.SND_BURNING);
        }
        finalTarget.sprite.emitter().burst(ShadowParticle.UP,10);
        if (!finalTarget.isAlive())         finalTarget.next();
      }
    }
);
  }
 else {
    CellEmitter.get(pos).burst(ShadowParticle.UP,10);
    Sample.INSTANCE.play(Assets.SND_BURNING);
  }
}
Program: 164155
Project: 164155
Buggy source:
@Override public int STRReq(int lvl){
  lvl=Math.max(0,lvl);
  return (7 + armorTier * 2) - (int)(Math.sqrt(8 * lvl + 1) - 1) / 2;
}

Fixed version (ground truth):
@Override public int STRReq(int lvl){
  lvl=Math.max(0,lvl);
  int effectiveTier=armorTier;
  if (glyph != null)   effectiveTier+=glyph.tierSTRAdjust();
  effectiveTier=Math.max(0,effectiveTier);
  return (8 + effectiveTier * 2) - (int)(Math.sqrt(8 * lvl + 1) - 1) / 2;
}
Program: 164156
Project: 164156
Buggy source:
@Override public int DR(){
  return armorTier * (2 + level() + (glyph == null ? 0 : 1));
}

Fixed version (ground truth):
@Override public int DR(){
  int effectiveTier=armorTier;
  if (glyph != null)   effectiveTier+=glyph.tierDRAdjust();
  effectiveTier=Math.max(0,effectiveTier);
  return effectiveTier * (2 + level());
}
Program: 164157
Project: 164157
Buggy source:
protected int throwPos(Hero user,int dst){
  return new Ballistica(user.pos,dst,Ballistica.PROJECTILE).collisionPos;
}

Fixed version (ground truth):
public int throwPos(Hero user,int dst){
  return new Ballistica(user.pos,dst,Ballistica.PROJECTILE).collisionPos;
}
Program: 164158
Project: 164158
Buggy source:
@Override protected int throwPos(Hero user,int dst){
  int defaultPos=super.throwPos(user,dst);
  if (defaultPos == dst)   return dst;
 else   if (hasEnchant(Projecting.class)) {
    Ballistica ProjectingTrajectory=new Ballistica(user.pos,dst,Ballistica.STOP_TARGET);
    if (ProjectingTrajectory.dist <= 4)     return ProjectingTrajectory.collisionPos;
 else     return super.throwPos(user,dst);
  }
 else {
    return super.throwPos(user,dst);
  }
}

Fixed version (ground truth):
@Override public int throwPos(Hero user,int dst){
  if (hasEnchant(Projecting.class) && !Level.solid[dst] && Level.distance(user.pos,dst) <= 4) {
    return dst;
  }
 else {
    return super.throwPos(user,dst);
  }
}
Program: 164159
Project: 164159
Buggy source:
public static int autoAim(Char target){
  if (new Ballistica(Dungeon.hero.pos,target.pos,Ballistica.PROJECTILE).collisionPos == target.pos) {
    return target.pos;
  }
  for (  int i : Level.NEIGHBOURS9DIST2) {
    if (new Ballistica(Dungeon.hero.pos,target.pos + i,Ballistica.PROJECTILE).collisionPos == target.pos) {
      return target.pos + i;
    }
  }
  return -1;
}

Fixed version (ground truth):
public static int autoAim(Char target,Item item){
  if (item.throwPos(Dungeon.hero,target.pos) == target.pos) {
    return target.pos;
  }
  for (  int i : Level.NEIGHBOURS9DIST2) {
    if (item.throwPos(Dungeon.hero,target.pos) == target.pos) {
      return target.pos + i;
    }
  }
  return -1;
}
Program: 164160
Project: 164160
Buggy source:
@Override protected void createChildren(){
  super.createChildren();
  slot=new ItemSlot(){
    @Override protected void onClick(){
      if (targeting) {
        int cell=autoAim(lastTarget);
        if (cell != -1) {
          GameScene.handleCell(cell);
        }
 else {
          GameScene.handleCell(lastTarget.pos);
        }
      }
 else {
        Item item=select(slotNum);
        if (item.usesTargeting)         useTargeting();
        item.execute(Dungeon.hero);
      }
    }
    @Override protected boolean onLongClick(){
      return QuickSlotButton.this.onLongClick();
    }
    @Override protected void onTouchDown(){
      icon.lightness(0.7f);
    }
    @Override protected void onTouchUp(){
      icon.resetColor();
    }
  }
;
  slot.showParams(true,false,true);
  add(slot);
  crossB=Icons.TARGET.get();
  crossB.visible=false;
  add(crossB);
  crossM=new Image();
  crossM.copy(crossB);
}

Fixed version (ground truth):
@Override protected void createChildren(){
  super.createChildren();
  slot=new ItemSlot(){
    @Override protected void onClick(){
      if (targeting) {
        int cell=autoAim(lastTarget,select(slotNum));
        if (cell != -1) {
          GameScene.handleCell(cell);
        }
 else {
          GameScene.handleCell(lastTarget.pos);
        }
      }
 else {
        Item item=select(slotNum);
        if (item.usesTargeting)         useTargeting();
        item.execute(Dungeon.hero);
      }
    }
    @Override protected boolean onLongClick(){
      return QuickSlotButton.this.onLongClick();
    }
    @Override protected void onTouchDown(){
      icon.lightness(0.7f);
    }
    @Override protected void onTouchUp(){
      icon.resetColor();
    }
  }
;
  slot.showParams(true,false,true);
  add(slot);
  crossB=Icons.TARGET.get();
  crossB.visible=false;
  add(crossB);
  crossM=new Image();
  crossM.copy(crossB);
}
Program: 164161
Project: 164161
Buggy source:
@Override public boolean doUnequip(Hero hero,boolean collect,boolean single){
  if (super.doUnequip(hero,collect,single)) {
    hero.HT-=level() * 5;
    hero.HP=Math.min(hero.HP,hero.HT);
    return false;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
@Override public boolean doUnequip(Hero hero,boolean collect,boolean single){
  if (super.doUnequip(hero,collect,single)) {
    hero.HT-=level() * 5;
    hero.HP=Math.min(hero.HP,hero.HT);
    return true;
  }
 else {
    return false;
  }
}
Program: 164162
Project: 164162
Buggy source:
private static Item prize(Level level){
  Armor prize=Generator.randomArmor((Dungeon.depth / 5) + 1);
  if (!prize.cursed) {
    prize.upgrade();
    if (prize.glyph != null) {
      prize.cursed=prize.cursedKnown=true;
      prize.inscribe(Armor.Glyph.randomCurse());
    }
  }
  return prize;
}

Fixed version (ground truth):
private static Item prize(Level level){
  Armor prize=Generator.randomArmor((Dungeon.depth / 5) + 1);
  if (!prize.cursed) {
    prize.upgrade();
    if (prize.glyph == null) {
      prize.cursed=prize.cursedKnown=true;
      prize.inscribe(Armor.Glyph.randomCurse());
    }
  }
  return prize;
}
Program: 164163
Project: 164163
Buggy source:
@Override public int attackProc(Char enemy,int damage){
  KindOfWeapon wep=rangedWeapon != null ? rangedWeapon : belongings.weapon;
  if (wep != null)   wep.proc(this,enemy,damage);
switch (subClass) {
case SNIPER:
    if (rangedWeapon != null) {
      Buff.prolong(this,SnipersMark.class,attackDelay() * 1.1f).object=enemy.id();
    }
  break;
default :
}
return damage;
}

Fixed version (ground truth):
@Override public int attackProc(Char enemy,int damage){
  KindOfWeapon wep=rangedWeapon != null ? rangedWeapon : belongings.weapon;
  if (wep != null)   damage=wep.proc(this,enemy,damage);
switch (subClass) {
case SNIPER:
    if (rangedWeapon != null) {
      Buff.prolong(this,SnipersMark.class,attackDelay() * 1.1f).object=enemy.id();
    }
  break;
default :
}
return damage;
}
Program: 164164
Project: 164164
Buggy source:
@Override public int attackProc(Char enemy,int damage){
  weapon.proc(this,enemy,damage);
  return damage;
}

Fixed version (ground truth):
@Override public int attackProc(Char enemy,int damage){
  return weapon.proc(this,enemy,damage);
}
Program: 164165
Project: 164165
Buggy source:
@Override public int proc(Weapon weapon,Char attacker,Char defender,int damage){
  int level=Math.max(0,weapon.level());
  if (Random.Int(100) < (50 + level)) {
    return weapon.max() - defender.dr() / 2;
  }
 else {
    return weapon.min() - defender.dr() / 2;
  }
}

Fixed version (ground truth):
@Override public int proc(Weapon weapon,Char attacker,Char defender,int damage){
  int level=Math.max(0,weapon.level());
  if (Random.Int(100) < (50 + level)) {
    int exStr=0;
    if (attacker == Dungeon.hero)     exStr=Math.max(0,Dungeon.hero.STR() - weapon.STRReq());
    damage=weapon.max() + exStr - Random.IntRange(0,defender.dr());
  }
 else {
    damage=weapon.min() - Random.IntRange(0,defender.dr());
  }
  return Math.max(0,damage);
}
Program: 164166
Project: 164166
Buggy source:
public void charge(){
  if (charge < target.HT) {
    charge+=(Math.round((target.HT - charge) * (.01 + level() * 0.01)));
    updateQuickslot();
  }
}

Fixed version (ground truth):
public void charge(){
  if (level() > 0 && charge < target.HT) {
    charge+=(Math.round((target.HT - charge) * (.01 + level() * 0.01)));
    updateQuickslot();
  }
}
Program: 164167
Project: 164167
Buggy source:
public void affixSeal(BrokenSeal seal){
  this.seal=seal;
  if (seal.level() > 0) {
    upgrade(glyph != null);
  }
  if (isEquipped(Dungeon.hero)) {
    Buff.affect(Dungeon.hero,BrokenSeal.WarriorShield.class).setArmor(this);
  }
}

Fixed version (ground truth):
public void affixSeal(BrokenSeal seal){
  this.seal=seal;
  if (seal.level() > 0) {
    level(level() + 1);
  }
  if (isEquipped(Dungeon.hero)) {
    Buff.affect(Dungeon.hero,BrokenSeal.WarriorShield.class).setArmor(this);
  }
}
Program: 164168
Project: 164168
Buggy source:
@Override public void damage(int dmg,Object src){
  LockedFloor lock=Dungeon.hero.buff(LockedFloor.class);
  if (lock != null) {
    int multiple=HP > HT / 2 ? 1 : 4;
    lock.addTime(dmg * multiple);
  }
  if (dmg >= HP) {
    if (state == SLEEPING) {
      state=WANDERING;
    }
    ((PrisonBossLevel)Dungeon.level).progress();
    return;
  }
  int beforeHitHP=HP;
  super.damage(dmg,src);
  int hpBracket=HP > HT / 2 ? 12 : 20;
  if (beforeHitHP > HT / 2 && HP <= HT / 2) {
    HP=(HT / 2) - 1;
    yell(Messages.get(this,"String_Node_Str"));
    ((PrisonBossLevel)Dungeon.level).progress();
    BossHealthBar.bleed(true);
  }
 else   if (beforeHitHP / hpBracket != HP / hpBracket) {
    jump();
  }
}

Fixed version (ground truth):
@Override public void damage(int dmg,Object src){
  int beforeHitHP=HP;
  super.damage(dmg,src);
  dmg=beforeHitHP - HP;
  LockedFloor lock=Dungeon.hero.buff(LockedFloor.class);
  if (lock != null) {
    int multiple=beforeHitHP > HT / 2 ? 1 : 4;
    lock.addTime(dmg * multiple);
  }
  if (HP == 0 && beforeHitHP <= HT / 2) {
    ((PrisonBossLevel)Dungeon.level).progress();
    return;
  }
  int hpBracket=beforeHitHP > HT / 2 ? 12 : 20;
  if (beforeHitHP > HT / 2 && HP <= HT / 2) {
    HP=(HT / 2) - 1;
    yell(Messages.get(this,"String_Node_Str"));
    ((PrisonBossLevel)Dungeon.level).progress();
    BossHealthBar.bleed(true);
  }
 else   if (beforeHitHP / hpBracket != HP / hpBracket) {
    jump();
  }
}
Program: 164169
Project: 164169
Buggy source:
@Override public void press(int cell,Char ch){
  super.press(cell,ch);
  if (ch == Dungeon.hero) {
    if (state == State.START && ((Room)new Room().set(2,25,8,32)).inside(cell)) {
      progress();
    }
 else     if (state == State.MAZE && ((Room)new Room().set(4,1,7,4)).inside(cell)) {
      progress();
    }
  }
}

Fixed version (ground truth):
@Override public void press(int cell,Char ch){
  super.press(cell,ch);
  if (ch == Dungeon.hero) {
    if (state == State.START && ((Room)new Room().set(2,25,8,32)).inside(cell)) {
      progress();
    }
 else     if (state == State.MAZE && ((Room)new Room().set(4,0,7,4)).inside(cell)) {
      progress();
    }
  }
}
Program: 164170
Project: 164170
Buggy source:
@Override public boolean act(){
  if (target.isAlive()) {
    int maxDmg=3 + Math.round(4 * target.HP / (float)target.HT);
    target.damage(Random.Int(1,maxDmg),this);
    Buff.detach(target,Chill.class);
    if (target instanceof Hero) {
      Hero hero=(Hero)target;
      Item item=hero.belongings.randomUnequipped();
      if (item instanceof Scroll) {
        item=item.detach(hero.belongings.backpack);
        GLog.w(Messages.get(this,"String_Node_Str",item.toString()));
        Heap.burnFX(hero.pos);
      }
 else       if (item instanceof MysteryMeat) {
        item=item.detach(hero.belongings.backpack);
        ChargrilledMeat steak=new ChargrilledMeat();
        if (!steak.collect(hero.belongings.backpack)) {
          Dungeon.level.drop(steak,hero.pos).sprite.drop();
        }
        GLog.w(Messages.get(this,"String_Node_Str",item.toString()));
        Heap.burnFX(hero.pos);
      }
    }
 else     if (target instanceof Thief && ((Thief)target).item instanceof Scroll) {
      ((Thief)target).item=null;
      target.sprite.emitter().burst(ElmoParticle.FACTORY,6);
    }
  }
 else {
    detach();
  }
  if (Level.flamable[target.pos]) {
    GameScene.add(Blob.seed(target.pos,4,Fire.class));
  }
  spend(TICK);
  left-=TICK;
  if (left <= 0 || (Level.water[target.pos] && !target.flying)) {
    detach();
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean act(){
  if (target.isAlive()) {
    int maxDmg=3 + Math.round(4 * target.HP / (float)target.HT);
    target.damage(Random.Int(1,maxDmg),this);
    Buff.detach(target,Chill.class);
    if (target instanceof Hero) {
      Hero hero=(Hero)target;
      Item item=hero.belongings.randomUnequipped();
      if (item instanceof Scroll) {
        item=item.detach(hero.belongings.backpack);
        GLog.w(Messages.get(this,"String_Node_Str",Messages.capitalize(item.toString())));
        Heap.burnFX(hero.pos);
      }
 else       if (item instanceof MysteryMeat) {
        item=item.detach(hero.belongings.backpack);
        ChargrilledMeat steak=new ChargrilledMeat();
        if (!steak.collect(hero.belongings.backpack)) {
          Dungeon.level.drop(steak,hero.pos).sprite.drop();
        }
        GLog.w(Messages.get(this,"String_Node_Str",item.toString()));
        Heap.burnFX(hero.pos);
      }
    }
 else     if (target instanceof Thief && ((Thief)target).item instanceof Scroll) {
      ((Thief)target).item=null;
      target.sprite.emitter().burst(ElmoParticle.FACTORY,6);
    }
  }
 else {
    detach();
  }
  if (Level.flamable[target.pos]) {
    GameScene.add(Blob.seed(target.pos,4,Fire.class));
  }
  spend(TICK);
  left-=TICK;
  if (left <= 0 || (Level.water[target.pos] && !target.flying)) {
    detach();
  }
  return true;
}
Program: 164171
Project: 164171
Buggy source:
public void damage(int dmg,Object src){
  if (HP <= 0 || dmg < 0) {
    return;
  }
  if (this.buff(Frost.class) != null) {
    Buff.detach(this,Frost.class);
  }
  if (this.buff(MagicalSleep.class) != null) {
    Buff.detach(this,MagicalSleep.class);
  }
  Class<?> srcClass=src.getClass();
  if (immunities().contains(srcClass)) {
    dmg=0;
  }
 else   if (resistances().contains(srcClass)) {
    dmg=Random.IntRange(0,dmg);
  }
  if (buff(Paralysis.class) != null) {
    if (Random.Int(dmg) >= Random.Int(HP)) {
      Buff.detach(this,Paralysis.class);
      if (Dungeon.visible[pos]) {
        GLog.i(Messages.get(Char.class,"String_Node_Str",name));
      }
    }
  }
  if (src instanceof Hunger || SHLD == 0) {
    HP-=dmg;
  }
 else   if (SHLD >= dmg) {
    SHLD-=dmg;
  }
 else   if (SHLD > 0) {
    HP-=(dmg - SHLD);
    SHLD=0;
  }
  if (dmg > 0 || src instanceof Char) {
    sprite.showStatus(HP > HT / 2 ? CharSprite.WARNING : CharSprite.NEGATIVE,Integer.toString(dmg));
  }
  if (HP < 0)   HP=0;
  if (!isAlive()) {
    die(src);
  }
}

Fixed version (ground truth):
public void damage(int dmg,Object src){
  if (!isAlive() || dmg < 0) {
    return;
  }
  if (this.buff(Frost.class) != null) {
    Buff.detach(this,Frost.class);
  }
  if (this.buff(MagicalSleep.class) != null) {
    Buff.detach(this,MagicalSleep.class);
  }
  Class<?> srcClass=src.getClass();
  if (immunities().contains(srcClass)) {
    dmg=0;
  }
 else   if (resistances().contains(srcClass)) {
    dmg=Random.IntRange(0,dmg);
  }
  if (buff(Paralysis.class) != null) {
    if (Random.Int(dmg) >= Random.Int(HP)) {
      Buff.detach(this,Paralysis.class);
      if (Dungeon.visible[pos]) {
        GLog.i(Messages.get(Char.class,"String_Node_Str",name));
      }
    }
  }
  if (src instanceof Hunger || SHLD == 0) {
    HP-=dmg;
  }
 else   if (SHLD >= dmg) {
    SHLD-=dmg;
  }
 else   if (SHLD > 0) {
    HP-=(dmg - SHLD);
    SHLD=0;
  }
  if (dmg > 0 || src instanceof Char) {
    sprite.showStatus(HP > HT / 2 ? CharSprite.WARNING : CharSprite.NEGATIVE,Integer.toString(dmg));
  }
  if (HP < 0)   HP=0;
  if (!isAlive()) {
    die(src);
  }
}
Program: 164172
Project: 164172
Buggy source:
public static Item get(){
  if (depth == -1) {
    try {
      InputStream input=Game.instance.openFileInput(BONES_FILE);
      Bundle bundle=Bundle.read(input);
      input.close();
      depth=bundle.getInt(LEVEL);
      item=(Item)bundle.get(ITEM);
      return get();
    }
 catch (    Exception e) {
      return null;
    }
  }
 else {
    if (depth == Dungeon.depth && Dungeon.challenges == 0) {
      Game.instance.deleteFile(BONES_FILE);
      depth=0;
      if (item instanceof Artifact) {
        if (Generator.removeArtifact((Artifact)item)) {
          try {
            Artifact artifact=(Artifact)item.getClass().newInstance();
            artifact.cursed=true;
            artifact.cursedKnown=true;
            artifact.transferUpgrade(Math.min(item.visiblyUpgraded(),1 + ((Dungeon.depth * 3) / 10)));
            return item;
          }
 catch (          Exception e) {
            return new Gold(item.price());
          }
        }
 else {
          return new Gold(item.price());
        }
      }
      if (item.isUpgradable()) {
        item.cursed=true;
        item.cursedKnown=true;
        if (item.isUpgradable()) {
          int lvl=1 + ((Dungeon.depth * 3) / 10);
          if (lvl < item.level()) {
            item.degrade(item.level() - lvl);
          }
          item.levelKnown=false;
        }
      }
      item.reset();
      return item;
    }
 else {
      return null;
    }
  }
}

Fixed version (ground truth):
public static Item get(){
  if (depth == -1) {
    try {
      InputStream input=Game.instance.openFileInput(BONES_FILE);
      Bundle bundle=Bundle.read(input);
      input.close();
      depth=bundle.getInt(LEVEL);
      item=(Item)bundle.get(ITEM);
      return get();
    }
 catch (    Exception e) {
      return null;
    }
  }
 else {
    if (depth == Dungeon.depth && Dungeon.challenges == 0) {
      Game.instance.deleteFile(BONES_FILE);
      depth=0;
      if (item instanceof Artifact) {
        if (Generator.removeArtifact((Artifact)item)) {
          try {
            Artifact artifact=(Artifact)item.getClass().newInstance();
            artifact.cursed=true;
            artifact.cursedKnown=true;
            artifact.transferUpgrade(Math.min(item.visiblyUpgraded(),1 + ((Dungeon.depth * 3) / 10)));
            return item;
          }
 catch (          Exception e) {
            return new Gold(item.price());
          }
        }
 else {
          return new Gold(item.price());
        }
      }
      if (item.isUpgradable() || item instanceof Artifact) {
        item.cursed=true;
        item.cursedKnown=true;
        if (item.isUpgradable()) {
          int lvl=1 + ((Dungeon.depth * 3) / 10);
          if (lvl < item.level()) {
            item.degrade(item.level() - lvl);
          }
          item.levelKnown=false;
        }
      }
      item.reset();
      return item;
    }
 else {
      return null;
    }
  }
}
Program: 164173
Project: 164173
Buggy source:
@Override public void execute(Hero hero,String action){
  super.execute(hero,action);
  if (action.equals(AC_SCRY)) {
    if (!isEquipped(hero))     GLog.i(Messages.get(Artifact.class,"String_Node_Str"));
 else     if (charge != chargeCap)     GLog.i(Messages.get(this,"String_Node_Str"));
 else {
      hero.sprite.operate(hero.pos);
      hero.busy();
      Sample.INSTANCE.play(Assets.SND_BEACON);
      charge=0;
      for (int i=0; i < Level.LENGTH; i++) {
        int terr=Dungeon.level.map[i];
        if ((Terrain.flags[terr] & Terrain.SECRET) != 0) {
          GameScene.updateMap(i);
          if (Dungeon.visible[i]) {
            GameScene.discoverTile(i,terr);
          }
        }
      }
      GLog.p(Messages.get(this,"String_Node_Str"));
      Buff.affect(hero,Awareness.class,Awareness.DURATION);
      Dungeon.observe();
    }
  }
}

Fixed version (ground truth):
@Override public void execute(Hero hero,String action){
  super.execute(hero,action);
  if (action.equals(AC_SCRY)) {
    if (!isEquipped(hero))     GLog.i(Messages.get(Artifact.class,"String_Node_Str"));
 else     if (charge != chargeCap)     GLog.i(Messages.get(this,"String_Node_Str"));
 else {
      hero.sprite.operate(hero.pos);
      hero.busy();
      Sample.INSTANCE.play(Assets.SND_BEACON);
      charge=0;
      for (int i=0; i < Level.LENGTH; i++) {
        int terr=Dungeon.level.map[i];
        if ((Terrain.flags[terr] & Terrain.SECRET) != 0) {
          GameScene.updateMap(i);
          if (Dungeon.visible[i]) {
            GameScene.discoverTile(i,terr);
          }
        }
      }
      GLog.p(Messages.get(this,"String_Node_Str"));
      updateQuickslot();
      Buff.affect(hero,Awareness.class,Awareness.DURATION);
      Dungeon.observe();
    }
  }
}
Program: 164174
Project: 164174
Buggy source:
@Override public boolean doPickUp(Hero hero){
  if (super.doPickUp(hero)) {
    if (!Statistics.amuletObtained) {
      Statistics.amuletObtained=true;
      Badges.validateVictory();
      hero.spend(-TIME_TO_PICK_UP);
      showAmuletScene(true);
    }
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
@Override public boolean doPickUp(Hero hero){
  if (super.doPickUp(hero)) {
    if (!Statistics.amuletObtained) {
      Statistics.amuletObtained=true;
      Badges.validateVictory();
      hero.spend(-TIME_TO_PICK_UP);
      Actor.addDelayed(new Actor(){
        @Override protected boolean act(){
          Actor.remove(this);
          showAmuletScene(true);
          return false;
        }
      }
,-5);
    }
    return true;
  }
 else {
    return false;
  }
}
Program: 164175
Project: 164175
Buggy source:
public void affixSeal(BrokenSeal sigil){
  this.seal=true;
  if (sigil.level() > 0) {
    upgrade(glyph != null);
  }
  if (isEquipped(Dungeon.hero)) {
    Buff.affect(Dungeon.hero,BrokenSeal.WarriorShield.class).setArmor(this);
  }
}

Fixed version (ground truth):
public void affixSeal(BrokenSeal seal){
  this.seal=true;
  if (seal.level() > 0) {
    upgrade(glyph != null);
  }
  if (isEquipped(Dungeon.hero)) {
    Buff.affect(Dungeon.hero,BrokenSeal.WarriorShield.class).setArmor(this);
  }
}
Program: 164176
Project: 164176
Buggy source:
public static ClassArmor upgrade(Hero owner,Armor armor){
  ClassArmor classArmor=null;
switch (owner.heroClass) {
case WARRIOR:
    classArmor=new WarriorArmor();
  break;
case ROGUE:
classArmor=new RogueArmor();
break;
case MAGE:
classArmor=new MageArmor();
break;
case HUNTRESS:
classArmor=new HuntressArmor();
break;
}
classArmor.STR=armor.STR;
classArmor.DR=armor.DR();
classArmor.inscribe(armor.glyph);
return classArmor;
}

Fixed version (ground truth):
public static ClassArmor upgrade(Hero owner,Armor armor){
  ClassArmor classArmor=null;
switch (owner.heroClass) {
case WARRIOR:
    classArmor=new WarriorArmor();
  classArmor.seal=armor.seal;
if (armor.seal && armor.isEquipped(owner)) {
  Buff.affect(Dungeon.hero,BrokenSeal.WarriorShield.class).setArmor(classArmor);
}
break;
case ROGUE:
classArmor=new RogueArmor();
break;
case MAGE:
classArmor=new MageArmor();
break;
case HUNTRESS:
classArmor=new HuntressArmor();
break;
}
classArmor.STR=armor.STR;
classArmor.DR=armor.DR();
classArmor.inscribe(armor.glyph);
return classArmor;
}
Program: 164177
Project: 164177
Buggy source:
public static Item get(){
  if (depth == -1) {
    try {
      InputStream input=Game.instance.openFileInput(BONES_FILE);
      Bundle bundle=Bundle.read(input);
      input.close();
      depth=bundle.getInt(LEVEL);
      item=(Item)bundle.get(ITEM);
      return get();
    }
 catch (    Exception e) {
      return null;
    }
  }
 else {
    if (depth == Dungeon.depth && Dungeon.challenges == 0) {
      Game.instance.deleteFile(BONES_FILE);
      depth=0;
      if (item instanceof Artifact) {
        if (Generator.removeArtifact((Artifact)item)) {
          try {
            Artifact artifact=(Artifact)item.getClass().newInstance();
            artifact.cursed=true;
            artifact.cursedKnown=true;
            artifact.transferUpgrade(Math.min(item.visiblyUpgraded(),1 + ((Dungeon.depth * 3) / 10)));
            return item;
          }
 catch (          Exception e) {
            return new Gold(item.price());
          }
        }
 else {
          return new Gold(item.price());
        }
      }
      if (item.isUpgradable() || item instanceof Artifact) {
        item.cursed=true;
        item.cursedKnown=true;
        if (item.isUpgradable()) {
          int lvl=1 + ((Dungeon.depth * 3) / 10);
          if (lvl < item.level()) {
            item.degrade(item.level() - lvl);
          }
          item.levelKnown=false;
        }
      }
      item.reset();
      return item;
    }
 else {
      return null;
    }
  }
}

Fixed version (ground truth):
public static Item get(){
  if (depth == -1) {
    try {
      InputStream input=Game.instance.openFileInput(BONES_FILE);
      Bundle bundle=Bundle.read(input);
      input.close();
      depth=bundle.getInt(LEVEL);
      item=(Item)bundle.get(ITEM);
      return get();
    }
 catch (    Exception e) {
      return null;
    }
  }
 else {
    if (depth == Dungeon.depth && Dungeon.challenges == 0) {
      Game.instance.deleteFile(BONES_FILE);
      depth=0;
      if (item instanceof Artifact) {
        if (Generator.removeArtifact((Artifact)item)) {
          try {
            Artifact artifact=(Artifact)item.getClass().newInstance();
            artifact.cursed=true;
            artifact.cursedKnown=true;
            artifact.transferUpgrade(Math.min(item.visiblyUpgraded(),1 + ((Dungeon.depth * 3) / 10)));
            return artifact;
          }
 catch (          Exception e) {
            return new Gold(item.price());
          }
        }
 else {
          return new Gold(item.price());
        }
      }
      if (item.isUpgradable()) {
        item.cursed=true;
        item.cursedKnown=true;
        if (item.isUpgradable()) {
          int lvl=1 + ((Dungeon.depth * 3) / 10);
          if (lvl < item.level()) {
            item.degrade(item.level() - lvl);
          }
          item.levelKnown=false;
        }
      }
      item.reset();
      return item;
    }
 else {
      return null;
    }
  }
}
Program: 164178
Project: 164178
Buggy source:
public boolean berserking(){
  if (target.HP == 0 && state == State.NORMAL) {
    WarriorShield sigil=target.buff(WarriorShield.class);
    if (sigil != null) {
      state=State.BERSERK;
      BuffIndicator.refreshHero();
      target.SHLD=sigil.maxShield() * 5;
      SpellSprite.show(target,SpellSprite.BERSERK);
      Sample.INSTANCE.play(Assets.SND_CHALLENGE);
      GameScene.flash(0xFF0000);
    }
  }
  return state == State.BERSERK;
}

Fixed version (ground truth):
public boolean berserking(){
  if (target.HP == 0 && state == State.NORMAL) {
    WarriorShield shield=target.buff(WarriorShield.class);
    if (shield != null) {
      state=State.BERSERK;
      BuffIndicator.refreshHero();
      target.SHLD=shield.maxShield() * 5;
      SpellSprite.show(target,SpellSprite.BERSERK);
      Sample.INSTANCE.play(Assets.SND_CHALLENGE);
      GameScene.flash(0xFF0000);
    }
  }
  return state == State.BERSERK;
}
Program: 164179
Project: 164179
Buggy source:
@Override public boolean doUnequip(Hero hero,boolean collect,boolean single){
  if (super.doUnequip(hero,collect,single)) {
    hero.belongings.armor=null;
    ((HeroSprite)hero.sprite).updateArmor();
    BrokenSeal.WarriorShield sigilBuff=hero.buff(BrokenSeal.WarriorShield.class);
    if (sigilBuff != null)     sigilBuff.setArmor(null);
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
@Override public boolean doUnequip(Hero hero,boolean collect,boolean single){
  if (super.doUnequip(hero,collect,single)) {
    hero.belongings.armor=null;
    ((HeroSprite)hero.sprite).updateArmor();
    BrokenSeal.WarriorShield sealBuff=hero.buff(BrokenSeal.WarriorShield.class);
    if (sealBuff != null)     sealBuff.setArmor(null);
    return true;
  }
 else {
    return false;
  }
}
Program: 164180
Project: 164180
Buggy source:
@Override public void execute(Hero hero,String action){
  super.execute(hero,action);
  if (action.equals(AC_DETACH) && seal) {
    seal=false;
    BrokenSeal.WarriorShield sigilBuff=hero.buff(BrokenSeal.WarriorShield.class);
    if (sigilBuff != null)     sigilBuff.setArmor(null);
    BrokenSeal sigil=new BrokenSeal();
    if (level() > 0) {
      sigil.upgrade();
      degrade();
    }
    GLog.i(Messages.get(Armor.class,"String_Node_Str"));
    hero.sprite.operate(hero.pos);
    if (!sigil.collect()) {
      Dungeon.level.drop(sigil,hero.pos);
    }
  }
}

Fixed version (ground truth):
@Override public void execute(Hero hero,String action){
  super.execute(hero,action);
  if (action.equals(AC_DETACH) && seal) {
    seal=false;
    BrokenSeal.WarriorShield sealBuff=hero.buff(BrokenSeal.WarriorShield.class);
    if (sealBuff != null)     sealBuff.setArmor(null);
    BrokenSeal seal=new BrokenSeal();
    if (level() > 0) {
      seal.upgrade();
      degrade();
    }
    GLog.i(Messages.get(Armor.class,"String_Node_Str"));
    hero.sprite.operate(hero.pos);
    if (!seal.collect()) {
      Dungeon.level.drop(seal,hero.pos);
    }
  }
}
Program: 164181
Project: 164181
Buggy source:
public static Emitter.Factory factory(final int type,final boolean lightMode,final int tint){
  Emitter.Factory factory=factories.get(type);
  if (factory == null) {
    factory=new Emitter.Factory(){
      @Override public void emit(      Emitter emitter,      int index,      float x,      float y){
        Speck p=(Speck)emitter.recycle(Speck.class);
        p.reset(index,x,y,type);
        if (tint != 0)         p.tint(tint);
      }
      @Override public boolean lightMode(){
        return lightMode;
      }
    }
;
    factories.put(type,factory);
  }
  return factory;
}

Fixed version (ground truth):
public static Emitter.Factory factory(final int type,final boolean lightMode){
  Emitter.Factory factory=factories.get(type);
  if (factory == null) {
    factory=new Emitter.Factory(){
      @Override public void emit(      Emitter emitter,      int index,      float x,      float y){
        Speck p=(Speck)emitter.recycle(Speck.class);
        p.reset(index,x,y,type);
      }
      @Override public boolean lightMode(){
        return lightMode;
      }
    }
;
    factories.put(type,factory);
  }
  return factory;
}
Program: 164184
Project: 164184
Buggy source:
@Override public void emit(Emitter emitter,int index,float x,float y){
  Speck p=(Speck)emitter.recycle(Speck.class);
  p.reset(index,x,y,type);
  if (tint != 0)   p.tint(tint);
}

Fixed version (ground truth):
@Override public void emit(Emitter emitter,int index,float x,float y){
  Speck p=(Speck)emitter.recycle(Speck.class);
  p.reset(index,x,y,type);
}
Program: 164185
Project: 164185
Buggy source:
@Override public Emitter emitter(){
  if (!seal)   return super.emitter();
  Emitter emitter=new Emitter();
  emitter.pos(10f,6f);
  emitter.fillTarget=false;
  emitter.pour(Speck.factory(Speck.LIGHT,0xFFCC0000),0.6f);
  return emitter;
}

Fixed version (ground truth):
@Override public Emitter emitter(){
  if (!seal)   return super.emitter();
  Emitter emitter=new Emitter();
  emitter.pos(10f,6f);
  emitter.fillTarget=false;
  emitter.pour(Speck.factory(Speck.RED_LIGHT),0.6f);
  return emitter;
}
Program: 164186
Project: 164186
Buggy source:
@Override public void execute(Hero hero,String action){
  super.execute(hero,action);
  if (action.equals(AC_EAT)) {
    if (potionAttrib == null) {
      GLog.w(Messages.get(this,"String_Node_Str"));
    }
 else {
      super.execute(hero,action);
      if (potionAttrib instanceof PotionOfFrost) {
        GLog.i(Messages.get(this,"String_Node_Str"));
        FrozenCarpaccio.effect(hero);
      }
 else       if (potionAttrib instanceof PotionOfLiquidFlame) {
        GLog.i(Messages.get(this,"String_Node_Str"));
        Buff.affect(hero,FireImbue.class).set(FireImbue.DURATION);
      }
 else       if (potionAttrib instanceof PotionOfToxicGas) {
        GLog.i(Messages.get(this,"String_Node_Str"));
        Buff.affect(hero,ToxicImbue.class).set(ToxicImbue.DURATION);
      }
 else       if (potionAttrib instanceof PotionOfParalyticGas) {
        GLog.i(Messages.get(this,"String_Node_Str"));
        Buff.affect(hero,EarthImbue.class,EarthImbue.DURATION);
      }
 else       potionAttrib.apply(hero);
    }
  }
}

Fixed version (ground truth):
@Override public void execute(Hero hero,String action){
  if (action.equals(AC_EAT) && potionAttrib == null) {
    GLog.w(Messages.get(this,"String_Node_Str"));
    return;
  }
  super.execute(hero,action);
  if (action.equals(AC_EAT) && potionAttrib != null) {
    if (potionAttrib instanceof PotionOfFrost) {
      GLog.i(Messages.get(this,"String_Node_Str"));
      FrozenCarpaccio.effect(hero);
    }
 else     if (potionAttrib instanceof PotionOfLiquidFlame) {
      GLog.i(Messages.get(this,"String_Node_Str"));
      Buff.affect(hero,FireImbue.class).set(FireImbue.DURATION);
    }
 else     if (potionAttrib instanceof PotionOfToxicGas) {
      GLog.i(Messages.get(this,"String_Node_Str"));
      Buff.affect(hero,ToxicImbue.class).set(ToxicImbue.DURATION);
    }
 else     if (potionAttrib instanceof PotionOfParalyticGas) {
      GLog.i(Messages.get(this,"String_Node_Str"));
      Buff.affect(hero,EarthImbue.class,EarthImbue.DURATION);
    }
 else {
      potionAttrib.apply(hero);
    }
  }
}
Program: 164187
Project: 164187
Buggy source:
@Override public void activate(){
  if (Dungeon.visible[pos]) {
    Sample.INSTANCE.play(Assets.SND_HIT);
    Wound.hit(pos);
  }
  Char ch=Actor.findChar(pos);
  if (ch != null) {
    int damage=Random.NormalIntRange(Dungeon.depth,Dungeon.depth * 2);
    damage-=Random.IntRange(0,ch.dr());
    ch.damage(Math.max(damage,0),this);
    if (!ch.isAlive() && ch == Dungeon.hero) {
      Dungeon.fail(getClass());
      GLog.n(Messages.get(this,"String_Node_Str"));
    }
  }
}

Fixed version (ground truth):
@Override public void activate(){
  if (Dungeon.visible[pos]) {
    Sample.INSTANCE.play(Assets.SND_HIT);
    Wound.hit(pos);
  }
  Char ch=Actor.findChar(pos);
  if (ch != null && !ch.flying) {
    int damage=Random.NormalIntRange(Dungeon.depth,Dungeon.depth * 2);
    damage-=Random.IntRange(0,ch.dr());
    ch.damage(Math.max(damage,0),this);
    if (!ch.isAlive() && ch == Dungeon.hero) {
      Dungeon.fail(getClass());
      GLog.n(Messages.get(this,"String_Node_Str"));
    }
  }
}
Program: 164188
Project: 164188
Buggy source:
@Override protected Char chooseEnemy(){
  if (enemy == null || !enemy.isAlive() || state == WANDERING) {
    HashSet<Mob> enemies=new HashSet<Mob>();
    for (    Mob mob : Dungeon.level.mobs) {
      if (mob.hostile && Level.fieldOfView[mob.pos] && mob.state != mob.PASSIVE) {
        enemies.add(mob);
      }
    }
    enemy=enemies.size() > 0 ? Random.element(enemies) : null;
  }
  return enemy;
}

Fixed version (ground truth):
@Override protected Char chooseEnemy(){
  if (enemy == null || !enemy.isAlive() || !Dungeon.level.mobs.contains(enemy) || state == WANDERING) {
    HashSet<Mob> enemies=new HashSet<Mob>();
    for (    Mob mob : Dungeon.level.mobs) {
      if (mob.hostile && Level.fieldOfView[mob.pos] && mob.state != mob.PASSIVE) {
        enemies.add(mob);
      }
    }
    enemy=enemies.size() > 0 ? Random.element(enemies) : null;
  }
  return enemy;
}
Program: 164189
Project: 164189
Buggy source:
@Override public void execute(Hero hero,String action){
  if (action.equals(AC_CAST)) {
    curUser=hero;
    if (!isEquipped(hero))     GLog.i(Messages.get(Artifact.class,"String_Node_Str"));
 else     if (charge < 1)     GLog.i(Messages.get(this,"String_Node_Str"));
 else     if (cursed)     GLog.w(Messages.get(this,"String_Node_Str"));
 else {
      GameScene.selectCell(caster);
    }
  }
 else   super.execute(hero,action);
}

Fixed version (ground truth):
@Override public void execute(Hero hero,String action){
  if (action.equals(AC_CAST)) {
    curUser=hero;
    if (!isEquipped(hero)) {
      GLog.i(Messages.get(Artifact.class,"String_Node_Str"));
      QuickSlotButton.cancel();
    }
 else     if (charge < 1) {
      GLog.i(Messages.get(this,"String_Node_Str"));
      QuickSlotButton.cancel();
    }
 else     if (cursed) {
      GLog.w(Messages.get(this,"String_Node_Str"));
      QuickSlotButton.cancel();
    }
 else {
      GameScene.selectCell(caster);
    }
  }
 else   super.execute(hero,action);
}
Program: 164191
Project: 164191
Buggy source:
@Override public void call(){
  if (finalTarget == Dungeon.hero) {
    if (((float)finalTarget.HP / finalTarget.HT) >= 0.9f) {
      finalTarget.damage((finalTarget.HP - 1),this);
    }
 else {
      finalTarget.damage(finalTarget.HP,this);
    }
    Sample.INSTANCE.play(Assets.SND_CURSED);
    if (!finalTarget.isAlive()) {
      Dungeon.fail(getClass());
      GLog.n(Messages.get(this,"String_Node_Str"));
    }
  }
 else {
    finalTarget.damage(finalTarget.HP,this);
    Sample.INSTANCE.play(Assets.SND_BURNING);
  }
  finalTarget.sprite.emitter().burst(ShadowParticle.UP,10);
}

Fixed version (ground truth):
@Override public void call(){
  if (finalTarget == Dungeon.hero) {
    if (((float)finalTarget.HP / finalTarget.HT) >= 0.9f) {
      finalTarget.damage((finalTarget.HP - 1),trap);
    }
 else {
      finalTarget.damage(finalTarget.HP,trap);
    }
    Sample.INSTANCE.play(Assets.SND_CURSED);
    if (!finalTarget.isAlive()) {
      Dungeon.fail(GrimTrap.class);
      GLog.n(Messages.get(GrimTrap.class,"String_Node_Str"));
    }
  }
 else {
    finalTarget.damage(finalTarget.HP,this);
    Sample.INSTANCE.play(Assets.SND_BURNING);
  }
  finalTarget.sprite.emitter().burst(ShadowParticle.UP,10);
  if (!finalTarget.isAlive())   finalTarget.next();
}
Program: 164192
Project: 164192
Buggy source:
@Override public void activate(){
  Char target=Actor.findChar(pos);
  if (target == null) {
    for (    Char ch : Actor.chars()) {
      Ballistica bolt=new Ballistica(pos,ch.pos,Ballistica.PROJECTILE);
      if (bolt.collisionPos == ch.pos && (target == null || Level.distance(pos,ch.pos) < Level.distance(pos,target.pos))) {
        target=ch;
      }
    }
  }
  if (target != null) {
    final Char finalTarget=target;
    MagicMissile.shadow(target.sprite.parent,pos,target.pos,new Callback(){
      @Override public void call(){
        if (finalTarget == Dungeon.hero) {
          if (((float)finalTarget.HP / finalTarget.HT) >= 0.9f) {
            finalTarget.damage((finalTarget.HP - 1),this);
          }
 else {
            finalTarget.damage(finalTarget.HP,this);
          }
          Sample.INSTANCE.play(Assets.SND_CURSED);
          if (!finalTarget.isAlive()) {
            Dungeon.fail(getClass());
            GLog.n(Messages.get(this,"String_Node_Str"));
          }
        }
 else {
          finalTarget.damage(finalTarget.HP,this);
          Sample.INSTANCE.play(Assets.SND_BURNING);
        }
        finalTarget.sprite.emitter().burst(ShadowParticle.UP,10);
      }
    }
);
  }
 else {
    CellEmitter.get(pos).burst(ShadowParticle.UP,10);
    Sample.INSTANCE.play(Assets.SND_BURNING);
  }
}

Fixed version (ground truth):
@Override public void activate(){
  Char target=Actor.findChar(pos);
  if (target == null) {
    for (    Char ch : Actor.chars()) {
      Ballistica bolt=new Ballistica(pos,ch.pos,Ballistica.PROJECTILE);
      if (bolt.collisionPos == ch.pos && (target == null || Level.distance(pos,ch.pos) < Level.distance(pos,target.pos))) {
        target=ch;
      }
    }
  }
  if (target != null) {
    final Char finalTarget=target;
    final GrimTrap trap=this;
    MagicMissile.shadow(target.sprite.parent,pos,target.pos,new Callback(){
      @Override public void call(){
        if (finalTarget == Dungeon.hero) {
          if (((float)finalTarget.HP / finalTarget.HT) >= 0.9f) {
            finalTarget.damage((finalTarget.HP - 1),trap);
          }
 else {
            finalTarget.damage(finalTarget.HP,trap);
          }
          Sample.INSTANCE.play(Assets.SND_CURSED);
          if (!finalTarget.isAlive()) {
            Dungeon.fail(GrimTrap.class);
            GLog.n(Messages.get(GrimTrap.class,"String_Node_Str"));
          }
        }
 else {
          finalTarget.damage(finalTarget.HP,this);
          Sample.INSTANCE.play(Assets.SND_BURNING);
        }
        finalTarget.sprite.emitter().burst(ShadowParticle.UP,10);
        if (!finalTarget.isAlive())         finalTarget.next();
      }
    }
);
  }
 else {
    CellEmitter.get(pos).burst(ShadowParticle.UP,10);
    Sample.INSTANCE.play(Assets.SND_BURNING);
  }
}
Program: 164193
Project: 164193
Buggy source:
public void stick(MissileWeapon item){
  items.add(item);
}

Fixed version (ground truth):
public void stick(MissileWeapon projectile){
  for (  Item item : items) {
    if (item.isSimilar(projectile)) {
      item.quantity(item.quantity() + projectile.quantity());
      return;
    }
  }
  items.add(projectile);
}
Program: 164194
Project: 164194
Buggy source:
@Override protected void onThrow(int cell){
  Char enemy=Actor.findChar(cell);
  if (enemy == null || enemy == curUser) {
    if (this instanceof Boomerang)     super.onThrow(cell);
 else     miss(cell);
  }
 else {
    if (!curUser.shoot(enemy,this)) {
      miss(cell);
    }
 else     if (!(this instanceof Boomerang)) {
      int bonus=0;
      for (      Buff buff : curUser.buffs(RingOfSharpshooting.Aim.class))       bonus+=((RingOfSharpshooting.Aim)buff).level;
      if (curUser.heroClass == HeroClass.HUNTRESS && enemy.buff(PinCushion.class) == null)       bonus+=3;
      if (Random.Float() > Math.pow(0.7,bonus))       Buff.affect(enemy,PinCushion.class).stick(this);
    }
  }
}

Fixed version (ground truth):
@Override protected void onThrow(int cell){
  Char enemy=Actor.findChar(cell);
  if (enemy == null || enemy == curUser) {
    if (this instanceof Boomerang)     super.onThrow(cell);
 else     miss(cell);
  }
 else {
    if (!curUser.shoot(enemy,this)) {
      miss(cell);
    }
 else     if (!(this instanceof Boomerang)) {
      int bonus=0;
      for (      Buff buff : curUser.buffs(RingOfSharpshooting.Aim.class))       bonus+=((RingOfSharpshooting.Aim)buff).level;
      if (curUser.heroClass == HeroClass.HUNTRESS && enemy.buff(PinCushion.class) == null)       bonus+=3;
      if (Random.Float() > Math.pow(0.7,bonus)) {
        if (enemy.isAlive())         Buff.affect(enemy,PinCushion.class).stick(this);
 else         Dungeon.level.drop(this,enemy.pos).sprite.drop();
      }
    }
  }
}
Program: 164196
Project: 164196
Buggy source:
@Override public void restoreFromBundle(Bundle bundle){
  if (bundle.contains(REASON)) {
    String info=bundle.getString(REASON).toLowerCase();
    if (info.equals("String_Node_Str"))     cause=Amulet.class;
 else     if (info.contains("String_Node_Str"))     cause=Goo.class;
 else     if (info.contains("String_Node_Str"))     cause=Tengu.class;
 else     if (info.contains("String_Node_Str"))     cause=DM300.class;
 else     if (info.contains("String_Node_Str"))     cause=King.class;
 else     if (info.contains("String_Node_Str"))     cause=Yog.class;
 else     if (info.contains("String_Node_Str"))     cause=Yog.class;
 else     if (info.contains("String_Node_Str"))     cause=Yog.class;
 else     if (info.equals("String_Node_Str"))     cause=Burning.class;
 else     if (info.equals("String_Node_Str"))     cause=Hunger.class;
 else     if (info.equals("String_Node_Str"))     cause=Poison.class;
 else     if (info.equals("String_Node_Str"))     cause=ToxicGas.class;
 else     if (info.equals("String_Node_Str"))     cause=Bleeding.class;
 else     if (info.equals("String_Node_Str"))     cause=Ooze.class;
 else     if (info.equals("String_Node_Str"))     cause=Chasm.class;
 else     this.info=info;
  }
 else {
    cause=bundle.getClass(CAUSE);
  }
  win=bundle.getBoolean(WIN);
  score=bundle.getInt(SCORE);
  heroClass=HeroClass.restoreInBundle(bundle);
  armorTier=bundle.getInt(TIER);
  gameFile=bundle.getString(GAME);
  depth=bundle.getInt(DEPTH);
  herolevel=bundle.getInt(LEVEL);
}

Fixed version (ground truth):
@Override public void restoreFromBundle(Bundle bundle){
  if (bundle.contains(REASON)) {
    String info=bundle.getString(REASON).toLowerCase(Locale.ENGLISH);
    if (info.equals("String_Node_Str"))     cause=Amulet.class;
 else     if (info.contains("String_Node_Str"))     cause=Goo.class;
 else     if (info.contains("String_Node_Str"))     cause=Tengu.class;
 else     if (info.contains("String_Node_Str"))     cause=DM300.class;
 else     if (info.contains("String_Node_Str"))     cause=King.class;
 else     if (info.contains("String_Node_Str"))     cause=Yog.class;
 else     if (info.contains("String_Node_Str"))     cause=Yog.class;
 else     if (info.contains("String_Node_Str"))     cause=Yog.class;
 else     if (info.equals("String_Node_Str"))     cause=Burning.class;
 else     if (info.equals("String_Node_Str"))     cause=Hunger.class;
 else     if (info.equals("String_Node_Str"))     cause=Poison.class;
 else     if (info.equals("String_Node_Str"))     cause=ToxicGas.class;
 else     if (info.equals("String_Node_Str"))     cause=Bleeding.class;
 else     if (info.equals("String_Node_Str"))     cause=Ooze.class;
 else     if (info.equals("String_Node_Str"))     cause=Chasm.class;
 else     this.info=info;
  }
 else {
    cause=bundle.getClass(CAUSE);
  }
  win=bundle.getBoolean(WIN);
  score=bundle.getInt(SCORE);
  heroClass=HeroClass.restoreInBundle(bundle);
  armorTier=bundle.getInt(TIER);
  gameFile=bundle.getString(GAME);
  depth=bundle.getInt(DEPTH);
  herolevel=bundle.getInt(LEVEL);
}