# Path: onix/model.py
# class Moveset(namedtuple('Moveset', ['formes',
#                                      'gender',
#                                      'item',
#                                      'moves',
#                                      'level',
#                                      'happiness'])):
#     """
#     Container comprising a complete description of a specific build's
#     battle-relevant attributes (read: not nickname).
# 
#     Args:
#         formes (:obj:`list` of :obj:`Forme`) : the formes the Pokemon might
#             take over the course of the battle
# 
#             .. note ::
#                 The first forme in this list is considered the Pokemon's
#                 "primary forme." It is the forme the Pokemon will appear in
#                 the first time it appears on the field (making an exception for
#                 orb-holding Groudon and Kyogre who transform immediately into
#                 their Primal formes and do not change back)
# 
#         gender ('m', 'f' or 'u') : the Pokemon's gender ('u' represents "not
#             specified")
#         item (str) : the Pokemon's held item
#         moves (:obj:`list` of :obj:`str`) : the moves the Pokemon knows
#         level (int) : the Pokemon's level
#         happiness (int) : the Pokemon's happiness
# 
#     Note:
#         Nature, IVs and EVs aren't included in this description, since there
#         might be multiple ways to get to the same battle-stats, but they're all
#         functionally equivalent.
# 
#     """
#     pass
# 
# class Forme(namedtuple('Forme', ['species',
#                                  'ability',
#                                  'stats'])):
#     """
#     Container to represent a Pokemon's Forme (that is, the aspects of a moveset
#     that might change when forme changes).
# 
#     Args:
#         species (str) : forme name
#         ability (str) : the Pokemon's ability
#         stats (PokeStats) : the Pokemon's battle stats (that is, not base stats)
#     """
# 
# class PokeStats(namedtuple('PokeStats', ['hp',
#                                          'atk',
#                                          'dfn',
#                                          'spa',
#                                          'spd',
#                                          'spe'])):
#     """
#     Container to represent a Pokemon's stats. This could be base stats, IVs/EVs
#     or battle-stats.
# 
#     Args:
#         hp (int) : hit point stat
#         atk (int) : attack stat
#         dfn (int) : defense stat (you can't have a field named "def")
#         spa (int) : special attack stat
#         spd (int) : special defense stat
#         spe (int) : speed stat
#     """
#     pass


import collections
import hashlib
import json
import re
import pkg_resources
from past.builtins import basestring
from onix.model import Moveset, Forme, PokeStats

    moveset_hash = hashlib.sha512(repr(moveset).encode('utf-8')).hexdigest()

    # may eventually want to truncate hash, e.g.
    # moveset_hash = moveset_hash[:16]

    return moveset_hash


def stats_dict_to_model(stats_dict):
    """
    Converts a Pokemon Showdown-style stats ``dict`` to a ``PokeStats`` object.

    Args:
        stats_dict (dict) : the object to convert

    Returns:
        PokeStats : the converted object

    Raises:
        TypeError : if ``stats_dict`` doesn't have the correct keys

    Examples:
        >>> from onix import utilities
        >>> utilities.stats_dict_to_model({'hp': 361, 'atk': 394, 'def': 197,
        ... 'spa': 158, 'spd' : 156, 'spe': 259})
        PokeStats(hp=361, atk=394, dfn=197, spa=158, spd=156, spe=259)
    """
    stats_dict = stats_dict.copy()
    stats_dict['dfn'] = stats_dict.pop('def')

# Path: onix/model.py
# class Moveset(namedtuple('Moveset', ['formes',
#                                      'gender',
#                                      'item',
#                                      'moves',
#                                      'level',
#                                      'happiness'])):
#     """
#     Container comprising a complete description of a specific build's
#     battle-relevant attributes (read: not nickname).
# 
#     Args:
#         formes (:obj:`list` of :obj:`Forme`) : the formes the Pokemon might
#             take over the course of the battle
# 
#             .. note ::
#                 The first forme in this list is considered the Pokemon's
#                 "primary forme." It is the forme the Pokemon will appear in
#                 the first time it appears on the field (making an exception for
#                 orb-holding Groudon and Kyogre who transform immediately into
#                 their Primal formes and do not change back)
# 
#         gender ('m', 'f' or 'u') : the Pokemon's gender ('u' represents "not
#             specified")
#         item (str) : the Pokemon's held item
#         moves (:obj:`list` of :obj:`str`) : the moves the Pokemon knows
#         level (int) : the Pokemon's level
#         happiness (int) : the Pokemon's happiness
# 
#     Note:
#         Nature, IVs and EVs aren't included in this description, since there
#         might be multiple ways to get to the same battle-stats, but they're all
#         functionally equivalent.
# 
#     """
#     pass
# 
# class Forme(namedtuple('Forme', ['species',
#                                  'ability',
#                                  'stats'])):
#     """
#     Container to represent a Pokemon's Forme (that is, the aspects of a moveset
#     that might change when forme changes).
# 
#     Args:
#         species (str) : forme name
#         ability (str) : the Pokemon's ability
#         stats (PokeStats) : the Pokemon's battle stats (that is, not base stats)
#     """
# 
# class PokeStats(namedtuple('PokeStats', ['hp',
#                                          'atk',
#                                          'dfn',
#                                          'spa',
#                                          'spd',
#                                          'spe'])):
#     """
#     Container to represent a Pokemon's stats. This could be base stats, IVs/EVs
#     or battle-stats.
# 
#     Args:
#         hp (int) : hit point stat
#         atk (int) : attack stat
#         dfn (int) : defense stat (you can't have a field named "def")
#         spa (int) : special attack stat
#         spd (int) : special defense stat
#         spe (int) : speed stat
#     """
#     pass


# Path: onix/utilities.py
import collections
import hashlib
import json
import re
import pkg_resources
from past.builtins import basestring
from onix.model import Moveset, Forme, PokeStats


    moveset_hash = hashlib.sha512(repr(moveset).encode('utf-8')).hexdigest()

    # may eventually want to truncate hash, e.g.
    # moveset_hash = moveset_hash[:16]

    return moveset_hash


def stats_dict_to_model(stats_dict):
    """
    Converts a Pokemon Showdown-style stats ``dict`` to a ``PokeStats`` object.

    Args:
        stats_dict (dict) : the object to convert

    Returns:
        PokeStats : the converted object

    Raises:
        TypeError : if ``stats_dict`` doesn't have the correct keys

    Examples:
        >>> from onix import utilities
        >>> utilities.stats_dict_to_model({'hp': 361, 'atk': 394, 'def': 197,
        ... 'spa': 158, 'spd' : 156, 'spe': 259})
        PokeStats(hp=361, atk=394, dfn=197, spa=158, spd=156, spe=259)
    """
    stats_dict = stats_dict.copy()
    stats_dict['dfn'] = stats_dict.pop('def')

    return PokeStats(**stats_dict)