nus-yam/ex-repair huggingface dataset:
Program: 164416
Project: 164416
Buggy source:
private void descend() throws Exception {
  Level level;
  ArrayList<Item> fallingItems=new ArrayList<Item>();
  if (Dungeon.depth > 0) {
    level=Dungeon.level;
    fallingItems=level.fallingItems;
    level.fallingItems=new ArrayList<Item>();
  }
  Actor.fixTime();
  if (Dungeon.hero == null) {
    Dungeon.init();
    if (noStory) {
      Dungeon.chapters.add(WndStory.ID_SEWERS);
      noStory=false;
    }
  }
 else {
    Dungeon.saveLevel();
  }
  if (Dungeon.depth >= Statistics.deepestFloor) {
    level=Dungeon.newLevel();
  }
 else {
    Dungeon.depth++;
    level=Dungeon.loadLevel(Dungeon.hero.heroClass);
  }
  for (  Item item : fallingItems) {
    int cell=level.randomRespawnCell();
    while (cell == -1)     cell=level.randomRespawnCell();
    if (!(item instanceof Potion))     level.drop(item,cell);
 else     level.fallingPotions.add((Potion)item);
  }
  Dungeon.switchLevel(level,level.entrance);
}

Fixed version (ground truth):
private void descend() throws Exception {
  Level level;
  ArrayList<Item> fallingItems=new ArrayList<Item>();
  Actor.fixTime();
  if (Dungeon.hero == null) {
    Dungeon.init();
    if (noStory) {
      Dungeon.chapters.add(WndStory.ID_SEWERS);
      noStory=false;
    }
  }
 else {
    level=Dungeon.level;
    fallingItems=level.fallingItems;
    level.fallingItems=new ArrayList<Item>();
    Dungeon.saveLevel();
  }
  if (Dungeon.depth >= Statistics.deepestFloor) {
    level=Dungeon.newLevel();
  }
 else {
    Dungeon.depth++;
    level=Dungeon.loadLevel(Dungeon.hero.heroClass);
  }
  for (  Item item : fallingItems) {
    int cell=level.randomRespawnCell();
    while (cell == -1)     cell=level.randomRespawnCell();
    if (!(item instanceof Potion))     level.drop(item,cell);
 else     level.fallingPotions.add((Potion)item);
  }
  Dungeon.switchLevel(level,level.entrance);
}
Program: 164417
Project: 164417
Buggy source:
public Plant plant(Plant.Seed seed,int pos){
  Plant plant=plants.get(pos);
  if (plant != null) {
    plant.wither();
  }
  plant=seed.couch(pos);
  plants.put(pos,plant);
  GameScene.add(plant);
  return plant;
}

Fixed version (ground truth):
public Plant plant(Plant.Seed seed,int pos){
  Plant plant=plants.get(pos);
  if (plant != null) {
    plant.wither();
  }
  if (map[pos] == Terrain.HIGH_GRASS || map[pos] == Terrain.EMPTY || map[pos] == Terrain.EMBERS || map[pos] == Terrain.EMPTY_DECO) {
    set(pos,Terrain.GRASS);
    GameScene.updateMap(pos);
  }
  plant=seed.couch(pos);
  plants.put(pos,plant);
  GameScene.add(plant);
  return plant;
}
Program: 164418
Project: 164418
Buggy source:
public Heap drop(Item item,int cell){
  if ((Dungeon.isChallenged(Challenges.NO_FOOD) && (item instanceof Food || item instanceof BlandfruitBush.Seed)) || (Dungeon.isChallenged(Challenges.NO_ARMOR) && item instanceof Armor) || (Dungeon.isChallenged(Challenges.NO_HEALING) && item instanceof PotionOfHealing)|| (Dungeon.isChallenged(Challenges.NO_HERBALISM) && (item instanceof Plant.Seed || item instanceof Dewdrop))) {
    return new Heap();
  }
  if ((map[cell] == Terrain.ALCHEMY) && (item instanceof BlandfruitBush.Seed || !(item instanceof Plant.Seed || (item instanceof Blandfruit && ((Blandfruit)item).potionAttrib == null && heaps.get(cell) == null)))) {
    int n;
    do {
      n=cell + NEIGHBOURS8[Random.Int(8)];
    }
 while (map[n] != Terrain.EMPTY_SP);
    cell=n;
  }
  Heap heap=heaps.get(cell);
  if (heap == null) {
    heap=new Heap();
    heap.pos=cell;
    if (map[cell] == Terrain.CHASM || (Dungeon.level != null && pit[cell])) {
      GameScene.discard(heap);
      fallingItems.add(item);
    }
 else {
      heaps.put(cell,heap);
      GameScene.add(heap);
    }
  }
 else   if (heap.type == Heap.Type.LOCKED_CHEST || heap.type == Heap.Type.CRYSTAL_CHEST) {
    int n;
    do {
      n=cell + Level.NEIGHBOURS8[Random.Int(8)];
    }
 while (!Level.passable[n] && !Level.avoid[n]);
    return drop(item,n);
  }
  heap.drop(item);
  if (Dungeon.level != null) {
    press(cell,null);
  }
  return heap;
}

