context: using System;
  using System.Linq;
  using System.Collections.Generic;
  using System.IO;
  using Android.Content;
  using pdsharp.noosa;
  using pdsharp.utils;
  using sharpdungeon.actors.hero;
  using sharpdungeon.actors.mobs;
  using sharpdungeon.items;
  using sharpdungeon.items.bags;
  using sharpdungeon.items.potions;
  using sharpdungeon.items.rings;
  using sharpdungeon.items.scrolls;
  using sharpdungeon.items.wands;
  using sharpdungeon.scenes;
  using sharpdungeon.utils;
  
  namespace sharpdungeon
  {
      public class Badge
      {
          public static Badge MONSTERS_SLAIN_1 = new Badge("10 enemies slain", 0);
  
          public static Badge MONSTERS_SLAIN_2 = new Badge("50 enemies slain", 1);
          public static Badge MONSTERS_SLAIN_3 = new Badge("150 enemies slain", 2);
          public static Badge MONSTERS_SLAIN_4 = new Badge("250 enemies slain", 3);
          public static Badge GOLD_COLLECTED_1 = new Badge("100 gold collected", 4);
          public static Badge GOLD_COLLECTED_2 = new Badge("500 gold collected", 5);
          public static Badge GOLD_COLLECTED_3 = new Badge("2500 gold collected", 6);
          public static Badge GOLD_COLLECTED_4 = new Badge("7500 gold collected", 7);
          public static Badge LEVEL_REACHED_1 = new Badge("Level 6 reached", 8);
          public static Badge LEVEL_REACHED_2 = new Badge("Level 12 reached", 9);
          public static Badge LEVEL_REACHED_3 = new Badge("Level 18 reached", 10);
          public static Badge LEVEL_REACHED_4 = new Badge("Level 24 reached", 11);
          public static Badge ALL_POTIONS_IDENTIFIED = new Badge("All potions identified", 16);
          public static Badge ALL_SCROLLS_IDENTIFIED = new Badge("All scrolls identified", 17);
          public static Badge ALL_RINGS_IDENTIFIED = new Badge("All rings identified", 18);
          public static Badge ALL_WANDS_IDENTIFIED = new Badge("All wands identified", 19);
  
          public static Badge ALL_ITEMS_IDENTIFIED = new Badge("All potions, scrolls, rings & wands identified", 35, true);
  
          public static Badge BAG_BOUGHT_SEED_POUCH;
          public static Badge BAG_BOUGHT_SCROLL_HOLDER;
          public static Badge BAG_BOUGHT_WAND_HOLSTER;
  
          public static Badge ALL_BAGS_BOUGHT = new Badge("All bags bought", 23);
  
          public static Badge DEATH_FROM_FIRE = new Badge("Death from fire", 24);
  
          public static Badge DEATH_FROM_POISON = new Badge("Death from poison", 25);
  
          public static Badge DEATH_FROM_GAS = new Badge("Death from toxic gas", 26);
  
          public static Badge DEATH_FROM_HUNGER = new Badge("Death from hunger", 27);
  
          public static Badge DEATH_FROM_GLYPH = new Badge("Death from a glyph", 57);
  
          public static Badge DEATH_FROM_FALLING = new Badge("Death from falling down", 59);
  
          public static Badge YASD = new Badge("Death from fire, poison, toxic gas & hunger", 34, true);
          public static Badge BOSS_SLAIN_1_WARRIOR;
          public static Badge BOSS_SLAIN_1_MAGE;
          public static Badge BOSS_SLAIN_1_ROGUE;
          public static Badge BOSS_SLAIN_1_HUNTRESS;
  
          public static Badge BOSS_SLAIN_1 = new Badge("1st boss slain", 12);
  
          public static Badge BOSS_SLAIN_2 = new Badge("2nd boss slain", 13);
  
          public static Badge BOSS_SLAIN_3 = new Badge("3rd boss slain", 14);
  
          public static Badge BOSS_SLAIN_4 = new Badge("4th boss slain", 15);
  
          public static Badge BOSS_SLAIN_1_ALL_CLASSES = new Badge("1st boss slain by Warrior, Mage, Rogue & Huntress", 32, true);
          public static Badge BOSS_SLAIN_3_GLADIATOR;
          public static Badge BOSS_SLAIN_3_BERSERKER;
          public static Badge BOSS_SLAIN_3_WARLOCK;
          public static Badge BOSS_SLAIN_3_BATTLEMAGE;
          public static Badge BOSS_SLAIN_3_FREERUNNER;
          public static Badge BOSS_SLAIN_3_ASSASSIN;
          public static Badge BOSS_SLAIN_3_SNIPER;
          public static Badge BOSS_SLAIN_3_WARDEN;
  
          public static Badge BOSS_SLAIN_3_ALL_SUBCLASSES = new Badge("3rd boss slain by Gladiator, Berserker, Warlock, Battlemage, Freerunner, Assassin, Sniper & Warden", 33, true);
  
          public static Badge RING_OF_HAGGLER = new Badge("Ring of Haggler obtained", 20);
  
          public static Badge RING_OF_THORNS = new Badge("Ring of Thorns obtained", 21);
  
          public static Badge STRENGTH_ATTAINED_1 = new Badge("13 points of Strength attained", 40);
  
          public static Badge STRENGTH_ATTAINED_2 = new Badge("15 points of Strength attained", 41);
  
          public static Badge STRENGTH_ATTAINED_3 = new Badge("17 points of Strength attained", 42);
  
          public static Badge STRENGTH_ATTAINED_4 = new Badge("19 points of Strength attained", 43);
  
          public static Badge FOOD_EATEN_1 = new Badge("10 pieces of food eaten", 44);
  
          public static Badge FOOD_EATEN_2 = new Badge("20 pieces of food eaten", 45);
  
          public static Badge FOOD_EATEN_3 = new Badge("30 pieces of food eaten", 46);
  
          public static Badge FOOD_EATEN_4 = new Badge("40 pieces of food eaten", 47);
          public static Badge MASTERY_WARRIOR;
          public static Badge MASTERY_MAGE;
          public static Badge MASTERY_ROGUE;
          public static Badge MASTERY_HUNTRESS;
  
          public static Badge ITEM_LEVEL_1 = new Badge("Item of Level 3 acquired", 48);
  
          public static Badge ITEM_LEVEL_2 = new Badge("Item of Level 6 acquired", 49);
  
          public static Badge ITEM_LEVEL_3 = new Badge("Item of Level 9 acquired", 50);
  
          public static Badge ITEM_LEVEL_4 = new Badge("Item of Level 12 acquired", 51);
          public static Badge RARE_ALBINO;
          public static Badge RARE_BANDIT;
          public static Badge RARE_SHIELDED;
          public static Badge RARE_SENIOR;
          public static Badge RARE_ACIDIC;
  
          public static Badge RARE = new Badge("All rare monsters slain", 37, true);
          public static Badge VICTORY_WARRIOR;
          public static Badge VICTORY_MAGE;
          public static Badge VICTORY_ROGUE;
          public static Badge VICTORY_HUNTRESS;
  
          public static Badge VICTORY = new Badge("Amulet of Yendor obtained", 22);
  
          public static Badge VICTORY_ALL_CLASSES = new Badge("Amulet of Yendor obtained by Warrior, Mage, Rogue & Huntress", 36, true);
  
          public static Badge MASTERY_COMBO = new Badge("7-hit combo", 56);
  
          public static Badge POTIONS_COOKED_1 = new Badge("3 potions cooked", 52);
  
          public static Badge POTIONS_COOKED_2 = new Badge("6 potions cooked", 53);
  
          public static Badge POTIONS_COOKED_3 = new Badge("9 potions cooked", 54);
  
          public static Badge POTIONS_COOKED_4 = new Badge("12 potions cooked", 55);
  
          public static Badge NO_MONSTERS_SLAIN = new Badge("Level completed without killing any monsters", 28);
  
          public static Badge GRIM_WEAPON = new Badge("Monster killed by a Grim weapon", 29);
  
          public static Badge PIRANHAS = new Badge("6 piranhas killed", 30);
  
          public static Badge NIGHT_HUNTER = new Badge("15 monsters killed at nighttime", 58);
  
          public static Badge GAMES_PLAYED_1 = new Badge("10 games played", 60, true);
  
          public static Badge GAMES_PLAYED_2 = new Badge("100 games played", 61, true);
  
          public static Badge GAMES_PLAYED_3 = new Badge("500 games played", 62, true);
  
          public static Badge GAMES_PLAYED_4 = new Badge("2000 games played", 63, true);
  
          public static Badge HAPPY_END = new Badge("Happy end", 38);
  
          public static Badge CHAMPION = new Badge("Challenge won", 39, true);
  
          public static Badge SUPPORTER = new Badge("Thanks for your support!", 31, true);
  
  
          public bool Meta;
  
          public string Description;
  
          public int Image;
  
  
          private Badge(string description, int image, bool meta = false)
          {
              Description = description;
              Image = image;
              Meta = meta;
          }
  
          private Badge()
              : this("", -1)
          {
          }
  
          private static List<Badge> _global;
          private static List<Badge> _local = new List<Badge>();
  
          private static bool _saveNeeded;
  
          public static void Reset()
          {
              _local.Clear();
              LoadGlobal();
          }
  
          private const string BadgesFile = "badges.dat";
          private const string Badges = "badges";
  
          private static List<Badge> Restore(Bundle bundle)
          {
              var badges = new List<Badge>();
  
              var names = bundle.GetStringArray(Badges);
              foreach (var name in names)
              {
                  try
                  {
                      //badges.Add(new Badge(
  
                      //    Enum.Parse = new Badge(typeof = new Badge(Badge), names[i])
  
                      //    );
                  }
                  catch (Exception)
                  {
                  }
              }
  
              return badges;
          }
  
          private static void Store(Bundle bundle, IEnumerable<Badge> badges)
          {
              var count = 0;
              var names = new string[badges.Count()];
  
              foreach (var badge in badges)
                  names[count++] = badge.ToString();
  
              bundle.Put(Badges, names);
          }
  
          public static void LoadLocal(Bundle bundle)
          {
  
gt:             _local = Restore(bundle);