Browse Source

add team stash getter

Bastien Sevajol 5 years ago
parent
commit
91772946d2

+ 2 - 0
config.yaml View File

@@ -25,6 +25,8 @@ global:
25 25
     state_dumper: "opencombat.state.StateDumper"
26 26
     state_schema: "opencombat/state.xsd"
27 27
     state_template: "opencombat/state_template.xml"
28
+    unit_stash: "opencombat.strategy.unit.stash.UnitStash"
29
+    team_stash: "opencombat.strategy.team.stash.TeamStash"
28 30
     cache_dir_path: 'cache'
29 31
     include_path:
30 32
       maps:

+ 17 - 0
opencombat/strategy/selection/troops.py View File

@@ -30,3 +30,20 @@ class TroopClassBuilder(object):
30 30
             self._config,
31 31
             units_file_path,
32 32
         )
33
+
34
+    def get_team_stash(
35
+        self,
36
+        teams_file_path: str,
37
+    ) -> UnitStash:
38
+        class_address = self._config.resolve(
39
+            'global.team_stash',
40
+            'opencombat.strategy.team.stash.TeamStash',
41
+        )
42
+        class_ = get_class_from_string_path(
43
+            self._config,
44
+            class_address,
45
+        )
46
+        return class_(
47
+            self._config,
48
+            teams_file_path,
49
+        )

+ 4 - 0
opencombat/strategy/team/stash.py View File

@@ -1,14 +1,18 @@
1 1
 # coding: utf-8
2 2
 import typing
3 3
 
4
+from synergine2.config import Config
5
+
4 6
 from opencombat.strategy.unit.model import TeamModel
5 7
 
6 8
 
7 9
 class TeamStash(object):
8 10
     def __init__(
9 11
         self,
12
+        config: Config,
10 13
         teams_file_path: str,
11 14
     ) -> None:
15
+        self._confg = config
12 16
         # TODO Load xml, validate
13 17
         self._teams = None  # typing.List[TeamModel]
14 18
 

+ 4 - 0
opencombat/strategy/unit/stash.py View File

@@ -1,14 +1,18 @@
1 1
 # coding: utf-8
2 2
 import typing
3 3
 
4
+from synergine2.config import Config
5
+
4 6
 from opencombat.strategy.team.model import UnitModel
5 7
 
6 8
 
7 9
 class UnitStash(object):
8 10
     def __init__(
9 11
         self,
12
+        config: Config,
10 13
         units_file_path: str,
11 14
     ) -> None:
15
+        self._confg = config
12 16
         # TODO Load xml, validate
13 17
         self._units = None  # typing.List[UnitModel]
14 18