Fixed version (ground truth):
public Heap drop(Item item,int cell){
  if ((Dungeon.isChallenged(Challenges.NO_FOOD) && (item instanceof Food || item instanceof BlandfruitBush.Seed)) || (Dungeon.isChallenged(Challenges.NO_ARMOR) && item instanceof Armor) || (Dungeon.isChallenged(Challenges.NO_HEALING) && item instanceof PotionOfHealing)|| (Dungeon.isChallenged(Challenges.NO_HERBALISM) && (item instanceof Plant.Seed || item instanceof Dewdrop))) {
    Heap heap=new Heap();
    GameScene.add(heap);
    return heap;
  }
  if ((map[cell] == Terrain.ALCHEMY) && (item instanceof BlandfruitBush.Seed || !(item instanceof Plant.Seed || (item instanceof Blandfruit && ((Blandfruit)item).potionAttrib == null && heaps.get(cell) == null)))) {
    int n;
    do {
      n=cell + NEIGHBOURS8[Random.Int(8)];
    }
 while (map[n] != Terrain.EMPTY_SP);
    cell=n;
  }
  Heap heap=heaps.get(cell);
  if (heap == null) {
    heap=new Heap();
    heap.pos=cell;
    if (map[cell] == Terrain.CHASM || (Dungeon.level != null && pit[cell])) {
      GameScene.discard(heap);
      fallingItems.add(item);
    }
 else {
      heaps.put(cell,heap);
      GameScene.add(heap);
    }
  }
 else   if (heap.type == Heap.Type.LOCKED_CHEST || heap.type == Heap.Type.CRYSTAL_CHEST) {
    int n;
    do {
      n=cell + Level.NEIGHBOURS8[Random.Int(8)];
    }
 while (!Level.passable[n] && !Level.avoid[n]);
    return drop(item,n);
  }
  heap.drop(item);
  if (Dungeon.level != null) {
    press(cell,null);
  }
  return heap;
}
Program: 164419
Project: 164419
Buggy source:
@Override public boolean act(){
  spend(TICK);
  boolean smthFound=false;
  int distance=3;
  int cx=target.pos % Level.WIDTH;
  int cy=target.pos / Level.WIDTH;
  int ax=cx - distance;
  if (ax < 0) {
    ax=0;
  }
  int bx=cx + distance;
  if (bx >= Level.WIDTH) {
    bx=Level.WIDTH - 1;
  }
  int ay=cy - distance;
  if (ay < 0) {
    ay=0;
  }
  int by=cy + distance;
  if (by >= Level.HEIGHT) {
    by=Level.HEIGHT - 1;
  }
  for (int y=ay; y <= by; y++) {
    for (int x=ax, p=ax + y * Level.WIDTH; x <= bx; x++, p++) {
      if (Dungeon.visible[p] && Level.secret[p] && Dungeon.level.map[p] != Terrain.SECRET_DOOR)       smthFound=true;
    }
  }
  if (smthFound == true || !cursed) {
    if (warn == 0) {
      GLog.w("String_Node_Str");
      if (target instanceof Hero) {
        ((Hero)target).interrupt();
      }
    }
    warn=3;
  }
 else {
    if (warn > 0) {
      warn--;
    }
  }
  BuffIndicator.refreshHero();
  if (charge < 100 && !cursed) {
    partialCharge+=(1f / 24) + (((float)level) / 80);
    if (partialCharge > 1 && charge < 100) {
      partialCharge--;
      charge++;
    }
 else     if (charge >= 100) {
      partialCharge=0;
      GLog.p("String_Node_Str");
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean act(){
  spend(TICK);
  boolean smthFound=false;
  int distance=3;
  int cx=target.pos % Level.WIDTH;
  int cy=target.pos / Level.WIDTH;
  int ax=cx - distance;
  if (ax < 0) {
    ax=0;
  }
  int bx=cx + distance;
  if (bx >= Level.WIDTH) {
    bx=Level.WIDTH - 1;
  }
  int ay=cy - distance;
  if (ay < 0) {
    ay=0;
  }
  int by=cy + distance;
  if (by >= Level.HEIGHT) {
    by=Level.HEIGHT - 1;
  }
  for (int y=ay; y <= by; y++) {
    for (int x=ax, p=ax + y * Level.WIDTH; x <= bx; x++, p++) {
      if (Dungeon.visible[p] && Level.secret[p] && Dungeon.level.map[p] != Terrain.SECRET_DOOR)       smthFound=true;
    }
  }
  if (smthFound == true && !cursed) {
    if (warn == 0) {
      GLog.w("String_Node_Str");
      if (target instanceof Hero) {
        ((Hero)target).interrupt();
      }
    }
    warn=3;
  }
 else {
    if (warn > 0) {
      warn--;
    }
  }
  BuffIndicator.refreshHero();
  if (charge < 100 && !cursed) {
    partialCharge+=(1f / 24) + (((float)level) / 80);
    if (partialCharge > 1 && charge < 100) {
      partialCharge--;
      charge++;
    }
 else     if (charge >= 100) {
      partialCharge=0;
      GLog.p("String_Node_Str");
    }
  }
  return true;
}
Program: 164420
Project: 164420
Buggy source:
@Override public boolean proc(Weapon weapon,Char attacker,Char defender,int damage){
  int level=Math.max(0,weapon.level);
  int maxDamage=(int)(damage * Math.pow(2,-1d / (level + 1)));
  if (maxDamage >= 1) {
    int d=defender.pos - attacker.pos;
    int pos=defender.pos + d;
    do {
      Char ch=Actor.findChar(pos);
      if (ch == null) {
        break;
      }
      int dr=Random.IntRange(0,ch.dr());
      int dmg=Random.Int(1,maxDamage);
      int effectiveDamage=Math.max(dmg - dr,0);
      ch.damage(effectiveDamage,this);
      ch.sprite.bloodBurstA(attacker.sprite.center(),effectiveDamage);
      ch.sprite.flash();
      pos+=d;
    }
 while (pos >= 0 && pos < Level.LENGTH);
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
@Override public boolean proc(Weapon weapon,Char attacker,Char defender,int damage){
  int level=Math.max(0,weapon.level);
  int maxDamage=(int)(damage * Math.pow(2,-1d / (level + 1)));
  if (maxDamage >= 1) {
    int d=defender.pos - attacker.pos;
    int pos=defender.pos + d;
    while (pos >= 0 && pos < Level.LENGTH) {
      Char ch=Actor.findChar(pos);
      if (ch == null) {
        break;
      }
      int dr=Random.IntRange(0,ch.dr());
      int dmg=Random.Int(1,maxDamage);
      int effectiveDamage=Math.max(dmg - dr,0);
      ch.damage(effectiveDamage,this);
      ch.sprite.bloodBurstA(attacker.sprite.center(),effectiveDamage);
      ch.sprite.flash();
      pos+=d;
    }
    return true;
  }
 else {
    return false;
  }
}
Program: 164421
Project: 164421
Buggy source:
@Override public ArrayList<String> actions(Hero hero){
  ArrayList<String> actions=super.actions(hero);
  DewVial vial=hero.belongings.getItem(DewVial.class);
  if (vial != null && vial.isFull())   actions.add(AC_BLESS);
  return actions;
}

Fixed version (ground truth):
@Override public ArrayList<String> actions(Hero hero){
  ArrayList<String> actions=super.actions(hero);
  DewVial vial=hero.belongings.getItem(DewVial.class);
  if (vial != null && vial.isFull() && !blessed)   actions.add(AC_BLESS);
  return actions;
}
Program: 164422
Project: 164422
Buggy source:
@Override public void die(Object cause){
  curAction=null;
  Ankh ankh=(Ankh)belongings.getItem(Ankh.class);
  if (ankh != null && ankh.isBlessed()) {
    this.HP=HT;
    new Flare(8,32).color(0xFFFF66,true).show(sprite,2f);
    CellEmitter.get(this.pos).start(Speck.factory(Speck.LIGHT),0.2f,3);
    ankh.detach(belongings.backpack);
    Sample.INSTANCE.play(Assets.SND_TELEPORT);
    GLog.w(ankh.TXT_REVIVE);
    Statistics.ankhsUsed++;
    return;
  }
  Actor.fixTime();
  super.die(cause);
  if (ankh == null) {
    reallyDie(cause);
  }
 else {
    Dungeon.deleteGame(Dungeon.hero.heroClass,false);
    GameScene.show(new WndResurrect(ankh,cause));
  }
}

Fixed version (ground truth):
@Override public void die(Object cause){
  curAction=null;
  Ankh ankh=null;
  for (  Item item : belongings) {
    if (item instanceof Ankh) {
      if (ankh == null || ((Ankh)item).isBlessed()) {
        ankh=(Ankh)item;
      }
    }
  }
  if (ankh != null && ankh.isBlessed()) {
    this.HP=HT;
    new Flare(8,32).color(0xFFFF66,true).show(sprite,2f);
    CellEmitter.get(this.pos).start(Speck.factory(Speck.LIGHT),0.2f,3);
    ankh.detach(belongings.backpack);
    Sample.INSTANCE.play(Assets.SND_TELEPORT);
    GLog.w(ankh.TXT_REVIVE);
    Statistics.ankhsUsed++;
    return;
  }
  Actor.fixTime();
  super.die(cause);
  if (ankh == null) {
    reallyDie(cause);
  }
 else {
    Dungeon.deleteGame(Dungeon.hero.heroClass,false);
    GameScene.show(new WndResurrect(ankh,cause));
  }
}
Program: 164423
Project: 164423
Buggy source:
public void countIronKeys(){
  IronKey.curDepthQuantity=0;
  for (  Item item : backpack) {
    if (item instanceof IronKey && ((IronKey)item).depth == Dungeon.depth) {
      IronKey.curDepthQuantity++;
    }
  }
}

Fixed version (ground truth):
public void countIronKeys(){
  IronKey.curDepthQuantity=0;
  for (  Item item : backpack) {
    if (item instanceof IronKey && ((IronKey)item).depth == Dungeon.depth) {
      IronKey.curDepthQuantity+=item.quantity();
    }
  }
}
Program: 164424
Project: 164424
Buggy source:
public final Item detach(Bag container){
  if (quantity <= 0) {
    return null;
  }
 else   if (quantity == 1) {
    return detachAll(container);
  }
 else {
    quantity--;
    updateQuickslot();
    try {
      Item detached=getClass().newInstance();
      detached.onDetach();
      return detached;
    }
 catch (    Exception e) {
      return null;
    }
  }
}

Fixed version (ground truth):
public final Item detach(Bag container){
  if (quantity <= 0) {
    return null;
  }
 else   if (quantity == 1) {
    return detachAll(container);
  }
 else {
    quantity--;
    updateQuickslot();
    try {
      Item detached=getClass().newInstance();
      Bundle copy=new Bundle();
      this.storeInBundle(copy);
      detached.restoreFromBundle(copy);
      detached.quantity(1);
      detached.onDetach();
      return detached;
    }
 catch (    Exception e) {
      return null;
    }
  }
}
Program: 164425
Project: 164425
Buggy source:
@Override public void interact(){
  sprite.turnTo(pos,Dungeon.hero.pos);
  Sample.INSTANCE.play(Assets.SND_GHOST);
  if (Quest.given) {
    if (Quest.processed || Dungeon.hero.belongings.getItem(RatSkull.class) != null) {
      GameScene.show(new WndSadGhost(this,Quest.type));
    }
 else {
switch (Quest.type) {
case 1:
default :
        GameScene.show(new WndQuest(this,TXT_RAT2));
      break;
case 2:
    GameScene.show(new WndQuest(this,TXT_GNOLL2));
  break;
case 3:
GameScene.show(new WndQuest(this,TXT_CRAB2));
break;
}
int newPos=-1;
for (int i=0; i < 10; i++) {
newPos=Dungeon.level.randomRespawnCell();
if (newPos != -1) {
break;
}
}
if (newPos != -1) {
Actor.freeCell(pos);
CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT),0.2f,3);
pos=newPos;
sprite.place(pos);
sprite.visible=Dungeon.visible[pos];
}
}
}
 else {
Mob questBoss;
String txt_quest;
switch (Quest.type) {
case 1:
default :
questBoss=new FetidRat();
txt_quest=TXT_RAT1;
break;
case 2:
questBoss=new GnollTrickster();
txt_quest=TXT_GNOLL1;
break;
case 3:
questBoss=new GreatCrab();
txt_quest=TXT_CRAB1;
break;
}
questBoss.pos=Dungeon.level.randomRespawnCell();
if (questBoss.pos != -1) {
GameScene.add(questBoss);
GameScene.show(new WndQuest(this,txt_quest));
Quest.given=true;
Journal.add(Journal.Feature.GHOST);
}
}
}

Fixed version (ground truth):
@Override public void interact(){
  sprite.turnTo(pos,Dungeon.hero.pos);
  Sample.INSTANCE.play(Assets.SND_GHOST);
  if (Quest.given) {
    if (Quest.weapon != null) {
      if (Quest.processed || Dungeon.hero.belongings.getItem(RatSkull.class) != null) {
        GameScene.show(new WndSadGhost(this,Quest.type));
      }
 else {
switch (Quest.type) {
case 1:
default :
          GameScene.show(new WndQuest(this,TXT_RAT2));
        break;
case 2:
      GameScene.show(new WndQuest(this,TXT_GNOLL2));
    break;
case 3:
  GameScene.show(new WndQuest(this,TXT_CRAB2));
break;
}
int newPos=-1;
for (int i=0; i < 10; i++) {
newPos=Dungeon.level.randomRespawnCell();
if (newPos != -1) {
break;
}
}
if (newPos != -1) {
Actor.freeCell(pos);
CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT),0.2f,3);
pos=newPos;
sprite.place(pos);
sprite.visible=Dungeon.visible[pos];
}
}
}
}
 else {
Mob questBoss;
String txt_quest;
switch (Quest.type) {
case 1:
default :
questBoss=new FetidRat();
txt_quest=TXT_RAT1;
break;
case 2:
questBoss=new GnollTrickster();
txt_quest=TXT_GNOLL1;
break;
case 3:
questBoss=new GreatCrab();
txt_quest=TXT_CRAB1;
break;
}
questBoss.pos=Dungeon.level.randomRespawnCell();
if (questBoss.pos != -1) {
GameScene.add(questBoss);
GameScene.show(new WndQuest(this,txt_quest));
Quest.given=true;
Journal.add(Journal.Feature.GHOST);
}
}
}
Program: 164426
Project: 164426
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) {
      Game.instance.deleteFile(BONES_FILE);
      depth=0;
      if (item.isUpgradable()) {
        item.cursed=true;
        item.cursedKnown=true;
        if (item.isUpgradable()) {
          int lvl=(Dungeon.depth - 1) * 3 / 5 + 1;
          if (lvl < item.level) {
            item.degrade(item.level - lvl);
          }
          item.levelKnown=false;
        }
      }
      if (item instanceof Ring) {
        ((Ring)item).syncGem();
      }
      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) {
      Game.instance.deleteFile(BONES_FILE);
      depth=0;
      if (item.isUpgradable()) {
        item.cursed=true;
        item.cursedKnown=true;
        if (item.isUpgradable()) {
          int lvl=(Dungeon.depth - 1) * 3 / 5 + 1;
          if (lvl < item.level) {
            item.degrade(item.level - lvl);
          }
          item.levelKnown=false;
        }
      }
      item.syncVisuals();
      return item;
    }
 else {
      return null;
    }
  }
}
Program: 164427
Project: 164427
Buggy source:
private static Item pickItem(Hero hero){
  Item item=null;
  if (Random.Int(2) == 0) {
switch (Random.Int(5)) {
case 0:
      item=hero.belongings.weapon;
    break;
case 1:
  item=hero.belongings.armor;
break;
case 2:
item=hero.belongings.misc1;
break;
case 3:
item=hero.belongings.misc2;
break;
case 4:
item=QuickSlot.getItem();
break;
}
if (item != null && !item.bones) return pickItem(hero);
}
 else {
Iterator<Item> iterator=hero.belongings.backpack.iterator();
Item curItem;
ArrayList<Item> items=new ArrayList<Item>();
while (iterator.hasNext()) {
curItem=iterator.next();
if (curItem.bones && !(curItem instanceof EquipableItem)) items.add(curItem);
}
if (!items.isEmpty()) {
item=Random.element(items);
if (item.stackable) {
item.quantity(Random.NormalIntRange(1,(int)Math.sqrt(item.quantity())));
}
}
}
if (item == null) {
if (Dungeon.gold > 0) {
item=new Gold(Random.NormalIntRange(1,Dungeon.gold));
}
 else {
item=new Gold(1);
}
}
return item;
}

