コード例 #1
0
    def get_character_actions(
            self,
            character: "CharacterModel") -> typing.List[CharacterActionLink]:
        available_cheats = self._get_available_cheats(character)
        action_links: typing.List[CharacterActionLink] = []

        if "increase_ap" in available_cheats:
            action_links.append(
                CharacterActionLink(
                    name="(Triche) S'ajouter des PA",
                    link=get_character_action_url(
                        character_id=character.id,
                        action_type=ActionType.CHEATS,
                        action_description_id=self._description.id,
                        query_params={"cheat_id": "increase_ap"},
                    ),
                ))

        if "reduce_tiredness" in available_cheats:
            action_links.append(
                CharacterActionLink(
                    name="(Triche) Réduire la fatigue",
                    link=get_character_action_url(
                        character_id=character.id,
                        action_type=ActionType.CHEATS,
                        action_description_id=self._description.id,
                        query_params={"cheat_id": "reduce_tiredness"},
                    ),
                ))

        return action_links
コード例 #2
0
 def get_character_actions(
         self, character: "CharacterModel", with_character: "CharacterModel"
 ) -> typing.List[CharacterActionLink]:
     return [
         CharacterActionLink(name=f"Suivre {with_character.name}",
                             link=self._get_url(character, with_character)),
         CharacterActionLink(
             name=f"Suivre {with_character.name} discrètement",
             link=self._get_url(character,
                                with_character,
                                input_=FollowModel(discreetly=True)),
         ),
     ]
コード例 #3
0
ファイル: knowledge.py プロジェクト: coolkat64/rolling
    def get_character_actions(
            self,
            character: "CharacterModel") -> typing.List[CharacterActionLink]:
        action_links = []

        for knowledge_id, knowledge_description in self._kernel.game.config.knowledge.items(
        ):
            continue_ = False

            if knowledge_id in character.knowledges:
                continue_ = True
            for required_knowledge_id in knowledge_description.requires:
                if required_knowledge_id not in character.knowledges:
                    continue_ = True

            if continue_:
                continue

            action_links.append(
                CharacterActionLink(
                    name=knowledge_description.name,
                    link=self._get_url(
                        character,
                        LearnKnowledgeModel(knowledge_id=knowledge_id)),
                    group_name="Apprentissages",
                ))

        return action_links
コード例 #4
0
ファイル: drink.py プロジェクト: coolkat64/rolling
    def get_character_actions(
            self, character: "CharacterModel",
            stuff: "StuffModel") -> typing.List[CharacterActionLink]:
        accept_resources_ids = [
            rd.id for rd in self._description.properties["accept_resources"]
        ]
        if (stuff.filled_with_resource is not None
                and stuff.filled_with_resource in accept_resources_ids):
            query_params = self.input_model(stuff_id=stuff.id)
            resource_description = self._kernel.game.config.resources[
                stuff.filled_with_resource]
            return [
                CharacterActionLink(
                    name=f"Boire {resource_description.name}",
                    link=get_with_stuff_action_url(
                        character.id,
                        ActionType.DRINK_STUFF,
                        query_params=self.input_model_serializer.dump(
                            query_params),
                        stuff_id=stuff.id,
                        action_description_id=self._description.id,
                    ),
                    cost=self.get_cost(character, stuff),
                )
            ]

        return []
コード例 #5
0
ファイル: take.py プロジェクト: coolkat64/rolling
 def get_character_actions(
         self, character: "CharacterModel", with_character: "CharacterModel"
 ) -> typing.List[CharacterActionLink]:
     return [
         CharacterActionLink(name="Prendre",
                             link=self._get_url(character, with_character))
     ]
コード例 #6
0
    def get_character_actions(
            self, character: "CharacterModel",
            resource_id: str) -> typing.List[CharacterActionLink]:
        accept_resources_ids = [
            rd.id for rd in self._description.properties["accept_resources"]
        ]
        # TODO BS 2019-09-14: perf
        carried_resource = next(
            (cr
             for cr in self._kernel.resource_lib.get_carried_by(character.id)
             if cr.id == resource_id))

        if carried_resource.id in accept_resources_ids:
            return [
                # FIXME BS NOW: il semblerait que que comme on ne donne pas le description_id,
                # lorsque on veux consommer la resource, l'action factory prend la première, et donc
                # pas la bonne. Revoir ça, je pense qu'il faut systématiquement donner un
                # description_id. Voir les conséquences.
                CharacterActionLink(
                    name=f"Manger {carried_resource.name}",
                    link=get_with_resource_action_url(
                        character_id=character.id,
                        action_type=ActionType.EAT_RESOURCE,
                        resource_id=resource_id,
                        query_params={},
                        action_description_id=self._description.id,
                    ),
                    cost=None,
                )
            ]

        return []
