gt:             bonus += ((RingOfAccuracy.Accuracy) buff).level;
context: /*
   * Pixel Dungeon
   * Copyright (C) 2012-2015 Oleg Dolya
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
   *
   * You should have received a copy of the GNU General Public License
   * along with this program.  If not, see <http://www.gnu.org/licenses/>
   */
  package com.github.mdsimmo.pixeldungeon.actors.hero;
  
  import com.github.mdsimmo.noosa.Camera;
  import com.github.mdsimmo.noosa.Game;
  import com.github.mdsimmo.noosa.audio.Sample;
  import com.github.mdsimmo.pixeldungeon.Assets;
  import com.github.mdsimmo.pixeldungeon.Badges;
  import com.github.mdsimmo.pixeldungeon.Bones;
  import com.github.mdsimmo.pixeldungeon.Dungeon;
  import com.github.mdsimmo.pixeldungeon.GamesInProgress;
  import com.github.mdsimmo.pixeldungeon.ResultDescriptions;
  import com.github.mdsimmo.pixeldungeon.actors.Actor;
  import com.github.mdsimmo.pixeldungeon.actors.Char;
  import com.github.mdsimmo.pixeldungeon.actors.buffs.Barkskin;
  import com.github.mdsimmo.pixeldungeon.actors.buffs.Bleeding;
  import com.github.mdsimmo.pixeldungeon.actors.buffs.Blindness;
  import com.github.mdsimmo.pixeldungeon.actors.buffs.Buff;
  import com.github.mdsimmo.pixeldungeon.actors.buffs.Burning;
  import com.github.mdsimmo.pixeldungeon.actors.buffs.Charm;
  import com.github.mdsimmo.pixeldungeon.actors.buffs.Combo;
  import com.github.mdsimmo.pixeldungeon.actors.buffs.Cripple;
  import com.github.mdsimmo.pixeldungeon.actors.buffs.Fury;
  import com.github.mdsimmo.pixeldungeon.actors.buffs.GasesImmunity;
  import com.github.mdsimmo.pixeldungeon.actors.buffs.Hunger;
  import com.github.mdsimmo.pixeldungeon.actors.buffs.Invisibility;
  import com.github.mdsimmo.pixeldungeon.actors.buffs.Light;
  import com.github.mdsimmo.pixeldungeon.actors.buffs.Ooze;
  import com.github.mdsimmo.pixeldungeon.actors.buffs.Paralysis;
  import com.github.mdsimmo.pixeldungeon.actors.buffs.Poison;
  import com.github.mdsimmo.pixeldungeon.actors.buffs.Regeneration;
  import com.github.mdsimmo.pixeldungeon.actors.buffs.Roots;
  import com.github.mdsimmo.pixeldungeon.actors.buffs.SnipersMark;
  import com.github.mdsimmo.pixeldungeon.actors.buffs.Vertigo;
  import com.github.mdsimmo.pixeldungeon.actors.buffs.Weakness;
  import com.github.mdsimmo.pixeldungeon.actors.mobs.Mob;
  import com.github.mdsimmo.pixeldungeon.actors.mobs.npcs.NPC;
  import com.github.mdsimmo.pixeldungeon.effects.CheckedCell;
  import com.github.mdsimmo.pixeldungeon.effects.Flare;
  import com.github.mdsimmo.pixeldungeon.effects.Speck;
  import com.github.mdsimmo.pixeldungeon.items.Amulet;
  import com.github.mdsimmo.pixeldungeon.items.Ankh;
  import com.github.mdsimmo.pixeldungeon.items.DewVial;
  import com.github.mdsimmo.pixeldungeon.items.Dewdrop;
  import com.github.mdsimmo.pixeldungeon.items.Heap;
  import com.github.mdsimmo.pixeldungeon.items.Heap.Type;
  import com.github.mdsimmo.pixeldungeon.items.Item;
  import com.github.mdsimmo.pixeldungeon.items.KindOfWeapon;
  import com.github.mdsimmo.pixeldungeon.items.armor.Armor;
  import com.github.mdsimmo.pixeldungeon.items.keys.GoldenKey;
  import com.github.mdsimmo.pixeldungeon.items.keys.IronKey;
  import com.github.mdsimmo.pixeldungeon.items.keys.Key;
  import com.github.mdsimmo.pixeldungeon.items.keys.SkeletonKey;
  import com.github.mdsimmo.pixeldungeon.items.potions.Potion;
  import com.github.mdsimmo.pixeldungeon.items.potions.PotionOfStrength;
  import com.github.mdsimmo.pixeldungeon.items.rings.RingOfAccuracy;
  import com.github.mdsimmo.pixeldungeon.items.rings.RingOfDetection;
  import com.github.mdsimmo.pixeldungeon.items.rings.RingOfElements;
  import com.github.mdsimmo.pixeldungeon.items.rings.RingOfEvasion;
  import com.github.mdsimmo.pixeldungeon.items.rings.RingOfHaste;
  import com.github.mdsimmo.pixeldungeon.items.rings.RingOfShadows;
  import com.github.mdsimmo.pixeldungeon.items.rings.RingOfThorns;
  import com.github.mdsimmo.pixeldungeon.items.scrolls.Scroll;
  import com.github.mdsimmo.pixeldungeon.items.scrolls.ScrollOfEnchantment;
  import com.github.mdsimmo.pixeldungeon.items.scrolls.ScrollOfMagicMapping;
  import com.github.mdsimmo.pixeldungeon.items.scrolls.ScrollOfRecharging;
  import com.github.mdsimmo.pixeldungeon.items.scrolls.ScrollOfUpgrade;
  import com.github.mdsimmo.pixeldungeon.items.wands.Wand;
  import com.github.mdsimmo.pixeldungeon.items.weapon.melee.MeleeWeapon;
  import com.github.mdsimmo.pixeldungeon.items.weapon.missiles.MissileWeapon;
  import com.github.mdsimmo.pixeldungeon.levels.Level;
  import com.github.mdsimmo.pixeldungeon.levels.Terrain;
  import com.github.mdsimmo.pixeldungeon.levels.features.AlchemyPot;
  import com.github.mdsimmo.pixeldungeon.levels.features.Chasm;
  import com.github.mdsimmo.pixeldungeon.levels.features.Sign;
  import com.github.mdsimmo.pixeldungeon.plants.Earthroot;
  import com.github.mdsimmo.pixeldungeon.scenes.GameScene;
  import com.github.mdsimmo.pixeldungeon.scenes.InterlevelScene;
  import com.github.mdsimmo.pixeldungeon.scenes.SurfaceScene;
  import com.github.mdsimmo.pixeldungeon.sprites.CharSprite;
  import com.github.mdsimmo.pixeldungeon.sprites.HeroSprite;
  import com.github.mdsimmo.pixeldungeon.ui.AttackIndicator;
  import com.github.mdsimmo.pixeldungeon.ui.BuffIndicator;
  import com.github.mdsimmo.pixeldungeon.utils.GLog;
  import com.github.mdsimmo.pixeldungeon.windows.WndMessage;
  import com.github.mdsimmo.pixeldungeon.windows.WndResurrect;
  import com.github.mdsimmo.pixeldungeon.windows.WndTradeItem;
  import com.github.mdsimmo.utils.Bundle;
  import com.github.mdsimmo.utils.Random;
  
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.HashSet;
  
  public class Hero extends Char {
  
      private static final String TXT_LEAVE = "One does not simply leave Pixel Dungeon.";
  
      private static final String TXT_LEVEL_UP = "level up!";
      private static final String TXT_NEW_LEVEL =
              "Welcome to level %d! Now you are healthier and more focused. " +
                      "It's easier for you to hit enemies and dodge their attacks.";
  
      public static final String TXT_YOU_NOW_HAVE = "You now have %s";
  
      private static final String TXT_SOMETHING_ELSE = "There is something else here";
      private static final String TXT_LOCKED_CHEST = "This chest is locked and you don't have matching key";
      private static final String TXT_LOCKED_DOOR = "You don't have a matching key";
      private static final String TXT_NOTICED_SMTH = "You noticed something";
  
      private static final String TXT_WAIT = "...";
      private static final String TXT_SEARCH = "search";
  
      public static final int STARTING_STR = 10;
  
      private static final float TIME_TO_REST = 1f;
      private static final float TIME_TO_SEARCH = 2f;
  
      public HeroClass heroClass = HeroClass.ROGUE;
      public HeroSubClass subClass = HeroSubClass.NONE;
  
      private int attackSkill = 10;
      private int defenseSkill = 5;
  
  
      public boolean ready = false;
  
      public HeroAction curAction = null;
      public HeroAction lastAction = null;
  
      private Char enemy;
  
      public Armor.Glyph killerGlyph = null;
  
      private Item theKey;
  
      public boolean restoreHealth = false;
  
      public MissileWeapon rangedWeapon = null;
      public Belongings belongings;
  
      public int STR;
      public boolean weakened = false;
  
      public float awareness;
  
      public int lvl = 1;
      public int exp = 0;
  
      private ArrayList<Mob> visibleEnemies;
  
      public Hero() {
          super();
          name = "you";
  
          HP = HT = 20;
          STR = STARTING_STR;
          awareness = 0.1f;
  
          belongings = new Belongings( this );
  
          visibleEnemies = new ArrayList<>();
      }
  
      public int STR() {
          return weakened ? STR - 2 : STR;
      }
  
      private static final String ATTACK = "attackSkill";
      private static final String DEFENSE = "defenseSkill";
      private static final String STRENGTH = "STR";
      private static final String LEVEL = "lvl";
      private static final String EXPERIENCE = "exp";
  
      @Override
      public void storeInBundle( Bundle bundle ) {
          super.storeInBundle( bundle );
  
          heroClass.storeInBundle( bundle );
          subClass.storeInBundle( bundle );
  
          bundle.put( ATTACK, attackSkill );
          bundle.put( DEFENSE, defenseSkill );
  
          bundle.put( STRENGTH, STR );
  
          bundle.put( LEVEL, lvl );
          bundle.put( EXPERIENCE, exp );
  
          belongings.storeInBundle( bundle );
      }
  
      @Override
      public void restoreFromBundle( Bundle bundle ) {
          super.restoreFromBundle( bundle );
  
          heroClass = HeroClass.restoreInBundle( bundle );
          subClass = HeroSubClass.restoreInBundle( bundle );
  
          attackSkill = bundle.getInt( ATTACK );
          defenseSkill = bundle.getInt( DEFENSE );
  
          STR = bundle.getInt( STRENGTH );
          updateAwareness();
  
          lvl = bundle.getInt( LEVEL );
          exp = bundle.getInt( EXPERIENCE );
  
          belongings.restoreFromBundle( bundle );
      }
  
      public static void preview( GamesInProgress.Info info, Bundle bundle ) {
          info.level = bundle.getInt( LEVEL );
      }
  
      public String className() {
          return subClass == null || subClass == HeroSubClass.NONE ? heroClass.title() : subClass.title();
      }
  
      public void live() {
          Buff.affect( this, Regeneration.class );
          Buff.affect( this, Hunger.class );
      }
  
      public int tier() {
          return belongings.armor == null ? 0 : belongings.armor.tier;
      }
  
      public boolean shoot( Char enemy, MissileWeapon wep ) {
  
          rangedWeapon = wep;
          boolean result = attack( enemy );
          rangedWeapon = null;
  
          return result;
      }
  
      @Override
      public int attackSkill( Char target ) {
  
          int bonus = 0;
          for ( Buff buff : buffs( RingOfAccuracy.Accuracy.class ) ) {
  