# Path: intelligine/display/map.py
# def get_map_connector(map_file_path, map_config):
#     return TileMapConnector.from_file(map_file_path, dict(map_config))
# 
# Path: intelligine/synergy/object/ant/Ant.py
# class Ant(Bug):
# 
#     _body_parts = {
#         BODY_PART_PHEROMONE_GLAND: MovementMoleculeGland
#     }
#     _brain_class = AntBrain
# 
#     def __init__(self, collection, context):
#         super().__init__(collection, context)
#         context.metas.states.add_list(self.get_id(), [TRANSPORTER, ATTACKER])
#         context.metas.collections.add_list(self.get_id(), [COL_TRANSPORTER,
#                                                            COL_TRANSPORTER_NOT_CARRYING,
#                                                            COL_FIGHTER])
#         self._carried = None
#         #  TODO: Comme pour lorsque une action put est faite, lancer un algo de choix de la mission a suivre.
#         if random.choice([1, 0]):
#             self._brain.switch_to_mode(MODE_EXPLO)
#         else:
#             self._brain.switch_to_mode(MODE_NURSE)
#         context.metas.list.add(TYPE, self.get_id(), TYPE_ANT)
#         self._put_fail_count = 0
# 
#     def die(self):
#         super().die()
#         self._remove_state(TRANSPORTER)
#         self._remove_state(ATTACKER)
#         self._remove_col(COL_TRANSPORTER)
#         self._remove_col(COL_TRANSPORTER_NOT_CARRYING)
#         self._remove_col(COL_TRANSPORTER_CARRYING, allow_not_in=True)
#         self._remove_col(COL_FIGHTER)
# 
#     def get_movement_molecule_gland(self):
#         return self.get_body_part(BODY_PART_PHEROMONE_GLAND)
# 
#     def put_carry(self, obj, position=None):
#         if position is None:
#             position = self._get_position()
#         self._carried = None
#         obj.set_position(position)
#         obj.set_is_carried(False, self)
#         self._context.metas.states.remove(self.get_id(), CARRYING)
#         self._context.metas.value.unset(CARRY, self.get_id())
#         self._add_col(COL_TRANSPORTER_NOT_CARRYING)
#         self._remove_col(COL_TRANSPORTER_CARRYING)
# 
#     def get_carried(self):
#         return self._carried
# 
#     def carry(self, obj):
#         self._carried = obj
#         self._context.metas.states.add(self.get_id(), CARRYING)
#         self._add_col(COL_TRANSPORTER_CARRYING)
#         self._remove_col(COL_TRANSPORTER_NOT_CARRYING)
#         obj.set_is_carried(True, self)
#         self._context.metas.value.set(CARRY, self.get_id(), obj.get_id())
#         # TODO: pour le moment hardcode, a gerer dans AntTakeBrainPart (callback en fct de ce qui est depose)
#         if isinstance(obj, Food):
#             self.get_brain().switch_to_mode(MODE_GOHOME)
#             self.get_movement_molecule_gland().appose()
# 
#     def is_carrying(self):
#         if self._carried:
#             return True
#         return False
# 
#     def set_position(self, position):
#         if self._position is not None and position != self._position:
#             self._brain.host_moved()
#         super().set_position(position)
#         if self.is_carrying():
#             self._carried.set_position(position)
# 
#     def initialize(self):
#         super().initialize()
#         if self.get_movement_molecule_gland().is_enabled():
#             try:
#                 self.get_movement_molecule_gland().appose()
#             except MoleculeException:
#                 pass
# 
#     def get_colony(self):
#         return self.get_collection()
# 
#     def get_put_fail_count(self):
#         return self._put_fail_count
# 
#     def increment_put_fail_count(self):
#         self._put_fail_count += 1
#         self._context.metas.value.set(PUT_FAIL_COUNT, self.get_id(), self._put_fail_count)
# 
#     def reinit_put_fail_count(self):
#         self._put_fail_count = 0
#         self._context.metas.value.set(PUT_FAIL_COUNT, self.get_id(), self._put_fail_count)
# 
# Path: intelligine/synergy/object/ant/Egg.py
# class Egg(BaseEgg):
#     pass


import pygame
from intelligine.display.map import get_map_connector
from synergine_xyz.display.PygameImageRotate import PygameImageRotate
from synergine_xyz.display.PygameVisualisation import PygameVisualisation
from synergine_xyz.display.object.pygame.PygameImage import PygameImage
from intelligine.synergy.object.ant.Ant import Ant
from intelligine.synergy.object.ant.Egg import Egg
from os import getcwd
from synergine_xyz.cst import PREVIOUS_DIRECTION

    def dead_ant_callback(obj, context):
        # TODO: obj dans le col ALIVE truc comme ça
        if obj.get_life_points() <= 0:
            return pygame_image
        # TODO: raise, ou dans objectVisual.get_visual tests si bool plutot que is
        return False

    return dead_ant_callback


def ant_direction_modifier(obj, context, visual):
    try:
        previous_direction = context.metas.value.get(PREVIOUS_DIRECTION, obj.get_id())
    except KeyError:
        previous_direction = 14
    return image_rotate.get_for_direction(visual, previous_direction)


def get_standard_extract_from_map(map_file_path, map_config):
    map_connector = get_map_connector(map_file_path, map_config)
    visualisation = PygameVisualisation.get_default_visualisation()

    simulations = map_connector.create_simulations()
    visualizer = PygameVisualisation(visualisation)

    objects_images = map_connector.extract_objects_images()
    visualizer.update_objects_images(objects_images)

    map_connector.add_object_callback_to_visualisation(visualizer, [Ant], dead_ant_callback_container)

