def enable_potion(self, scene: Scene, item_entity_id: UUID, component_inventory: ComponentInventory, component_potion: ComponentPotion, player: Entity) -> None: if system := scene.get_system(SystemUnitHealthy): system: SystemUnitHealthy system.add_healthy(healthy=component_potion.hp, entity_id=player.get_uuid(), scene=scene)
def display_input(self, scene: Scene, component_dialog: ComponentDialog) -> bool: """Получени ввода""" try: input_text: str = input("Введите вариант: ").strip() except UnicodeDecodeError: return False events: List[ComponentDialogEvent] for component in component_dialog.dialog_events: if component.command == input_text: system: Optional[System] = scene.get_system( component.system_type) component_input: Optional[Component] = scene.get_component( entity_id=component.entity_id, component=component.component_type) value: Any = component.value value_name: str = component.value_name kwargs: Dict[str, Any] = component.kwargs entity_id: UUID = component.entity_id event_result: bool = self._event_system( system=system, component=component_input, value=value, value_name=value_name, kwargs=kwargs, scene=scene, entity_id=entity_id) return event_result return False
def _show_display(self, scene: Scene, entity_id: UUID) -> bool: """Отрисовка диалогов""" system_display: Optional[SystemDisplay] = scene.get_system(SystemDisplay) system_input: Optional[SystemInput] = scene.get_system(SystemInput) component_dialog: Optional[ComponentDialog] = scene.get_component( entity_id=entity_id, component=ComponentDialog) if system_display is None or system_input is None or component_dialog is None: return False self.clear() system_display.display_print(scene=scene, component_dialog=component_dialog) component_dialog = scene.get_component(entity_id=entity_id, component=ComponentDialog) system_input.display_input(scene=scene, component_dialog=component_dialog) return True
def _event_input(self, value: Tuple[int, int], scene: Scene, entity_id: UUID, value_name: str, component: ComponentPosition) -> bool: if value_name == "coordinate_x_y": system_word: Optional[SystemWord] = scene.get_system(SystemWord) if system_word is None: return False move: bool = system_word.set_move(entity_id=entity_id, component=component, move_x=value[0], move_y=value[1]) scene.set_status(GameStatus.runner) return move
def render(self, scene: Scene, render_entity_id: UUID, next_dialog: UUID) -> List[ComponentDialogEvent]: system_word: Optional[SystemWord] = scene.get_system(SystemWord) position: Optional[ComponentPosition] = scene.get_component( entity_id=render_entity_id, component=ComponentPosition) if system_word is None or position is None: return [] events: List[ComponentDialogEvent] = self._render( system_word=system_word, position=position, entity_id=render_entity_id, next_dialog=next_dialog) scene.set_resource("dialog", next_dialog) return events
def _get_dialogs( self, scene: Scene, component: ComponentDialog ) -> List[ComponentDialogEvent]: """Получение диалогов""" renderings: List[ComponentDialogEvent] = list() for render_iter in component.renderings: render_iter: ComponentDialogRender system: Optional[SystemRender] = scene.get_system( render_iter.system_type ) for render in system.render( scene=scene, render_entity_id=render_iter.entity_id, next_dialog=render_iter.next_dialog ): render: ComponentDialogEvent renderings.append(render) return renderings