Fixed version (ground truth):
private static Item pickItem(Hero hero){
  Item item=null;
  if (Random.Int(2) == 0) {
switch (Random.Int(5)) {
case 0:
      item=hero.belongings.weapon;
    break;
case 1:
  item=hero.belongings.armor;
break;
case 2:
item=hero.belongings.misc1;
break;
case 3:
item=hero.belongings.misc2;
break;
case 4:
item=QuickSlot.getItem();
break;
}
if (item != null && !item.bones) return pickItem(hero);
}
 else {
Iterator<Item> iterator=hero.belongings.backpack.iterator();
Item curItem;
ArrayList<Item> items=new ArrayList<Item>();
while (iterator.hasNext()) {
curItem=iterator.next();
if (curItem.bones && !(curItem instanceof EquipableItem)) items.add(curItem);
}
if (!items.isEmpty()) {
item=Random.element(items);
if (item.stackable) {
item.quantity((int)Math.sqrt(item.quantity()));
}
}
}
if (item == null) {
if (Dungeon.gold > 0) {
item=new Gold(Random.NormalIntRange(1,Dungeon.gold));
}
 else {
item=new Gold(1);
}
}
return item;
}
Program: 164428
Project: 164428
Buggy source:
public Potion(){
  super();
  image=handler.image(this);
  color=handler.label(this);
}