コード例 #7
0
    def get_character_actions(
            self, character: "CharacterModel",
            stuff: "StuffModel") -> typing.List[CharacterActionLink]:
        actions: typing.List[CharacterActionLink] = []

        for fill_acceptable_type in self._kernel.game.config.fill_with_material_ids:
            for resource in self._kernel.game.world_manager.get_resource_on_or_around(
                    world_row_i=character.world_row_i,
                    world_col_i=character.world_col_i,
                    zone_row_i=character.zone_row_i,
                    zone_col_i=character.zone_col_i,
                    material_type=fill_acceptable_type,
            ):
                query_params = self.input_model(resource_id=resource.id)
                actions.append(
                    CharacterActionLink(
                        name=f"Remplir {stuff.name} avec {resource.name}",
                        link=get_with_stuff_action_url(
                            character_id=character.id,
                            action_type=ActionType.FILL_STUFF,
                            stuff_id=stuff.id,
                            query_params=self.input_model_serializer.dump(
                                query_params),
                            action_description_id=self._description.id,
                        ),
                        cost=self.get_cost(character, stuff),
                    ))

        return actions
コード例 #8
0
ファイル: mix.py プロジェクト: coolkat64/rolling
    def get_character_actions(
            self, character: "CharacterModel",
            resource_id: str) -> typing.List[CharacterActionLink]:
        actions: typing.List[CharacterActionLink] = []

        for carried_resource in self._kernel.resource_lib.get_carried_by(
                character.id):
            if carried_resource.id == resource_id:
                continue

            for resource_mix_description in self._kernel.game.config.get_resource_mixs_with(
                [resource_id, carried_resource.id]):
                with_str = ", ".join([
                    r.resource.name
                    for r in resource_mix_description.required_resources
                    if r.resource.id != resource_id
                ])
                query_params = self.input_model_serializer.dump(
                    self.input_model(
                        resource_mix_id=resource_mix_description.id))
                actions.append(
                    CharacterActionLink(
                        name=
                        f"Produire de {resource_mix_description.produce_resource.name} avec {with_str}",
                        link=get_with_resource_action_url(
                            character_id=character.id,
                            action_type=ActionType.MIX_RESOURCES,
                            resource_id=carried_resource.id,
                            query_params=query_params,
                            action_description_id=self._description.id,
                        ),
                        cost=None,
                    ))

        return actions
コード例 #9
0
ファイル: drink.py プロジェクト: coolkat64/rolling
    def get_character_actions(
            self,
            character: "CharacterModel") -> typing.List[CharacterActionLink]:
        character_actions: typing.List[CharacterActionLink] = []
        accept_resources_ids = [
            rd.id for rd in self._description.properties["accept_resources"]
        ]

        for resource in self._kernel.game.world_manager.get_resource_on_or_around(
                world_row_i=character.world_row_i,
                world_col_i=character.world_col_i,
                zone_row_i=character.zone_row_i,
                zone_col_i=character.zone_col_i,
                material_type=self._kernel.game.config.liquid_material_id,
        ):
            if resource.id in accept_resources_ids:
                query_params = self.input_model(resource_id=resource.id)
                character_actions.append(
                    CharacterActionLink(
                        name=f"Drink {resource.name}",
                        link=get_character_action_url(
                            character_id=character.id,
                            action_type=ActionType.DRINK_RESOURCE,
                            action_description_id=self._description.id,
                            query_params=self.input_model_serializer.dump(
                                query_params),
                        ),
                        cost=self.get_cost(character),
                    ))

        return character_actions
コード例 #10
0
ファイル: fight.py プロジェクト: coolkat64/rolling
 def get_character_actions(
         self, character: "CharacterModel", with_character: "CharacterModel"
 ) -> typing.List[CharacterActionLink]:
     return [
         CharacterActionLink(name=f"Attaquer",
                             link=self._get_here_url(
                                 character, with_character),
                             cost=0.0)
     ]
