import random

class Item():
    def __init__(self, name, hex):
        self.name = name
        self.hex = hex

    def __str__(self):
        return  self.name

    @staticmethod
    def fromBytes(hex):
        return Item.reverse[hex]

    @staticmethod
    def buildReverse():
        reverse = {}
        Item.members = [attr for attr in dir(Item) if not callable(getattr(Item, attr)) and not attr.startswith("__")]
        for member in Item.members:
            item = getattr(Item, member)
            reverse[item.hex] = item

        Item.reverse = reverse

    @staticmethod
    def rnd():
        return getattr(Item, random.choice(Item.members))


Item.NOTHING = Item('Nothing', 0x00)
Item.MASTER_BALL = Item("Master Ball", 0x01)
Item.ULTRA_BALL = Item("Ultra Ball", 0x02)
Item.BRIGHT_POWDER = Item("BrightPowder", 0x03)
Item.GREAT_BALL = Item("Great Ball", 0x04)
Item.POKE_BALL = Item("Poke Ball", 0x05)
Item.BICYCLE = Item("Bicycle", 0x06)
Item.MOON_STONE = Item("Moon Stone", 0x08)
Item.ANTIDOTE = Item("Antidote", 0x09)
Item.BURN_HEAL = Item("Burn Heal", 0x0A)
Item.ICE_HEAL = Item("Ice Heal", 0x0B)
Item.AWAKENING = Item("Awakening", 0x0C)
Item.PARLYZ_HEAL = Item("Parlyz Heal", 0x0D)
Item.FULL_RESTORE = Item("Full Restore", 0x0E)
Item.MAX_POTION = Item("Max Potion", 0x0F)
Item.HYPER_POTION = Item("Hyper Potion", 0x10)
Item.SUPER_POTION = Item("Super Potion", 0x11)
Item.POTION = Item("Potion", 0x12)
Item.ESCAPE_ROPE = Item("Escape Rope", 0x13)
Item.REPEL = Item("Repel", 0x14)
Item.MAX_ELIXER = Item("Max Elixer", 0x15)
Item.FIRE_STONE = Item("Fire Stone", 0x16)
Item.THUNDER_STONE = Item("Thunder Stone", 0x17)
Item.WATER_STONE = Item("Water Stone", 0x18)
Item.HP_UP = Item("HP Up", 0x1A)
Item.PROTEIN = Item("Protein", 0x1B)
Item.IRON = Item("Iron", 0x1C)
Item.CARBOS = Item("Carbos", 0x1D)
Item.LUCKY_PUNCH = Item("Lucky Punch", 0x1E)
Item.CALCIUM = Item("Calcium", 0x1F)
Item.RARE_CANDY = Item("Rare Candy", 0x20)
Item.X_ACCURACY = Item("X Accuracy", 0x21)
Item.LEAF_STONE = Item("Leaf Stone", 0x22)
Item.METAL_POWDER = Item("Metal Powder", 0x23)
Item.NUGGET = Item("Nugget", 0x24)
Item.POKE_DOLL = Item("Poke Doll", 0x25)
Item.FULL_HEAL = Item("Full Heal", 0x26)
Item.REVIVE = Item("Revive", 0x27)
Item.MAX_REVIVE = Item("Max Revive", 0x28)
Item.GUARD_SPEC = Item("Guard Spec.", 0x29)
Item.SUPER_REPEL = Item("Super Repel", 0x2A)
Item.MAX_REPEL = Item("Max Repel", 0x2B)
Item.DIRE_HIT = Item("Dire Hit", 0x2C)
Item.FRESH_WATER = Item("Fresh Water", 0x2E)
Item.SODA_POP = Item("Soda Pop", 0x2F)
Item.LEMONADE = Item("Lemonade", 0x30)
Item.X_ATTACK = Item("X Attack", 0x31)
Item.X_DEFEND = Item("X Defend", 0x33)
Item.X_SPEED = Item("X Speed", 0x34)
Item.X_SPECIAL = Item("X Special", 0x35)
Item.COIN_CASE = Item("Coin Case", 0x36)
Item.ITEMFINDER = Item("Itemfinder", 0x37)
Item.EXP_SHARE = Item("Exp Share", 0x39)
Item.OLD_ROD = Item("Old Rod", 0x3A)
Item.GOOD_ROD = Item("Good Rod", 0x3B)
Item.SILVER_LEAF = Item("Silver Leaf", 0x3C)
Item.SUPER_ROD = Item("Super Rod", 0x3D)
Item.PP_UP = Item("PP Up", 0x3E)
Item.ETHER = Item("Ether", 0x3F)
Item.MAX_ETHER = Item("Max Ether", 0x40)
Item.ELIXER = Item("Elixer", 0x41)
Item.RED_SCALE = Item("Red Scale", 0x42)
Item.SECRET_POTION = Item("SecretPotion", 0x43)
Item.SS_TICKET = Item("S.S. Ticket", 0x44)
Item.MYSTERY_EGG = Item("Mystery Egg", 0x45)
Item.CLEAR_BELL = Item("Clear Bell*", 0x46)
Item.SILVER_WING = Item("Silver Wing", 0x47)
Item.MOOMOO_MILK = Item("Moomoo Milk", 0x48)
Item.QUICK_CLAW = Item("Quick Claw", 0x49)
Item.PSN_CURE_BERRY = Item("PSNCureBerry", 0x4A)
Item.GOLD_LEAF = Item("Gold Leaf", 0x4B)
Item.SOFT_SAND = Item("Soft Sand", 0x4C)
Item.SHARP_BEAK = Item("Sharp Beak", 0x4D)
Item.PRZ_CURE_BERRY = Item("PRZCureBerry", 0x4E)
Item.BURNT_BERRY = Item("Burnt Berry", 0x4F)
Item.ICE_BERRY = Item("Ice Berry", 0x50)
Item.POISON_BARB = Item("Poison Barb", 0x51)
Item.KINGS_ROCK = Item("King's Rock", 0x52)
Item.BITTER_BERRY = Item("Bitter Berry", 0x53)
Item.MINT_BERRY = Item("Mint Berry", 0x54)
Item.RED_APRICORN = Item("Red Apricorn", 0x55)
Item.TINY_MUSHROOM = Item("TinyMushroom", 0x56)
Item.BIG_MUSHROOM = Item("Big Mushroom", 0x57)
Item.SILVER_POWDER = Item("SilverPowder", 0x58)
Item.BLU_APRICORN = Item("Blu Apricorn", 0x59)
Item.AMULET_COIN = Item("Amulet Coin", 0x5B)
Item.YLW_APRICORN = Item("Ylw Apricorn", 0x5C)
Item.GRN_APRICORN = Item("Grn Apricorn", 0x5D)
Item.CLEANSE_TAG = Item("Cleanse Tag", 0x5E)
Item.MYSTIC_WATER = Item("Mystic Water", 0x5F)
Item.TWISTED_SPOON = Item("TwistedSpoon", 0x60)
Item.WHT_APRICORN = Item("Wht Apricorn", 0x61)
Item.BLACK_BELT = Item("Black Belt", 0x62)
Item.BLK_APRICORN = Item("Blk Apricorn", 0x63)
Item.PNK_APRICORN = Item("Pnk Apricorn", 0x65)
Item.BLACK_GLASSES = Item("BlackGlasses", 0x66)
Item.SLOWPOKE_TAIL = Item("SlowpokeTail", 0x67)
Item.PINK_BOW = Item("Pink Bow", 0x68)
Item.STICK = Item("Stick", 0x69)
Item.SMOKE_BALL = Item("Smoke Ball", 0x6A)
Item.NEVER_MELT_ICE = Item("NeverMeltIce", 0x6B)
Item.MAGNET = Item("Magnet", 0x6C)
Item.MIRACLE_BERRY = Item("MiracleBerry", 0x6D)
Item.PEARL = Item("Pearl", 0x6E)
Item.BIG_PEARL = Item("Big Pearl", 0x6F)
Item.EVERSTONE = Item("Everstone", 0x70)
Item.SPELL_TAG = Item("Spell Tag", 0x71)
Item.RAGE_CANDY_BAR = Item("RageCandyBar", 0x72)
Item.GS_BALL = Item("GS Ball*", 0x73)
Item.BLUE_CARD = Item("Blue Card*", 0x74)
Item.MIRACLE_SEED = Item("Miracle Seed", 0x75)
Item.THICK_CLUB = Item("Thick Club", 0x76)
Item.FOCUS_BAND = Item("Focus Band", 0x77)
Item.ENERGY_POWDER = Item("EnergyPowder", 0x79)
Item.ENERGY_ROOT = Item("Energy Root", 0x7A)
Item.HEAL_POWDER = Item("Heal Powder", 0x7B)
Item.REVIVAL_HERB = Item("Revival Herb", 0x7C)
Item.HARD_STONE = Item("Hard Stone", 0x7D)
Item.LUCKY_EGG = Item("Lucky Egg", 0x7E)
Item.CARD_KEY = Item("Card Key", 0x7F)
Item.MACHINE_PART = Item("Machine Part", 0x80)
Item.EGG_TICKET = Item("Egg Ticket*", 0x81)
Item.LOST_ITEM = Item("Lost Item", 0x82)
Item.STARDUST = Item("Stardust", 0x83)
Item.STAR_PIECE = Item("Star Piece", 0x84)
Item.BASEMENT_KEY = Item("Basement Key", 0x85)
Item.PASS = Item("Pass", 0x86)
Item.CHARCOAL = Item("Charcoal", 0x8A)
Item.BERRY_JUICE = Item("Berry Juice", 0x8B)
Item.SCOPE_LENS = Item("Scope Lens", 0x8C)
Item.METAL_COAT = Item("Metal Coat", 0x8F)
Item.DRAGON_FANG = Item("Dragon Fang", 0x90)
Item.LEFTOVERS = Item("Leftovers", 0x92)
Item.MYSTERY_BERRY = Item("MysteryBerry", 0x96)
Item.DRAGON_SCALE = Item("Dragon Scale", 0x97)
Item.BERSERK_GENE = Item("Berserk Gene", 0x98)
Item.SACRED_ASH = Item("Sacred Ash", 0x9C)
Item.HEAVY_BALL = Item("Heavy Ball", 0x9D)
Item.FLOWER_MAIL = Item("Flower Mail", 0x9E)
Item.LEVEL_BALL = Item("Level Ball", 0x9F)
Item.LURE_BALL = Item("Lure Ball", 0xA0)
Item.FAST_BALL = Item("Fast Ball", 0xA1)
Item.LIGHT_BALL = Item("Light Ball", 0xA3)
Item.FRIEND_BALL = Item("Friend Ball", 0xA4)
Item.MOON_BALL = Item("Moon Ball", 0xA5)
Item.LOVE_BALL = Item("Love Ball", 0xA6)
Item.NORMAL_BOX = Item("Normal Box", 0xA7)
Item.GORGEOUS_BOX = Item("Gorgeous Box", 0xA8)
Item.SUN_STONE = Item("Sun Stone", 0xA9)
Item.POLKADOT_BOW = Item("Polkadot Bow", 0xAA)
Item.UP_GRADE = Item("Up-Grade", 0xAC)
Item.BERRY = Item("Berry", 0xAD)
Item.GOLD_BERRY = Item("Gold Berry", 0xAE)
Item.SQUIRT_BOTTLE = Item("SquirtBottle", 0xAF)
Item.PARK_BALL = Item("Park Ball", 0xB1)
Item.RAINBOW_WING = Item("Rainbow Wing", 0xB2)
Item.BRICK_PIECE = Item("Brick Piece", 0xB4)
Item.SURF_MAIL = Item("Surf Mail", 0xB5)
Item.LITEBLUEMAIL = Item("Litebluemail", 0xB6)
Item.PORTRAITMAIL = Item("Portraitmail", 0xB7)
Item.LOVELY_MAIL = Item("Lovely Mail", 0xB8)
Item.EON_MAIL = Item("Eon Mail", 0xB9)
Item.MORPH_MAIL = Item("Morph Mail", 0xBA)
Item.BLUESKY_MAIL = Item("Bluesky Mail", 0xBB)
Item.MUSIC_MAIL = Item("Music Mail", 0xBC)
Item.MIRAGE_MAIL = Item("Mirage Mail", 0xBD)
Item.TM01 = Item("TM01", 0xBF)
Item.TM02 = Item("TM02", 0xC0)
Item.TM03 = Item("TM03", 0xC1)
Item.TM04 = Item("TM04", 0xC2)
Item.TM05 = Item("TM05", 0xC4)
Item.TM06 = Item("TM06", 0xC5)
Item.TM07 = Item("TM07", 0xC6)
Item.TM08 = Item("TM08", 0xC7)
Item.TM09 = Item("TM09", 0xC8)
Item.TM10 = Item("TM10", 0xC9)
Item.TM11 = Item("TM11", 0xCA)
Item.TM12 = Item("TM12", 0xCB)
Item.TM13 = Item("TM13", 0xCC)
Item.TM14 = Item("TM14", 0xCD)
Item.TM15 = Item("TM15", 0xCE)
Item.TM16 = Item("TM16", 0xCF)
Item.TM17 = Item("TM17", 0xD0)
Item.TM18 = Item("TM18", 0xD1)
Item.TM19 = Item("TM19", 0xD2)
Item.TM20 = Item("TM20", 0xD3)
Item.TM21 = Item("TM21", 0xD4)
Item.TM22 = Item("TM22", 0xD5)
Item.TM23 = Item("TM23", 0xD6)
Item.TM24 = Item("TM24", 0xD7)
Item.TM25 = Item("TM25", 0xD8)
Item.TM26 = Item("TM26", 0xD9)
Item.TM27 = Item("TM27", 0xDA)
Item.TM28 = Item("TM28", 0xDB)
Item.TM29 = Item("TM29", 0xDD)
Item.TM30 = Item("TM30", 0xDE)
Item.TM31 = Item("TM31", 0xDF)
Item.TM32 = Item("TM32", 0xE0)
Item.TM33 = Item("TM33", 0xE1)
Item.TM34 = Item("TM34", 0xE2)
Item.TM35 = Item("TM35", 0xE3)
Item.TM36 = Item("TM36", 0xE4)
Item.TM37 = Item("TM37", 0xE5)
Item.TM38 = Item("TM38", 0xE6)
Item.TM39 = Item("TM39", 0xE7)
Item.TM40 = Item("TM40", 0xE8)
Item.TM41 = Item("TM41", 0xE9)
Item.TM42 = Item("TM42", 0xEA)
Item.TM43 = Item("TM43", 0xEB)
Item.TM44 = Item("TM44", 0xEC)
Item.TM45 = Item("TM45", 0xED)
Item.TM46 = Item("TM46", 0xEE)
Item.TM47 = Item("TM47", 0xEF)
Item.TM48 = Item("TM48", 0xF0)
Item.TM49 = Item("TM49", 0xF1)
Item.TM50 = Item("TM50", 0xF2)
Item.HM01 = Item("HM01", 0xF3)
Item.HM02 = Item("HM02", 0xF4)
Item.HM03 = Item("HM03", 0xF5)
Item.HM04 = Item("HM04", 0xF6)
Item.HM05 = Item("HM05", 0xF7)
Item.HM06 = Item("HM06", 0xF8)
Item.HM07 = Item("HM07", 0xF9)
Item.HM08 = Item("HM08", 0xFA)
Item.HM09 = Item("HM09", 0xFB)
Item.HM10 = Item("HM10", 0xFC)
Item.HM11 = Item("HM11", 0xFD)
Item.HM12 = Item("HM12", 0xFE)
Item.UNKNOWN = Item("Unknown", 0xFF)


Item.buildReverse()