Fixed version (ground truth):
public Potion(){
  super();
  syncVisuals();
}
Program: 164429
Project: 164429
Buggy source:
public Ring(){
  super();
  syncGem();
}

Fixed version (ground truth):
public Ring(){
  super();
  syncVisuals();
}
Program: 164430
Project: 164430
Buggy source:
public Scroll(){
  super();
  image=handler.image(this);
  rune=handler.label(this);
}

Fixed version (ground truth):
public Scroll(){
  super();
  syncVisuals();
}
Program: 164431
Project: 164431
Buggy source:
public Wand(){
  super();
  calculateDamage();
  try {
    image=handler.image(this);
    wood=handler.label(this);
  }
 catch (  Exception e) {
  }
}

Fixed version (ground truth):
public Wand(){
  super();
  calculateDamage();
  try {
    syncVisuals();
  }
 catch (  Exception e) {
  }
}
Program: 164432
Project: 164432
Buggy source:
@Override public void damage(int dmg,Object src){
  restoreHealth=false;
  if (this.buff(Drowsy.class) != null) {
    Buff.detach(this,Drowsy.class);
    GLog.w("String_Node_Str");
  }
  int tenacity=0;
  for (  Buff buff : buffs(RingOfTenacity.Tenacity.class)) {
    tenacity+=((RingOfTenacity.Tenacity)buff).level;
  }
  if (tenacity != 0)   dmg*=Math.pow(0.9,tenacity * ((float)(HT - HP) / HT));
  super.damage(dmg,src);
  if (subClass == HeroSubClass.BERSERKER && 0 < HP && HP <= HT * Fury.LEVEL) {
    Buff.affect(this,Fury.class);
  }
}

Fixed version (ground truth):
@Override public void damage(int dmg,Object src){
  restoreHealth=false;
  if (this.buff(Drowsy.class) != null) {
    Buff.detach(this,Drowsy.class);
    GLog.w("String_Node_Str");
  }
  int tenacity=0;
  for (  Buff buff : buffs(RingOfTenacity.Tenacity.class)) {
    tenacity+=((RingOfTenacity.Tenacity)buff).level;
  }
  if (tenacity != 0)   dmg=(int)Math.ceil((float)dmg * Math.pow(0.9,tenacity * ((float)(HT - HP) / HT)));
  super.damage(dmg,src);
  if (subClass == HeroSubClass.BERSERKER && 0 < HP && HP <= HT * Fury.LEVEL) {
    Buff.affect(this,Fury.class);
  }
}
Program: 164433
Project: 164433
Buggy source:
@Override protected void doRead(){
  for (  Mob mob : Dungeon.level.mobs) {
    mob.beckon(curUser.pos);
    if (Dungeon.level.fieldOfView[mob.pos]) {
      Buff.prolong(mob,Amok.class,5f);
    }
  }
  GLog.w("String_Node_Str");
  setKnown();
  curUser.sprite.centerEmitter().start(Speck.factory(Speck.SCREAM),0.3f,3);
  Sample.INSTANCE.play(Assets.SND_CHALLENGE);
  Invisibility.dispel();
  curUser.spendAndNext(TIME_TO_READ);
}

Fixed version (ground truth):
@Override protected void doRead(){
  for (  Mob mob : Dungeon.level.mobs.toArray(new Mob[0])) {
    mob.beckon(curUser.pos);
    if (Level.fieldOfView[mob.pos]) {
      Buff.prolong(mob,Amok.class,5f);
    }
  }
  GLog.w("String_Node_Str");
  setKnown();
  curUser.sprite.centerEmitter().start(Speck.factory(Speck.SCREAM),0.3f,3);
  Sample.INSTANCE.play(Assets.SND_CHALLENGE);
  Invisibility.dispel();
  curUser.spendAndNext(TIME_TO_READ);
}
Program: 164434
Project: 164434
Buggy source:
@Override public void remove(Buff buff){
  super.remove(buff);
  if (buff instanceof Light) {
    sprite.remove(CharSprite.State.ILLUMINATED);
  }
 else   if (buff instanceof RingOfMight.Might) {
    if (((RingOfMight.Might)buff).level > 0) {
      HT-=((RingOfMight.Might)buff).level * 5;
    }
  }
  BuffIndicator.refreshHero();
}

Fixed version (ground truth):
@Override public void remove(Buff buff){
  super.remove(buff);
  if (buff instanceof Light) {
    sprite.remove(CharSprite.State.ILLUMINATED);
  }
 else   if (buff instanceof RingOfMight.Might) {
    if (((RingOfMight.Might)buff).level > 0) {
      HT-=((RingOfMight.Might)buff).level * 5;
      HP=Math.min(HT,HP);
    }
  }
  BuffIndicator.refreshHero();
}
Program: 164435
Project: 164435
Buggy source:
public void charge(){
  charge=Math.min(charge + 4,chargeCap);
  exp++;
  if (exp >= 4) {
    upgrade();
    GLog.p("String_Node_Str");
    exp-=4;
  }
}