コード例 #11
0
 def get_character_actions(
         self, character: "CharacterModel", with_character: "CharacterModel"
 ) -> typing.List[CharacterActionLink]:
     if self._kernel.character_lib.is_following(character.id,
                                                with_character.id,
                                                discreetly=True):
         return [
             CharacterActionLink(
                 name=
                 f"Arreter de suivre {with_character.name} discrètement",
                 link=self._get_url(character, with_character),
             )
         ]
     return [
         CharacterActionLink(
             name=f"Arreter de suivre {with_character.name}",
             link=self._get_url(character, with_character),
         )
     ]
コード例 #12
0
ファイル: build.py プロジェクト: coolkat64/rolling
 def get_character_actions(
     self, character: "CharacterModel"
 ) -> typing.List[CharacterActionLink]:
     build_id = self._description.properties["build_id"]
     build_description = self._kernel.game.config.builds[build_id]
     return [
         CharacterActionLink(
             name=build_description.name,
             link=self.get_base_url(character),
             cost=self.get_cost(character),
         )
     ]
コード例 #13
0
ファイル: kill.py プロジェクト: coolkat64/rolling
 def get_character_actions(
         self, character: "CharacterModel", with_character: "CharacterModel"
 ) -> typing.List[CharacterActionLink]:
     return [
         CharacterActionLink(
             name="Tuer",
             link=get_with_character_action_url(
                 character_id=character.id,
                 with_character_id=with_character.id,
                 action_type=ActionType.KILL_CHARACTER,
                 query_params={},
                 action_description_id=self._description.id,
             ),
         )
     ]
コード例 #14
0
ファイル: craft.py プロジェクト: coolkat64/rolling
 def get_character_actions(
     self, character: "CharacterModel"
 ) -> typing.List[CharacterActionLink]:
     return [
         CharacterActionLink(
             name=f"Commencer {self._description.name}",
             link=get_character_action_url(
                 character_id=character.id,
                 action_type=ActionType.BEGIN_STUFF_CONSTRUCTION,
                 action_description_id=self._description.id,
                 query_params={},
             ),
             cost=self.get_cost(character),
             group_name=self._description.properties["link_group_name"],
         )
     ]
コード例 #15
0
ファイル: craft.py プロジェクト: coolkat64/rolling
 def get_character_actions(
     self, character: "CharacterModel", stuff: "StuffModel"
 ) -> typing.List[CharacterActionLink]:
     return [
         CharacterActionLink(
             name=f"Continuer le travail",
             link=get_with_stuff_action_url(
                 character_id=character.id,
                 action_type=ActionType.CONTINUE_STUFF_CONSTRUCTION,
                 action_description_id=self._description.id,
                 query_params={},
                 stuff_id=stuff.id,
             ),
             cost=self.get_cost(character, stuff),
             merge_by="continue_craft",
         )
     ]
コード例 #16
0
ファイル: drop.py プロジェクト: coolkat64/rolling
    def get_character_actions(
            self, character: "CharacterModel",
            stuff: "StuffModel") -> typing.List[CharacterActionLink]:
        actions: typing.List[CharacterActionLink] = [
            CharacterActionLink(
                name=f"Laisser {stuff.name} ici",
                link=get_with_stuff_action_url(
                    character_id=character.id,
                    action_type=ActionType.DROP_STUFF,
                    stuff_id=stuff.id,
                    query_params={},
                    action_description_id=self._description.id,
                ),
                cost=self.get_cost(character, stuff),
            )
        ]

        return actions
コード例 #17
0
ファイル: use.py プロジェクト: coolkat64/rolling
    def get_character_actions(
        self, character: "CharacterModel", stuff: "StuffModel"
    ) -> typing.List[CharacterActionLink]:
        actions: typing.List[CharacterActionLink] = [
            CharacterActionLink(
                name=f"Ne plus utiliser {stuff.name} comme armure/equipement",
                link=get_with_stuff_action_url(
                    character_id=character.id,
                    action_type=ActionType.NOT_USE_AS_ARMOR,
                    stuff_id=stuff.id,
                    query_params={},
                    action_description_id=self._description.id,
                ),
                cost=self.get_cost(character, stuff),
            )
        ]

        return actions
