Browse Source

reorganize libs to run tests without import pygame

Bastien Sevajol 8 years ago
parent
commit
94463a0952

+ 5 - 0
intelligine/display/map.py View File

@@ -0,0 +1,5 @@
1
+from synergine_xyz.tmx.TileMapConnector import TileMapConnector
2
+
3
+
4
+def get_map_connector(map_file_path, map_config):
5
+    return TileMapConnector.from_file(map_file_path, dict(map_config))

+ 26 - 0
intelligine/display/pygame/config.py View File

@@ -0,0 +1,26 @@
1
+from intelligine.synergy.Colony import Colony
2
+from intelligine.synergy.Environment import Environment
3
+from intelligine.synergy.object.StockedFood import StockedFood
4
+from synergine.synergy.Simulation import Simulation
5
+from intelligine.synergy.object.Food import Food
6
+from intelligine.synergy.object.Rock import Rock
7
+from intelligine.synergy.object.ant.Ant import Ant
8
+from intelligine.synergy.object.ant.Egg import Egg
9
+
10
+
11
+map_config = {
12
+    'simulation': {
13
+        'base': Simulation
14
+    },
15
+    'collection': {
16
+        'ant': Colony,
17
+        'env': Environment
18
+    },
19
+    'object': {
20
+        'ant': Ant,
21
+        'egg': Egg,
22
+        'rock': Rock,
23
+        'food': Food,
24
+        'stocked_food': StockedFood
25
+    }
26
+}

+ 2 - 24
intelligine/display/pygame/visualisation.py View File

@@ -1,18 +1,12 @@
1 1
 import pygame
2
-from intelligine.synergy.Colony import Colony
3
-from intelligine.synergy.Environment import Environment
4
-from intelligine.synergy.object.StockedFood import StockedFood
5
-from synergine.synergy.Simulation import Simulation
2
+from intelligine.display.map import get_map_connector
6 3
 from synergine_xyz.display.PygameImageRotate import PygameImageRotate
7 4
 from synergine_xyz.display.PygameVisualisation import PygameVisualisation
8 5
 from synergine_xyz.display.object.pygame.PygameImage import PygameImage
9
-from intelligine.synergy.object.Food import Food
10 6
 from intelligine.synergy.object.ant.Ant import Ant
11
-from intelligine.synergy.object.Rock import Rock
12 7
 from intelligine.synergy.object.ant.Egg import Egg
13 8
 from os import getcwd
14 9
 from synergine_xyz.cst import PREVIOUS_DIRECTION
15
-from synergine_xyz.tmx.TileMapConnector import TileMapConnector
16 10
 
17 11
 SURFACE_PHEROMONE_HOME = 'molecule_home'
18 12
 SURFACE_PHEROMONE_EXPLORATION = 'molecule_exploration'
@@ -158,22 +152,6 @@ def for_position(position, objects, context):
158 152
 # Behind, new
159 153
 #############################
160 154
 
161
-map_config = {
162
-    'simulation': {
163
-        'base': Simulation
164
-    },
165
-    'collection': {
166
-        'ant': Colony,
167
-        'env': Environment
168
-    },
169
-    'object': {
170
-        'ant': Ant,
171
-        'egg': Egg,
172
-        'rock': Rock,
173
-        'food': Food,
174
-        'stocked_food': StockedFood
175
-    }
176
-}
177 155
 image_rotate = PygameImageRotate()
178 156
 
179 157
 
@@ -203,7 +181,7 @@ def ant_direction_modifier(obj, context, visual):
203 181
 
204 182
 
205 183
 def get_standard_extract_from_map(map_file_path, map_config):
206
-    map_connector = TileMapConnector.from_file(map_file_path, dict(map_config))
184
+    map_connector = get_map_connector(map_file_path, map_config)
207 185
     visualisation = PygameVisualisation.get_default_visualisation()
208 186
 
209 187
     simulations = map_connector.create_simulations()

+ 4 - 3
intelligine/tests/src/simulation/SimpleTestWorld1Simulation.py View File

@@ -1,6 +1,7 @@
1
+from intelligine.display.map import get_map_connector
2
+from intelligine.display.pygame.config import map_config
1 3
 from synergine.test.TestSimulation import TestSimulation
2 4
 from os import getcwd
3
-from intelligine.display.pygame.visualisation import get_standard_extract_from_map, map_config
4 5
 
5 6
 
6 7
 class SimpleTestWorld1Simulation(TestSimulation):
@@ -8,11 +9,11 @@ class SimpleTestWorld1Simulation(TestSimulation):
8 9
     def __init__(self, *args, **kwargs):
9 10
         super().__init__(*args, **kwargs)
10 11
 
11
-        simulations, visualisation = get_standard_extract_from_map(
12
+        map_connector = get_map_connector(
12 13
             getcwd()+"/intelligine/tests/src/simulation/SimpleTestWorld1.tmx",
13 14
             map_config
14 15
         )
15
-        self._simulations = simulations
16
+        self._simulations = map_connector.create_simulations()
16 17
 
17 18
     def _get_set_up_simulations(self):
18 19
         return self._simulations