# Path: data/python_templates/items.py
# def build_short_sword():
# def build_long_sword():
# def build_helmet():
# def build_leather_hood():
# def build_breastplate():
# def build_leather_cuirass():
# def build_bracer():
# def build_gauntlet():
# def build_greave():
# def build_leather_pants():
# def build_boot():
# 
# Path: data/python_templates/material.py

# 
# Path: items/item.py
# class Item(GameObject):
#     NAME = "item"
#     """
#     What is an item?
#     It made out of a material, it has a type, it can be used.
#     It has stats, it can be destroyed, displayed, held.
#     It can have a rarity, a level, value.
#     It can be sharpened, altered, destroyed and repaired.
#     Painted, customized, engraved.
#     A good loot system can go a long way in terms of extending play time.
#     """
#     def __init__(self, uid, name="", description="", location=None, display=None):
#         super().__init__()
#         self.uid = uid
#         self._name = name
#         self._description = description
#         self.location = location
#         self.display = display
# 
#         # TODO Items should have weapon stats AND armor stats of D&D
#         # TODO They should be affected by material, so you can have a base item of iron breastplate of +2 AC
#         # TODO that could be reforged to steel for a total of +4 AC that could then be enchanted for a +6
#         # TODO Having these materials affects may not be very D&D but lets talk about it again
#         # TODO Once you craft a breastplate out of bones.
# 
#     @property
#     def description(self):
#         """
#         This property will be able to return altered descriptions for customized items.
#         :return: String of current description.
#         """
#         return self._description
# 
#     @property
#     def name(self):
#         """
#         This property will be able to return engraved names for customized items.
#         :return: String of current name.
#         """
#         return self._name
# 
#     def copy(self):
#         new_item = Item(self.uid, self._name, self._description, self.location, self.display)
#         return super().copy_to(new_item)
# 
#     def __eq__(self, other):
#         return (
#             self.uid == other.uid,
#             self.name == other.name,
#             self.description == other.description,
#             self.material == other.material,
#             self.stats == other.stats
#         )
# 
#     def __ne__(self, other):
#         return not self.__eq__(other)
# 
#     def __hash__(self):
#         return hash(
#             (
#                 self.uid,
#                 self.name,
#                 self.description,
#                 self.material,
#                 self.stats
#             )
#         )


from data.python_templates.items import item_templates
from data.python_templates.material import material_templates
from items.item import Item

        item_instance = item_templates[uid]
        if item_instance:
            return self._create_instance_of_template(item_instance)
        else:
            raise Exception("Could not find template for UID " + uid)

    def _create_instance_of_template(self, item_template):
        instance_id = 0
        if item_template.uid in self.template_instance_count:
            instance_id = self.template_instance_count[item_template.uid]
            self.template_instance_count[item_template.uid] += 1
        else:
            self.template_instance_count[item_template.uid] = 1

        instance_uid = item_template.uid + "_" + str(instance_id)
        new_instance = Item(
            uid=instance_uid,
            name=item_template.name,
            description=item_template.description,
            display=item_template.display.copy(),
        )
        item_template.copy_to(new_instance)

        return new_instance

    def get_material_template_by_uid(self, uid):
        return material_templates[uid]

    def get_item_template_by_uid(self, uid):

# Path: data/python_templates/items.py
# def build_short_sword():
# def build_long_sword():
# def build_helmet():
# def build_leather_hood():
# def build_breastplate():
# def build_leather_cuirass():
# def build_bracer():
# def build_gauntlet():
# def build_greave():
# def build_leather_pants():
# def build_boot():
# 
# Path: data/python_templates/material.py

# 
# Path: items/item.py
# class Item(GameObject):
#     NAME = "item"
#     """
#     What is an item?
#     It made out of a material, it has a type, it can be used.
#     It has stats, it can be destroyed, displayed, held.
#     It can have a rarity, a level, value.
#     It can be sharpened, altered, destroyed and repaired.
#     Painted, customized, engraved.
#     A good loot system can go a long way in terms of extending play time.
#     """
#     def __init__(self, uid, name="", description="", location=None, display=None):
#         super().__init__()
#         self.uid = uid
#         self._name = name
#         self._description = description
#         self.location = location
#         self.display = display
# 
#         # TODO Items should have weapon stats AND armor stats of D&D
#         # TODO They should be affected by material, so you can have a base item of iron breastplate of +2 AC
#         # TODO that could be reforged to steel for a total of +4 AC that could then be enchanted for a +6
#         # TODO Having these materials affects may not be very D&D but lets talk about it again
#         # TODO Once you craft a breastplate out of bones.
# 
#     @property
#     def description(self):
#         """
#         This property will be able to return altered descriptions for customized items.
#         :return: String of current description.
#         """
#         return self._description
# 
#     @property
#     def name(self):
#         """
#         This property will be able to return engraved names for customized items.
#         :return: String of current name.
#         """
#         return self._name
# 
#     def copy(self):
#         new_item = Item(self.uid, self._name, self._description, self.location, self.display)
#         return super().copy_to(new_item)
# 
#     def __eq__(self, other):
#         return (
#             self.uid == other.uid,
#             self.name == other.name,
#             self.description == other.description,
#             self.material == other.material,
#             self.stats == other.stats
#         )
# 
#     def __ne__(self, other):
#         return not self.__eq__(other)
# 
#     def __hash__(self):
#         return hash(
#             (
#                 self.uid,
#                 self.name,
#                 self.description,
#                 self.material,
#                 self.stats
#             )
#         )


# Path: factories/item_factory.py
from data.python_templates.items import item_templates
from data.python_templates.material import material_templates
from items.item import Item


        item_instance = item_templates[uid]
        if item_instance:
            return self._create_instance_of_template(item_instance)
        else:
            raise Exception("Could not find template for UID " + uid)

    def _create_instance_of_template(self, item_template):
        instance_id = 0
        if item_template.uid in self.template_instance_count:
            instance_id = self.template_instance_count[item_template.uid]
            self.template_instance_count[item_template.uid] += 1
        else:
            self.template_instance_count[item_template.uid] = 1

        instance_uid = item_template.uid + "_" + str(instance_id)
        new_instance = Item(
            uid=instance_uid,
            name=item_template.name,
            description=item_template.description,
            display=item_template.display.copy(),
        )
        item_template.copy_to(new_instance)

        return new_instance

    def get_material_template_by_uid(self, uid):
        return material_templates[uid]

    def get_item_template_by_uid(self, uid):

        return item_templates[uid]