Beispiel #1
0
 def render(self, scene: Scene, render_entity_id: UUID,
            next_dialog: UUID) -> List[ComponentDialogEvent]:
     event_v: ComponentDialogEvent = ComponentDialogEvent(
         command="v",
         display_info="Выпить",
         system_type=SystemPotionY,
         kwargs={},
         value=True,
         value_name="",
         entity_id=render_entity_id,
         component_type=ComponentPotion,
         next_dialog=next_dialog,
     )
     event_q: ComponentDialogEvent = ComponentDialogEvent(
         command="q",
         display_info="Вернутся в инвентарь",
         system_type=SystemPotionY,
         kwargs={},
         value=False,
         value_name="",
         entity_id=render_entity_id,
         component_type=ComponentPotion,
         next_dialog=next_dialog,
     )
     scene.set_resource("dialog", render_entity_id)
     return [event_v, event_q]
Beispiel #2
0
 def render(self, scene: Scene, render_entity_id: UUID,
            next_dialog: UUID) -> List[ComponentDialogEvent]:
     event: ComponentDialogEvent = ComponentDialogEvent(
         command="i",
         display_info="Инвентарь",
         system_type=SystemInventory,
         value=None,
         value_name="",
         entity_id=render_entity_id,
         component_type=ComponentInventory,
         next_dialog=next_dialog,
     )
     scene.set_resource("dialog", render_entity_id)
     return [event]
Beispiel #3
0
    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
Beispiel #4
0
    def event(self, scene: Scene, system_event: System, event_type: str,
              entity_id: UUID, component: Component, value: Any,
              value_name: str, kwargs: Dict[str, Any]) -> None:

        player_uuid: UUID = scene.get_resource("player")
        player: Entity = scene.get_entity(entity_id=player_uuid)
        component_inventory: Optional[
            ComponentInventory] = player.get_component(ComponentInventory)

        if component_inventory is None:
            raise RuntimeError(
                "Не найден компонент инветаря при использование зелья")

        if isinstance(value, bool) and value:
            self.enable_potion(scene=scene,
                               item_entity_id=entity_id,
                               component_inventory=component_inventory,
                               component_potion=component,
                               player=player)

        scene.set_resource("dialog", component_inventory.entity_items)
Beispiel #5
0
 def event(self, scene: Scene, system_event: System, event_type: str,
           entity_id: UUID, component: Component, value: Any,
           value_name: str, kwargs: Dict[str, Any]) -> None:
     if value is None:
         scene.set_resource("dialog", entity_id)
Beispiel #6
0
 def event(self, scene: Scene, system_event: System, event_type: str,
           entity_id: UUID, component: Component, value: Any,
           value_name: str, kwargs: Dict[str, Any]) -> None:
     component: ComponentInventory
     scene.set_resource("dialog", component.entity_items)
     scene.set_status(GameStatus.dialog)
Beispiel #7
0
    def render(self, scene: Scene, render_entity_id: UUID,
               next_dialog: UUID) -> List[ComponentDialogEvent]:
        inventory: Optional[ComponentInventory] = scene.get_component(
            entity_id=render_entity_id, component=ComponentInventory)

        if inventory is None:
            raise RuntimeError("Не найден компонен для рендеринга инвентаря")

        renders: List[ComponentDialogEvent] = list()

        q_event: ComponentDialogEvent = ComponentDialogEvent(
            command=f"q",
            display_info="Вернутся в меню",
            system_type=SystemDialog,
            value=None,
            value_name="",
            entity_id=render_entity_id,
            component_type=ComponentDialog,
            next_dialog=render_entity_id,
            info=False)

        if len(inventory.items) == 0:
            info_event: ComponentDialogEvent = ComponentDialogEvent(
                command=f"",
                display_info="В инвентаре нет предметов",
                system_type=type(None),
                value=None,
                value_name="",
                entity_id=render_entity_id,
                component_type=Component,
                next_dialog=render_entity_id,
                info=True)

            return [info_event, q_event]

        for index, item_uuid in enumerate(inventory.items):
            entity: Optional[Entity] = scene.get_entity(entity_id=item_uuid)

            if entity is None:
                continue

            component_item: Optional[ComponentItem] = entity.get_component(
                ComponentItem)

            if component_item is None:
                continue

            event: ComponentDialogEvent = ComponentDialogEvent(
                command=f"{index}",
                display_info=component_item.name,
                system_type=component_item.system_type,
                value=None,
                value_name="",
                entity_id=entity.get_uuid(),
                component_type=ComponentItem,
                next_dialog=next_dialog,
            )
            renders.append(event)
        renders.append(q_event)
        scene.set_resource("dialog", render_entity_id)
        return renders