|
@@ -1,17 +1,17 @@
|
1
|
1
|
# coding: utf-8
|
2
|
|
-import importlib
|
3
|
2
|
import typing
|
4
|
|
-from _elementtree import Element
|
5
|
3
|
|
|
4
|
+from _elementtree import Element
|
6
|
5
|
from lxml import etree
|
7
|
6
|
|
8
|
7
|
from synergine2.config import Config
|
9
|
8
|
from synergine2.log import get_logger
|
10
|
|
-from synergine2.simulation import Subject
|
11
|
9
|
|
12
|
10
|
from opencombat.exception import StateLoadError
|
13
|
11
|
from opencombat.simulation.base import TileStrategySimulation
|
|
12
|
+from opencombat.simulation.subject import TileSubject
|
14
|
13
|
from opencombat.util import get_class_from_string_path
|
|
14
|
+from opencombat.util import get_text_xml_element
|
15
|
15
|
|
16
|
16
|
|
17
|
17
|
class State(object):
|
|
@@ -23,17 +23,17 @@ class State(object):
|
23
|
23
|
) -> None:
|
24
|
24
|
self._config = config
|
25
|
25
|
self._state_root = state_root
|
26
|
|
- self._subjects = None # type: typing.List[Subject]
|
|
26
|
+ self._subjects = None # type: typing.List[TileSubject]
|
27
|
27
|
self._simulation = simulation
|
28
|
28
|
|
29
|
29
|
@property
|
30
|
|
- def subjects(self) -> typing.List[Subject]:
|
|
30
|
+ def subjects(self) -> typing.List[TileSubject]:
|
31
|
31
|
if self._subjects is None:
|
32
|
32
|
self._subjects = self._get_subjects()
|
33
|
33
|
|
34
|
34
|
return self._subjects
|
35
|
35
|
|
36
|
|
- def _get_subjects(self) -> typing.List[Subject]:
|
|
36
|
+ def _get_subjects(self) -> typing.List[TileSubject]:
|
37
|
37
|
subjects = []
|
38
|
38
|
subject_elements = self._state_root.find('subjects').findall('subject')
|
39
|
39
|
|
|
@@ -44,12 +44,38 @@ class State(object):
|
44
|
44
|
subject_class_path,
|
45
|
45
|
)
|
46
|
46
|
subject = subject_class(self._config, self._simulation)
|
|
47
|
+ self._fill_subject(subject, subject_element)
|
47
|
48
|
|
48
|
49
|
# TODO BS 2018-06-13: Fill subject with property
|
49
|
50
|
subjects.append(subject)
|
50
|
51
|
|
51
|
52
|
return subjects
|
52
|
53
|
|
|
54
|
+ def _fill_subject(
|
|
55
|
+ self,
|
|
56
|
+ subject: TileSubject,
|
|
57
|
+ subject_element: Element,
|
|
58
|
+ ) -> None:
|
|
59
|
+ subject.position = tuple(
|
|
60
|
+ map(
|
|
61
|
+ int,
|
|
62
|
+ get_text_xml_element(subject_element, 'position').split(','),
|
|
63
|
+ ),
|
|
64
|
+ )
|
|
65
|
+ subject.direction = float(
|
|
66
|
+ get_text_xml_element(subject_element, 'direction'),
|
|
67
|
+ )
|
|
68
|
+
|
|
69
|
+ """
|
|
70
|
+ TODO:
|
|
71
|
+
|
|
72
|
+ properties={
|
|
73
|
+ SELECTION_COLOR_RGB: DE_COLOR,
|
|
74
|
+ FLAG: FLAG_DE,
|
|
75
|
+ SIDE: 'AXIS',
|
|
76
|
+ }
|
|
77
|
+ """
|
|
78
|
+
|
53
|
79
|
|
54
|
80
|
class StateLoader(object):
|
55
|
81
|
def __init__(
|