Fixed version (ground truth):
public void charge(){
  charge=Math.min(charge + 4,chargeCap);
  exp++;
  if (exp >= 5 && level < levelCap) {
    upgrade();
    GLog.p("String_Node_Str");
    exp-=5;
  }
}
Program: 164436
Project: 164436
Buggy source:
@Override public void onSelect(Item item){
  if (item != null && item instanceof Plant.Seed) {
    if (seeds.contains(item.name())) {
      GLog.w("String_Node_Str" + name + "String_Node_Str");
    }
 else {
      seeds.add(item.name());
      Hero hero=Dungeon.hero;
      hero.sprite.operate(hero.pos);
      hero.busy();
      hero.spend(2f);
      if (seeds.size() >= 5 + level) {
        seeds.clear();
        upgrade();
        if (level >= 1 && level <= 3) {
          GLog.p("String_Node_Str" + name + "String_Node_Str"+ NAMES[level]+ "String_Node_Str");
          name=NAMES[level];
        }
        if (level <= 0)         image=ItemSpriteSheet.ARTIFACT_SANDALS;
 else         if (level == 1)         image=ItemSpriteSheet.ARTIFACT_SHOES;
 else         if (level == 2)         image=ItemSpriteSheet.ARTIFACT_BOOTS;
 else         if (level >= 3)         image=ItemSpriteSheet.ARTIFACT_GREAVES;
      }
 else {
        GLog.i("String_Node_Str" + name + "String_Node_Str");
      }
    }
  }
}

Fixed version (ground truth):
@Override public void onSelect(Item item){
  if (item != null && item instanceof Plant.Seed) {
    if (seeds.contains(item.name())) {
      GLog.w("String_Node_Str" + name + "String_Node_Str");
    }
 else {
      seeds.add(item.name());
      Hero hero=Dungeon.hero;
      hero.sprite.operate(hero.pos);
      hero.busy();
      hero.spend(2f);
      if (seeds.size() >= 5 + level) {
        seeds.clear();
        upgrade();
        if (level >= 1 && level <= 3) {
          GLog.p("String_Node_Str" + name + "String_Node_Str"+ NAMES[level]+ "String_Node_Str");
          name=NAMES[level];
        }
        if (level <= 0)         image=ItemSpriteSheet.ARTIFACT_SANDALS;
 else         if (level == 1)         image=ItemSpriteSheet.ARTIFACT_SHOES;
 else         if (level == 2)         image=ItemSpriteSheet.ARTIFACT_BOOTS;
 else         if (level >= 3)         image=ItemSpriteSheet.ARTIFACT_GREAVES;
      }
 else {
        GLog.i("String_Node_Str" + name + "String_Node_Str");
      }
      item.detach(hero.belongings.backpack);
    }
  }
}
Program: 164438
Project: 164438
Buggy source:
public int absorb(int damage){
  if (level >= damage - damage / 2) {
    detach();
    return damage - level;
  }
 else {
    level-=damage - damage / 2;
    return damage / 2;
  }
}

Fixed version (ground truth):
public int absorb(int damage){
  if (level <= damage - damage / 2) {
    detach();
    return damage - level;
  }
 else {
    level-=damage - damage / 2;
    return damage / 2;
  }
}
Program: 164439
Project: 164439
Buggy source:
@Override public boolean doEquip(Hero hero){
  if (hero.belongings.misc1 != null && hero.belongings.misc2 != null) {
    GLog.w("String_Node_Str");
    return false;
  }
 else   if (hero.belongings.misc1.getClass() == this.getClass() || hero.belongings.misc2.getClass() == this.getClass()) {
    GLog.w("String_Node_Str");
    return false;
  }
 else {
    if (hero.belongings.misc1 == null) {
      hero.belongings.misc1=this;
    }
 else {
      hero.belongings.misc2=this;
    }
    detach(hero.belongings.backpack);
    activate(hero);
    hero.spendAndNext(TIME_TO_EQUIP);
    return true;
  }
}

Fixed version (ground truth):
@Override public boolean doEquip(Hero hero){
  if (hero.belongings.misc1 != null && hero.belongings.misc2 != null) {
    GLog.w("String_Node_Str");
    return false;
  }
 else   if ((hero.belongings.misc1 != null && hero.belongings.misc1.getClass() == this.getClass()) || (hero.belongings.misc2 != null && hero.belongings.misc2.getClass() == this.getClass())) {
    GLog.w("String_Node_Str");
    return false;
  }
 else {
    if (hero.belongings.misc1 == null) {
      hero.belongings.misc1=this;
    }
 else {
      hero.belongings.misc2=this;
    }
    detach(hero.belongings.backpack);
    activate(hero);
    hero.spendAndNext(TIME_TO_EQUIP);
    return true;
  }
}
Program: 164440
Project: 164440
Buggy source:
@Override public boolean act(){
  charge--;
  if (charge <= 0) {
    detach();
    GLog.w("String_Node_Str");
  }
  exp+=10 + ((Hero)target).lvl;
  if (exp >= level * 50 && level < 21) {
    exp-=level * 50;
    GLog.p("String_Node_Str");
    level++;
    chargeCap++;
  }
  QuickSlot.refresh();
  spend(TICK);
  return true;
}

Fixed version (ground truth):
@Override public boolean act(){
  charge--;
  if (charge <= 0) {
    detach();
    GLog.w("String_Node_Str");
  }
  exp+=10 + ((Hero)target).lvl;
  if (exp >= level * 50 && level < 16) {
    exp-=level * 50;
    GLog.p("String_Node_Str");
    level++;
    chargeCap++;
  }
  QuickSlot.refresh();
  spend(TICK);
  return true;
}
Program: 164441
Project: 164441
Buggy source:
@Override public void storeInBundle(Bundle bundle){
  super.storeInBundle(bundle);
  bundle.put("String_Node_Str",stealthed);
}

Fixed version (ground truth):
@Override public void storeInBundle(Bundle bundle){
  super.storeInBundle(bundle);
  bundle.put("String_Node_Str",stealthed);
  bundle.put("String_Node_Str",cooldown);
}
Program: 164442
Project: 164442
Buggy source:
@Override public void detach(){
  if (target.invisible > 0)   target.invisible--;
  stealthed=false;
  cooldown=12 - (level / 3);
  super.detach();
}

Fixed version (ground truth):
@Override public void detach(){
  if (target.invisible > 0)   target.invisible--;
  stealthed=false;
  cooldown=10 - (level / 4);
  QuickSlot.refresh();
  super.detach();
}
Program: 164443
Project: 164443
Buggy source:
@Override public void restoreFromBundle(Bundle bundle){
  super.restoreFromBundle(bundle);
  stealthed=bundle.getBoolean("String_Node_Str");
}

Fixed version (ground truth):
@Override public void restoreFromBundle(Bundle bundle){
  super.restoreFromBundle(bundle);
  stealthed=bundle.getBoolean("String_Node_Str");
  cooldown=bundle.getInt("String_Node_Str");
}
Program: 164444
Project: 164444
Buggy source:
@Override public String desc(){
  return "String_Node_Str" + cooldown;
}

Fixed version (ground truth):
@Override public String desc(){
  return "String_Node_Str";
}
Program: 164445
Project: 164445
Buggy source:
@Override public String status(){
  return Utils.format(TXT_STATUS,charge,chargeCap);
}

