def get_troop_dumper(self) -> TroopDumper: class_address = self._config.resolve( 'global.troop_dumper', 'opencombat.strategy.troops.TroopDumper', ) class_ = get_class_from_string_path( self._config, class_address, ) return class_(self._config, )
def get_troop_loader(self, ) -> TroopLoader: class_address = self._config.resolve( 'global.troop_loader', 'opencombat.strategy.troops.TroopLoader', ) troop_loader_class = get_class_from_string_path( self._config, class_address, ) return troop_loader_class( self._config, self._simulation, )
def get_state_dumper(self, ) -> StateDumper: class_address = self._config.resolve( 'global.state_dumper', 'opencombat.state.StateDumper', ) state_loader_class = get_class_from_string_path( self._config, class_address, ) return state_loader_class( self._config, self._simulation, )
def _get_subjects(self) -> typing.List[TileSubject]: subjects = [] subject_elements = self._state_root.find('subjects').findall('subject') for subject_element in subject_elements: subject_class_path = subject_element.find('type').text subject_class = get_class_from_string_path( self._config, subject_class_path, ) subject = subject_class(self._config, self._simulation) self._fill_subject(subject, subject_element) subjects.append(subject) return subjects
def get_unit_stash( self, units_file_path: str, ) -> UnitStash: class_address = self._config.resolve( 'global.unit_stash', 'opencombat.strategy.unit.stash.UnitStash', ) class_ = get_class_from_string_path( self._config, class_address, ) return class_( self._config, units_file_path, )
def get_team_stash( self, units_file_path: str, teams_file_path: str, ) -> TeamStash: class_address = self._config.resolve( 'global.team_stash', 'opencombat.strategy.team.stash.TeamStash', ) class_ = get_class_from_string_path( self._config, class_address, ) unit_stash = self.get_unit_stash(units_file_path) return class_( self._config, teams_file_path, unit_stash=unit_stash, )
def _get_computed_units(self) -> typing.List[UnitModel]: units = [] for unit_element in self._root_element.findall('unit'): unit_element = typing.cast(Element, unit_element) unit_id = unit_element.attrib['id'] unit_country = unit_element.attrib['country'] unit_name = get_text_xml_element(unit_element, 'name') unit_class_path = get_text_xml_element(unit_element, 'type') unit_class = get_class_from_string_path( self._config, unit_class_path, ) units.append( UnitModel( id_=unit_id, name=unit_name, class_=unit_class, country=unit_country, )) return units