コード例 #18
0
ファイル: use.py プロジェクト: coolkat64/rolling
    def get_character_actions(
        self, character: "CharacterModel", stuff: "StuffModel"
    ) -> typing.List[CharacterActionLink]:
        actions: typing.List[CharacterActionLink] = [
            CharacterActionLink(
                name=f"Utiliser {stuff.name} comme bouclier",
                link=get_with_stuff_action_url(
                    character_id=character.id,
                    action_type=ActionType.USE_AS_SHIELD,
                    stuff_id=stuff.id,
                    query_params={},
                    action_description_id=self._description.id,
                ),
                cost=self.get_cost(character, stuff),
            )
        ]

        return actions
コード例 #19
0
ファイル: knowledge.py プロジェクト: coolkat64/rolling
    def get_character_actions(
            self, character: "CharacterModel", with_character: "CharacterModel"
    ) -> typing.List[CharacterActionLink]:
        action_links = []

        for knowledge_id, knowledge_description in character.knowledges.items(
        ):
            action_links.append(
                CharacterActionLink(
                    name=f"Proposer un cours de {knowledge_description.name}",
                    link=self._get_url(
                        character,
                        with_character,
                        ProposeTeachKnowledgeModel(knowledge_id=knowledge_id),
                    ),
                    group_name="Enseigner",
                ))

        return action_links
コード例 #20
0
    def get_character_actions(
            self, character: "CharacterModel",
            stuff: "StuffModel") -> typing.List[CharacterActionLink]:
        if stuff.stuff_id in self._description.properties["accept_stuff_ids"]:
            return [
                CharacterActionLink(
                    name=f"Manger {stuff.name}",
                    link=get_with_stuff_action_url(
                        character.id,
                        ActionType.EAT_STUFF,
                        query_params={},
                        stuff_id=stuff.id,
                        action_description_id=self._description.id,
                    ),
                    cost=self.get_cost(character, stuff),
                )
            ]

        return []
コード例 #21
0
ファイル: build.py プロジェクト: coolkat64/rolling
    def get_character_actions(
        self, character: "CharacterModel", build_id: int
    ) -> typing.List[CharacterActionLink]:
        build_doc = self._kernel.build_lib.get_build_doc(build_id)
        if build_doc.under_construction:
            return [
                CharacterActionLink(
                    name=f"Faire avancer la construction",
                    link=get_with_build_action_url(
                        character_id=character.id,
                        build_id=build_id,
                        action_type=ActionType.CONSTRUCT_BUILD,
                        action_description_id=self._description.id,
                        query_params={},
                    ),
                    cost=None,
                )
            ]

        return []
コード例 #22
0
ファイル: craft.py プロジェクト: coolkat64/rolling
    def get_character_actions(
        self, character: "CharacterModel", resource_id: str
    ) -> typing.List[CharacterActionLink]:
        try:
            self.check_is_possible(character, resource_id)
        except ImpossibleAction:
            return []

        return [
            CharacterActionLink(
                name=self._description.name,
                link=get_with_resource_action_url(
                    character_id=character.id,
                    action_type=ActionType.CRAFT_STUFF_WITH_RESOURCE,
                    action_description_id=self._description.id,
                    resource_id=resource_id,
                    query_params={},
                ),
                cost=self.get_cost(character, resource_id),
            )
        ]
コード例 #23
0
ファイル: hunt.py プロジェクト: coolkat64/rolling
    def get_character_actions(
        self, character: "CharacterModel"
    ) -> typing.List[CharacterActionLink]:
        try:
            self.check_is_possible(character)
        except ImpossibleAction:
            return []

        return [
            CharacterActionLink(
                name=self._description.name,
                link=get_character_action_url(
                    character_id=character.id,
                    action_type=ActionType.SEARCH_FOOD,
                    action_description_id=self._description.id,
                    query_params={},
                ),
                group_name="Chercher de la nourriture",
                cost=self.get_cost(character),
            )
        ]
コード例 #24
0
ファイル: craft.py プロジェクト: coolkat64/rolling
    def get_character_actions(
        self, character: "CharacterModel", stuff: "StuffModel"
    ) -> typing.List[CharacterActionLink]:
        try:
            self.check_is_possible(character, stuff)
        except ImpossibleAction:
            return []

        return [
            # FIXME BS NOW: all CharacterActionLink must generate a can_be_back_url=True
            CharacterActionLink(
                name=self._description.name,
                link=get_with_stuff_action_url(
                    character_id=character.id,
                    action_type=ActionType.CRAFT_STUFF_WITH_STUFF,
                    action_description_id=self._description.id,
                    stuff_id=stuff.id,
                    query_params={},
                ),
                cost=self.get_cost(character, stuff),
            )
        ]