Fixed version (ground truth):
@Override public String status(){
  if (cooldown == 0)   return Utils.format(TXT_CHARGE,charge,chargeCap);
 else   return Utils.format(TXT_CD,cooldown);
}
Program: 164446
Project: 164446
Buggy source:
public int proc(int damage,Char attacker){
  if (timer == 0) {
    charge+=damage / (4f - level * 0.1);
    if (charge > chargeCap) {
      charge=0;
      timer=5 + level;
    }
  }
  if (timer != 0) {
    int deflected=Random.NormalIntRange(0,(int)(damage * 0.66));
    damage-=deflected;
    attacker.damage(deflected,this);
    exp+=deflected;
    if (exp >= (level + 1) * 10 && level < levelCap) {
      exp-=(level + 1) * 10;
      level++;
      GLog.p("String_Node_Str");
    }
  }
  return damage;
}

Fixed version (ground truth):
public int proc(int damage,Char attacker){
  if (timer == 0) {
    charge+=damage * (0.5 + level * 0.025);
    if (charge > chargeCap) {
      charge=0;
      timer=5 + level;
      BuffIndicator.refreshHero();
    }
  }
  if (timer != 0) {
    int deflected=Random.NormalIntRange((int)(damage * 0.33),damage);
    damage-=deflected;
    attacker.damage(deflected,this);
    exp+=deflected;
    if (exp >= (level + 1) * 10 && level < levelCap) {
      exp-=(level + 1) * 10;
      level++;
      GLog.p("String_Node_Str");
    }
  }
  QuickSlot.refresh();
  return damage;
}
Program: 164447
Project: 164447
Buggy source:
@Override public boolean act(){
  if (timer > 0)   timer--;
 else   if (charge > 0)   charge--;
  return true;
}

Fixed version (ground truth):
@Override public boolean act(){
  if (timer > 0) {
    timer--;
    if (timer == 0)     BuffIndicator.refreshHero();
    QuickSlot.refresh();
  }
  spend(TICK);
  return true;
}
Program: 164449
Project: 164449
Buggy source:
public static void saveGame(String fileName) throws IOException {
  try {
    Bundle bundle=new Bundle();
    bundle.put(VERSION,Game.version);
    bundle.put(HERO,hero);
    bundle.put(GOLD,gold);
    bundle.put(DEPTH,depth);
    bundle.put(POS,potionOfStrength);
    bundle.put(SOU,scrollsOfUpgrade);
    bundle.put(AS,arcaneStyli);
    bundle.put(DV,dewVial);
    bundle.put(WT,transmutation);
    int count=0;
    int ids[]=new int[chapters.size()];
    for (    Integer id : chapters) {
      ids[count++]=id;
    }
    bundle.put(CHAPTERS,ids);
    Bundle quests=new Bundle();
    Ghost.Quest.storeInBundle(quests);
    Wandmaker.Quest.storeInBundle(quests);
    Blacksmith.Quest.storeInBundle(quests);
    Imp.Quest.storeInBundle(quests);
    bundle.put(QUESTS,quests);
    Room.storeRoomsInBundle(bundle);
    Statistics.storeInBundle(bundle);
    Journal.storeInBundle(bundle);
    if (quickslot instanceof Class) {
      bundle.put(QUICKSLOT,((Class<?>)quickslot).getName());
    }
    Scroll.save(bundle);
    Potion.save(bundle);
    Wand.save(bundle);
    Ring.save(bundle);
    Bundle badges=new Bundle();
    Badges.saveLocal(badges);
    bundle.put(BADGES,badges);
    OutputStream output=Game.instance.openFileOutput(fileName,Game.MODE_PRIVATE);
    Bundle.write(bundle,output);
    output.close();
  }
 catch (  Exception e) {
    GamesInProgress.setUnknown(hero.heroClass);
  }
}

Fixed version (ground truth):
public static void saveGame(String fileName) throws IOException {
  try {
    Bundle bundle=new Bundle();
    bundle.put(VERSION,Game.versionCode);
    bundle.put(HERO,hero);
    bundle.put(GOLD,gold);
    bundle.put(DEPTH,depth);
    bundle.put(POS,potionOfStrength);
    bundle.put(SOU,scrollsOfUpgrade);
    bundle.put(AS,arcaneStyli);
    bundle.put(DV,dewVial);
    bundle.put(WT,transmutation);
    int count=0;
    int ids[]=new int[chapters.size()];
    for (    Integer id : chapters) {
      ids[count++]=id;
    }
    bundle.put(CHAPTERS,ids);
    Bundle quests=new Bundle();
    Ghost.Quest.storeInBundle(quests);
    Wandmaker.Quest.storeInBundle(quests);
    Blacksmith.Quest.storeInBundle(quests);
    Imp.Quest.storeInBundle(quests);
    bundle.put(QUESTS,quests);
    Room.storeRoomsInBundle(bundle);
    Statistics.storeInBundle(bundle);
    Journal.storeInBundle(bundle);
    if (quickslot instanceof Class) {
      bundle.put(QUICKSLOT,((Class<?>)quickslot).getName());
    }
    Scroll.save(bundle);
    Potion.save(bundle);
    Wand.save(bundle);
    Ring.save(bundle);
    Bundle badges=new Bundle();
    Badges.saveLocal(badges);
    bundle.put(BADGES,badges);
    OutputStream output=Game.instance.openFileOutput(fileName,Game.MODE_PRIVATE);
    Bundle.write(bundle,output);
    output.close();
  }
 catch (  Exception e) {
    GamesInProgress.setUnknown(hero.heroClass);
  }
}
Program: 164450
Project: 164450
Buggy source:
private void restore(Bundle bundle,String[] allLabels,Integer[] allImages){
  ArrayList<String> labelsLeft=new ArrayList<String>(Arrays.asList(allLabels));
  ArrayList<Integer> imagesLeft=new ArrayList<Integer>(Arrays.asList(allImages));
  for (int i=0; i < items.length; i++) {
    Class<? extends T> item=(Class<? extends T>)(items[i]);
    String itemName=item.toString();
    if (bundle.contains(itemName + PFX_LABEL)) {
      String label=bundle.getString(itemName + PFX_LABEL);
      labels.put(item,label);
      labelsLeft.remove(label);
      Integer image=bundle.getInt(itemName + PFX_IMAGE);
      images.put(item,image);
      imagesLeft.remove(image);
      if (bundle.getBoolean(itemName + PFX_KNOWN)) {
        known.add(item);
      }
    }
 else {
      int index=Random.Int(labelsLeft.size());
      labels.put(item,labelsLeft.get(index));
      labelsLeft.remove(index);
      images.put(item,imagesLeft.get(index));
      imagesLeft.remove(index);
    }
  }
}

