# Path: intelligine/cst.py
# MODE = IncrementedNamedInt.get('intelligine.basebug.move')
# 
# TYPE = IncrementedNamedInt.get('intelligine.object.type')
# 
# Path: intelligine/simulation/object/brain/part/BrainPart.py
# class BrainPart():
# 
#     def __init__(self, host_brain):
#         self._host_brain = host_brain
#         self._context = self._host_brain.get_context()
#         self._host = self._host_brain.get_host()
# 
#     def get_host_brain(self):
#         return self._host_brain
# 
#     def get_host(self):
#         return self.get_host_brain().get_host()
# 
#     def done(self):
#         pass


from intelligine.cst import MODE, TYPE
from intelligine.simulation.object.brain.part.BrainPart import BrainPart


class TransportBrainPart(BrainPart):

    _mode_matches = {}
    _types_matches = {}

    @classmethod
    def _match_with_mode(cls, context, object_id, concerned_object_id):
        move_mode = context.metas.value.get(MODE, object_id)
        for takable_type in cls._mode_matches[move_mode]:
            if context.metas.list.have(TYPE, concerned_object_id, takable_type, allow_empty=True):
                return True
        return False

    @classmethod
    def _objects_types_match(cls, context, object_a_id, object_b_id):
        """

        Retourne vrai si un des type de l'objet b se trouve dans la lise de type définis dans _types_matches pour
        l'un des types de l'objet a.

        :param context:
        :param object_a_id:
        :param object_b_id:
        :return: bool
        """

# Path: intelligine/cst.py
# MODE = IncrementedNamedInt.get('intelligine.basebug.move')
# 
# TYPE = IncrementedNamedInt.get('intelligine.object.type')
# 
# Path: intelligine/simulation/object/brain/part/BrainPart.py
# class BrainPart():
# 
#     def __init__(self, host_brain):
#         self._host_brain = host_brain
#         self._context = self._host_brain.get_context()
#         self._host = self._host_brain.get_host()
# 
#     def get_host_brain(self):
#         return self._host_brain
# 
#     def get_host(self):
#         return self.get_host_brain().get_host()
# 
#     def done(self):
#         pass


# Path: intelligine/simulation/object/brain/part/transport/TransportBrainPart.py
from intelligine.cst import MODE, TYPE
from intelligine.simulation.object.brain.part.BrainPart import BrainPart



class TransportBrainPart(BrainPart):

    _mode_matches = {}
    _types_matches = {}

    @classmethod
    def _match_with_mode(cls, context, object_id, concerned_object_id):
        move_mode = context.metas.value.get(MODE, object_id)
        for takable_type in cls._mode_matches[move_mode]:
            if context.metas.list.have(TYPE, concerned_object_id, takable_type, allow_empty=True):
                return True
        return False

    @classmethod
    def _objects_types_match(cls, context, object_a_id, object_b_id):
        """

        Retourne vrai si un des type de l'objet b se trouve dans la lise de type définis dans _types_matches pour
        l'un des types de l'objet a.

        :param context:
        :param object_a_id:
        :param object_b_id:
        :return: bool
        """

        object_a_types = context.metas.list.get(TYPE, object_a_id)