コード例 #25
0
ファイル: build.py プロジェクト: coolkat64/rolling
    def get_character_actions(
        self, character: "CharacterModel"
    ) -> typing.List[CharacterActionLink]:
        try:
            self.check_is_possible(character)
        except ImpossibleAction:
            pass

        build_id = self._description.properties["build_id"]
        build_description = self._kernel.game.config.builds[build_id]
        return [
            CharacterActionLink(
                name=build_description.name,
                link=get_character_action_url(
                    character_id=character.id,
                    action_type=ActionType.BEGIN_BUILD,
                    action_description_id=self._description.id,
                    query_params={},
                ),
                cost=self.get_cost(character, input_=None),
            )
        ]
コード例 #26
0
ファイル: build.py プロジェクト: coolkat64/rolling
    def get_character_actions(
        self, character: "CharacterModel", build_id: int
    ) -> typing.List[CharacterActionLink]:
        actions: typing.List[CharacterActionLink] = []
        build_doc = self._kernel.build_lib.get_build_doc(build_id)
        build_description = self._kernel.game.config.builds[build_doc.build_id]

        for required_resource in build_description.build_require_resources:
            resource_description, left, left_percent = self.get_resource_infos(
                self._kernel, required_resource, build_doc=build_doc
            )
            if left <= 0:
                continue

            left_str = quantity_to_str(left, resource_description.unit, kernel=self._kernel)

            query_params = BringResourcesOnBuild.input_model_serializer.dump(
                BringResourcesOnBuild.input_model(resource_id=required_resource.resource_id)
            )
            name = (
                f"Apporter {resource_description.name} pour la construction "
                f"(manque {left_str} soit {round(left_percent)}%)"
            )
            actions.append(
                CharacterActionLink(
                    name=name,
                    link=get_with_build_action_url(
                        character_id=character.id,
                        build_id=build_id,
                        action_type=ActionType.BRING_RESOURCE_ON_BUILD,
                        action_description_id=self._description.id,
                        query_params=query_params,
                    ),
                    cost=None,
                )
            )

        return actions
コード例 #27
0
ファイル: drop.py プロジェクト: coolkat64/rolling
    def get_character_actions(
            self, character: "CharacterModel",
            resource_id: str) -> typing.List[CharacterActionLink]:
        # TODO BS 2019-09-09: perfs
        carried_resources = self._kernel.resource_lib.get_carried_by(
            character.id)
        carried_resource = next(
            (r for r in carried_resources if r.id == resource_id))

        actions: typing.List[CharacterActionLink] = [
            CharacterActionLink(
                name=f"Laisser de {carried_resource.name} ici",
                link=get_with_resource_action_url(
                    character_id=character.id,
                    action_type=ActionType.DROP_RESOURCE,
                    resource_id=carried_resource.id,
                    query_params={},
                    action_description_id=self._description.id,
                ),
                cost=None,
            )
        ]

        return actions
コード例 #28
0
    def get_character_actions(
            self,
            character: "CharacterModel") -> typing.List[CharacterActionLink]:
        inspect_zone_positions = get_on_and_around_coordinates(
            character.zone_row_i, character.zone_col_i)
        character_actions: typing.List[CharacterActionLink] = []

        for row_i, col_i in inspect_zone_positions:
            for resource in self._kernel.game.world_manager.get_resources_at(
                    world_row_i=character.world_row_i,
                    world_col_i=character.world_col_i,
                    zone_row_i=row_i,
                    zone_col_i=col_i,
            ):
                tile_type = self._kernel.tile_maps_by_position[(
                    character.world_row_i,
                    character.world_col_i)].source.geography.rows[row_i][col_i]
                query_params = self.input_model(resource_id=resource.id,
                                                row_i=row_i,
                                                col_i=col_i)
                character_actions.append(
                    CharacterActionLink(
                        name=f"Récupérer {resource.name} sur {tile_type.name}",
                        link=get_character_action_url(
                            character_id=character.id,
                            action_type=ActionType.COLLECT_RESOURCE,
                            action_description_id=self._description.id,
                            query_params=self.input_model_serializer.dump(
                                query_params),
                        ),
                        cost=None,
                        merge_by=(ActionType.COLLECT_RESOURCE, resource.id),
                        group_name="Ramasser du matériel ou des ressources",
                    ))

        return character_actions