Fixed version (ground truth):
private void restore(Bundle bundle,String[] allLabels,Integer[] allImages){
  ArrayList<String> labelsLeft=new ArrayList<String>(Arrays.asList(allLabels));
  ArrayList<Integer> imagesLeft=new ArrayList<Integer>(Arrays.asList(allImages));
  for (int i=0; i < items.length; i++) {
    Class<? extends T> item=(Class<? extends T>)(items[i]);
    String itemName=item.toString();
    if (bundle.contains(itemName + PFX_LABEL) && Dungeon.version > 3) {
      String label=bundle.getString(itemName + PFX_LABEL);
      labels.put(item,label);
      labelsLeft.remove(label);
      Integer image=bundle.getInt(itemName + PFX_IMAGE);
      images.put(item,image);
      imagesLeft.remove(image);
      if (bundle.getBoolean(itemName + PFX_KNOWN)) {
        known.add(item);
      }
    }
 else {
      int index=Random.Int(labelsLeft.size());
      labels.put(item,labelsLeft.get(index));
      labelsLeft.remove(index);
      images.put(item,imagesLeft.get(index));
      imagesLeft.remove(index);
      if (bundle.contains(itemName + PFX_KNOWN) && bundle.getBoolean(itemName + PFX_KNOWN)) {
        known.add(item);
      }
    }
  }
}
Program: 164451
Project: 164451
Buggy source:
@Override public boolean act(){
  if (target.pos != pos || level <= 0) {
    detach();
  }
  if (count == 5) {
    if (level <= healCurr) {
      target.HP=Math.min(target.HT,target.HP + level);
      target.sprite.emitter().burst(Speck.factory(Speck.HEALING),1);
      detach();
    }
 else {
      target.HP=Math.min(target.HT,target.HP + (int)(healCurr * .025 * target.HT));
      level-=(healCurr * .025 * target.HT);
      if (healCurr < 6)       healCurr++;
      target.sprite.emitter().burst(Speck.factory(Speck.HEALING),1);
    }
    count=1;
  }
 else {
    count++;
  }
  spend(STEP);
  return true;
}

Fixed version (ground truth):
@Override public boolean act(){
  if (target.pos != pos) {
    detach();
  }
  if (count == 5) {
    if (level <= healCurr * .025 * target.HT) {
      target.HP=Math.min(target.HT,target.HP + level);
      target.sprite.emitter().burst(Speck.factory(Speck.HEALING),1);
      detach();
    }
 else {
      target.HP=Math.min(target.HT,target.HP + (int)(healCurr * .025 * target.HT));
      level-=(healCurr * .025 * target.HT);
      if (healCurr < 6)       healCurr++;
      target.sprite.emitter().burst(Speck.factory(Speck.HEALING),1);
    }
    count=1;
  }
 else {
    count++;
  }
  if (level <= 0)   detach();
  spend(STEP);
  return true;
}
Program: 164452
Project: 164452
Buggy source:
@Override public boolean act(){
  if (placed) {
    if (target instanceof Hero)     if (target.HP == target.HT) {
      GLog.i("String_Node_Str");
      detach();
    }
 else {
      GLog.i("String_Node_Str");
      Buff.affect(target,MagicalSleep.class);
      detach();
    }
 else     Buff.affect(target,MagicalSleep.class);
    return true;
  }
 else {
    placed=true;
    spend(STEP);
    return true;
  }
}

