Browse Source

add team stash getter

Bastien Sevajol 5 years ago
parent
commit
91772946d2

+ 2 - 0
config.yaml View File

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

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

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

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

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