# Path: intelligine/display/map.py
# def get_map_connector(map_file_path, map_config):
#     return TileMapConnector.from_file(map_file_path, dict(map_config))
# 
# Path: intelligine/synergy/object/ant/Ant.py
# class Ant(Bug):
# 
#     _body_parts = {
#         BODY_PART_PHEROMONE_GLAND: MovementMoleculeGland
#     }
#     _brain_class = AntBrain
# 
#     def __init__(self, collection, context):
#         super().__init__(collection, context)
#         context.metas.states.add_list(self.get_id(), [TRANSPORTER, ATTACKER])
#         context.metas.collections.add_list(self.get_id(), [COL_TRANSPORTER,
#                                                            COL_TRANSPORTER_NOT_CARRYING,
#                                                            COL_FIGHTER])
#         self._carried = None
#         #  TODO: Comme pour lorsque une action put est faite, lancer un algo de choix de la mission a suivre.
#         if random.choice([1, 0]):
#             self._brain.switch_to_mode(MODE_EXPLO)
#         else:
#             self._brain.switch_to_mode(MODE_NURSE)
#         context.metas.list.add(TYPE, self.get_id(), TYPE_ANT)
#         self._put_fail_count = 0
# 
#     def die(self):
#         super().die()
#         self._remove_state(TRANSPORTER)
#         self._remove_state(ATTACKER)
#         self._remove_col(COL_TRANSPORTER)
#         self._remove_col(COL_TRANSPORTER_NOT_CARRYING)
#         self._remove_col(COL_TRANSPORTER_CARRYING, allow_not_in=True)
#         self._remove_col(COL_FIGHTER)
# 
#     def get_movement_molecule_gland(self):
#         return self.get_body_part(BODY_PART_PHEROMONE_GLAND)
# 
#     def put_carry(self, obj, position=None):
#         if position is None:
#             position = self._get_position()
#         self._carried = None
#         obj.set_position(position)
#         obj.set_is_carried(False, self)
#         self._context.metas.states.remove(self.get_id(), CARRYING)
#         self._context.metas.value.unset(CARRY, self.get_id())
#         self._add_col(COL_TRANSPORTER_NOT_CARRYING)
#         self._remove_col(COL_TRANSPORTER_CARRYING)
# 
#     def get_carried(self):
#         return self._carried
# 
#     def carry(self, obj):
#         self._carried = obj
#         self._context.metas.states.add(self.get_id(), CARRYING)
#         self._add_col(COL_TRANSPORTER_CARRYING)
#         self._remove_col(COL_TRANSPORTER_NOT_CARRYING)
#         obj.set_is_carried(True, self)
#         self._context.metas.value.set(CARRY, self.get_id(), obj.get_id())
#         # TODO: pour le moment hardcode, a gerer dans AntTakeBrainPart (callback en fct de ce qui est depose)
#         if isinstance(obj, Food):
#             self.get_brain().switch_to_mode(MODE_GOHOME)
#             self.get_movement_molecule_gland().appose()
# 
#     def is_carrying(self):
#         if self._carried:
#             return True
#         return False
# 
#     def set_position(self, position):
#         if self._position is not None and position != self._position:
#             self._brain.host_moved()
#         super().set_position(position)
#         if self.is_carrying():
#             self._carried.set_position(position)
# 
#     def initialize(self):
#         super().initialize()
#         if self.get_movement_molecule_gland().is_enabled():
#             try:
#                 self.get_movement_molecule_gland().appose()
#             except MoleculeException:
#                 pass
# 
#     def get_colony(self):
#         return self.get_collection()
# 
#     def get_put_fail_count(self):
#         return self._put_fail_count
# 
#     def increment_put_fail_count(self):
#         self._put_fail_count += 1
#         self._context.metas.value.set(PUT_FAIL_COUNT, self.get_id(), self._put_fail_count)
# 
#     def reinit_put_fail_count(self):
#         self._put_fail_count = 0
#         self._context.metas.value.set(PUT_FAIL_COUNT, self.get_id(), self._put_fail_count)
# 
# Path: intelligine/synergy/object/ant/Egg.py
# class Egg(BaseEgg):
#     pass


# Path: intelligine/display/pygame/visualisation.py
import pygame
from intelligine.display.map import get_map_connector
from synergine_xyz.display.PygameImageRotate import PygameImageRotate
from synergine_xyz.display.PygameVisualisation import PygameVisualisation
from synergine_xyz.display.object.pygame.PygameImage import PygameImage
from intelligine.synergy.object.ant.Ant import Ant
from intelligine.synergy.object.ant.Egg import Egg
from os import getcwd
from synergine_xyz.cst import PREVIOUS_DIRECTION


    def dead_ant_callback(obj, context):
        # TODO: obj dans le col ALIVE truc comme ça
        if obj.get_life_points() <= 0:
            return pygame_image
        # TODO: raise, ou dans objectVisual.get_visual tests si bool plutot que is
        return False

    return dead_ant_callback


def ant_direction_modifier(obj, context, visual):
    try:
        previous_direction = context.metas.value.get(PREVIOUS_DIRECTION, obj.get_id())
    except KeyError:
        previous_direction = 14
    return image_rotate.get_for_direction(visual, previous_direction)


def get_standard_extract_from_map(map_file_path, map_config):
    map_connector = get_map_connector(map_file_path, map_config)
    visualisation = PygameVisualisation.get_default_visualisation()

    simulations = map_connector.create_simulations()
    visualizer = PygameVisualisation(visualisation)

    objects_images = map_connector.extract_objects_images()
    visualizer.update_objects_images(objects_images)

    map_connector.add_object_callback_to_visualisation(visualizer, [Ant], dead_ant_callback_container)

    ant_production_classes = map_connector.get_dynamic_classes().get_production_classes(Ant)