Fixed version (ground truth):
@Override public boolean act(){
  if (placed) {
    if (target instanceof Hero)     if (target.HP == target.HT) {
      GLog.i("String_Node_Str");
    }
 else {
      GLog.i("String_Node_Str");
      Buff.affect(target,MagicalSleep.class);
    }
 else     Buff.affect(target,MagicalSleep.class);
    detach();
    return true;
  }
 else {
    placed=true;
    spend(STEP);
    return true;
  }
}
Program: 164453
Project: 164453
Buggy source:
@Override public boolean act(){
  if (target.isAlive()) {
    if (target.HP < target.HT && !((Hero)target).isStarving()) {
      target.HP+=1;
    }
    ChaliceOfBlood.chaliceRegen regenBuff=Dungeon.hero.buff(ChaliceOfBlood.chaliceRegen.class);
    spend(REGENERATION_DELAY - regenBuff.level());
  }
 else {
    diactivate();
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean act(){
  if (target.isAlive()) {
    if (target.HP < target.HT && !((Hero)target).isStarving()) {
      target.HP+=1;
    }
    ChaliceOfBlood.chaliceRegen regenBuff=Dungeon.hero.buff(ChaliceOfBlood.chaliceRegen.class);
    if (regenBuff != null)     spend(REGENERATION_DELAY - regenBuff.level());
 else     spend(REGENERATION_DELAY);
  }
 else {
    diactivate();
  }
  return true;
}
Program: 164454
Project: 164454
Buggy source:
@Override public boolean act(){
  if (charge < chargeCap) {
    partialCharge+=(1 / (200 - level));
    if (partialCharge >= 1) {
      charge++;
      partialCharge-=1;
      if (charge == chargeCap) {
        GLog.p("String_Node_Str");
        partialCharge=0;
      }
    }
  }
 else   partialCharge=0;
  spend(TICK);
  return true;
}

Fixed version (ground truth):
@Override public boolean act(){
  if (charge < chargeCap) {
    partialCharge+=(1f / (200 - level));
    if (partialCharge >= 1) {
      charge++;
      partialCharge-=1;
      if (charge == chargeCap) {
        GLog.p("String_Node_Str");
        partialCharge=0;
      }
    }
  }
 else   partialCharge=0;
  spend(TICK);
  return true;
}
Program: 164455
Project: 164455
Buggy source:
@Override public void onSelect(Item item){
  if (item != null && item instanceof Food) {
    if (item instanceof Blandfruit && ((Blandfruit)item).potionAttrib == null) {
      GLog.w("String_Node_Str");
    }
 else {
      curItem.level+=((Food)item).hornValue;
      if (curItem.level >= 150) {
        curItem.level=150;
        GLog.p("String_Node_Str");
      }
 else       GLog.p("String_Node_Str");
      item.detach(Dungeon.hero.belongings.backpack);
    }
  }
}

Fixed version (ground truth):
@Override public void onSelect(Item item){
  if (item != null && item instanceof Food) {
    if (item instanceof Blandfruit && ((Blandfruit)item).potionAttrib == null) {
      GLog.w("String_Node_Str");
    }
 else {
      Hero hero=Dungeon.hero;
      hero.sprite.operate(hero.pos);
      hero.busy();
      hero.spend(TIME_TO_EAT);
      curItem.level+=((Food)item).hornValue;
      if (curItem.level >= 150) {
        curItem.level=150;
        GLog.p("String_Node_Str");
      }
 else       GLog.p("String_Node_Str");
      item.detach(Dungeon.hero.belongings.backpack);
    }
  }
}
Program: 164456
Project: 164456
Buggy source:
public static void process(){
  if (current != null) {
    return;
  }
  boolean doNext;
  do {
    now=Float.MAX_VALUE;
    current=null;
    Arrays.fill(chars,null);
    for (    Actor actor : all) {
      if (actor.time < now) {
        now=actor.time;
        current=actor;
      }
      if (actor instanceof Char) {
        Char ch=(Char)actor;
        chars[ch.pos]=ch;
      }
    }
    if (current != null) {
      doNext=current.act();
      if (doNext && !Dungeon.hero.isAlive()) {
        doNext=false;
        current=null;
      }
    }
 else {
      doNext=false;
    }
  }
 while (doNext);
}

Fixed version (ground truth):
public static void process(){
  if (current != null) {
    return;
  }
  boolean doNext;
  do {
    now=Float.MAX_VALUE;
    current=null;
    Arrays.fill(chars,null);
    for (    Actor actor : all) {
      if (actor.time < now || (actor instanceof Hero && actor.time == now)) {
        now=actor.time;
        current=actor;
      }
      if (actor instanceof Char) {
        Char ch=(Char)actor;
        chars[ch.pos]=ch;
      }
    }
    if (current != null) {
      doNext=current.act();
      if (doNext && !Dungeon.hero.isAlive()) {
        doNext=false;
        current=null;
      }
    }
 else {
      doNext=false;
    }
  }
 while (doNext);
}
Program: 164458
Project: 164458
Buggy source:
public void updateSpriteState(){
  for (  Buff buff : buffs) {
    if (buff instanceof Burning) {
      sprite.add(CharSprite.State.BURNING);
    }
 else     if (buff instanceof Levitation) {
      sprite.add(CharSprite.State.LEVITATING);
    }
 else     if (buff instanceof Invisibility) {
      sprite.add(CharSprite.State.INVISIBLE);
    }
 else     if (buff instanceof Paralysis) {
      sprite.add(CharSprite.State.PARALYSED);
    }
 else     if (buff instanceof Frost) {
      sprite.add(CharSprite.State.FROZEN);
    }
 else     if (buff instanceof Light) {
      sprite.add(CharSprite.State.ILLUMINATED);
    }
  }
}

Fixed version (ground truth):
public void updateSpriteState(){
  for (  Buff buff : buffs) {
    if (buff instanceof Burning) {
      sprite.add(CharSprite.State.BURNING);
    }
 else     if (buff instanceof Levitation) {
      sprite.add(CharSprite.State.LEVITATING);
    }
 else     if (buff instanceof Invisibility || buff instanceof CloakOfShadows.cloakStealth) {
      sprite.add(CharSprite.State.INVISIBLE);
    }
 else     if (buff instanceof Paralysis) {
      sprite.add(CharSprite.State.PARALYSED);
    }
 else     if (buff instanceof Frost) {
      sprite.add(CharSprite.State.FROZEN);
    }
 else     if (buff instanceof Light) {
      sprite.add(CharSprite.State.ILLUMINATED);
    }
  }
}
Program: 164459
Project: 164459
Buggy source:
@Override public void restoreFromBundle(Bundle bundle){
  super.restoreFromBundle(bundle);
  stealthed=bundle.getBoolean("String_Node_Str");
  if (stealthed) {
    Hero hero=Dungeon.hero;
    activeBuff=activeBuff();
    activeBuff.attachTo(hero);
    if (hero.sprite.parent != null) {
      hero.sprite.parent.add(new AlphaTweener(hero.sprite,0.4f,0.4f));
    }
 else {
      hero.sprite.alpha(0.4f);
    }
  }
}

Fixed version (ground truth):
@Override public void restoreFromBundle(Bundle bundle){
  super.restoreFromBundle(bundle);
  stealthed=bundle.getBoolean("String_Node_Str");
}
Program: 164460
Project: 164460
Buggy source:
@Override public void detach(){
  target.invisible--;
  super.detach();
}

Fixed version (ground truth):
@Override public void detach(){
  if (target.invisible > 0)   target.invisible--;
  super.detach();
}
Program: 164461
Project: 164461
Buggy source:
@Override public boolean act(){
  charge--;
  if (charge <= 0) {
    detach();
    GLog.w("String_Node_Str");
  }
 else   if (charge == 2)   GLog.w("String_Node_Str");
  exp+=10 + ((Hero)target).lvl;
  if (exp >= level * 50 && level < 26) {
    exp-=level * 50;
    GLog.p("String_Node_Str");
    level++;
    chargeCap++;
  }
  spend(TICK);
  return true;
}

Fixed version (ground truth):
@Override public boolean act(){
  charge--;
  if (charge <= 0) {
    detach();
    GLog.w("String_Node_Str");
  }
  exp+=10 + ((Hero)target).lvl;
  if (exp >= level * 50 && level < 26) {
    exp-=level * 50;
    GLog.p("String_Node_Str");
    level++;
    chargeCap++;
  }
  spend(TICK);
  return true;
}
Program: 164462
Project: 164462
Buggy source:
@Override public void detach(){
  target.invisible--;
  stealthed=false;
  cooldown=18 - (level / 2);
  super.detach();
}

Fixed version (ground truth):
@Override public void detach(){
  if (target.invisible > 0)   target.invisible--;
  stealthed=false;
  cooldown=18 - (level / 2);
  super.detach();
}
Program: 164463
Project: 164463
Buggy source:
@Override public boolean attachTo(Char target){
  if (super.attachTo(target)) {
    target.invisible++;
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
@Override public boolean attachTo(Char target){
  if (super.attachTo(target)) {
    target.invisible++;
    spend(TICK);
    return true;
  }
 else {
    return false;
  }
}
Program: 164464
Project: 164464
Buggy source:
@Override public void apply(Hero hero){
  setKnown();
  hero.STR++;
  hero.HT+=5;
  hero.HP+=5;
  hero.sprite.showStatus(CharSprite.POSITIVE,"String_Node_Str");
  GLog.p("String_Node_Str");
}

Fixed version (ground truth):
@Override public void apply(Hero hero){
  setKnown();
  hero.STR++;
  hero.HT+=5;
  hero.HP+=5;
  hero.sprite.showStatus(CharSprite.POSITIVE,"String_Node_Str");
  GLog.p("String_Node_Str");
  Badges.validateStrengthAttained();
}
Program: 164465
Project: 164465
Buggy source:
@Override public void storeInBundle(Bundle bundle){
}

Fixed version (ground truth):
@Override public void storeInBundle(Bundle bundle){
  super.storeInBundle(bundle);
  bundle.put(NAME,name);
}
Program: 164468
Project: 164468
Buggy source:
@Override public void die(Object cause){
  curAction=null;
  Ankh ankh=(Ankh)belongings.getItem(Ankh.class);
  if (ankh != null && ankh.isBlessed()) {
    this.HP=HT;
    new Flare(8,32).color(0xFFFF66,true).show(sprite,2f);
    ankh.detach(belongings.backpack);
    Sample.INSTANCE.play(Assets.SND_TELEPORT);
    GLog.w(ankh.TXT_REVIVE);
    return;
  }
  Actor.fixTime();
  super.die(cause);
  if (ankh == null) {
    reallyDie(cause);
  }
 else {
    Dungeon.deleteGame(Dungeon.hero.heroClass,false);
    GameScene.show(new WndResurrect(ankh,cause));
  }
}

Fixed version (ground truth):
@Override public void die(Object cause){
  curAction=null;
  Ankh ankh=(Ankh)belongings.getItem(Ankh.class);
  if (ankh != null && ankh.isBlessed()) {
    this.HP=HT;
    new Flare(8,32).color(0xFFFF66,true).show(sprite,2f);
    CellEmitter.get(this.pos).start(Speck.factory(Speck.LIGHT),0.2f,3);
    ankh.detach(belongings.backpack);
    Sample.INSTANCE.play(Assets.SND_TELEPORT);
    GLog.w(ankh.TXT_REVIVE);
    return;
  }
  Actor.fixTime();
  super.die(cause);
  if (ankh == null) {
    reallyDie(cause);
  }
 else {
    Dungeon.deleteGame(Dungeon.hero.heroClass,false);
    GameScene.show(new WndResurrect(ankh,cause));
  }
}