Beispiel #1
0
    def from_dict(cls, bot: vbu.Bot, location_data: dict, quotes_data: dict):
        """
        Loads an :class:`Item` from a dictionary.

        Args:
            bot (:class:`voxelbot.VoxelBot`): The bot used for loading emojis.
            data (`dict`): The dictionary to load the item from.
        """

        return cls(
            bot,
            location_data["level"],
            location_data["id"],
            location_data["name"],
            location_data["description"],
            bot.get_emoji(location_data["emoji"])
            if isinstance(location_data["emoji"], int)
            else location_data["emoji"],
            LootTable(*(LootTableItem(**item) for item in location_data["loot_table"])),
            Quotes(
                (location_data["quotes"]["success"]) + quotes_data["success"],
                (location_data["quotes"]["fail"]) + quotes_data["fail"],
                MiniGames(
                    FillInTheBlank(
                        **location_data["quotes"]["minigames"]["fill_in_the_blank"],
                    ),
                    Scramble(
                        **location_data["quotes"]["minigames"]["scramble"],
                    ),
                    Retype(**location_data["quotes"]["minigames"]["retype"]),
                ),
            ),
        )
Beispiel #2
0
    def from_dict(cls, bot: vbu.Bot, data: dict):
        """
        Loads an :class:`Item` from a dictionary. This can be used to load an item from `./config/items.toml`.

        Args:
            data (`dict`): The dictionary to load the item from.
        """

        return cls(
            bot,
            data["id"],
            data["type"],
            data["rarity"],
            bot.get_emoji(data["emoji"])
            if isinstance(data["emoji"], int) else data["emoji"],
            data["name"],
            data["description"],
            [
                SkillRequirements(**req)
                for req in data["skill_requirements"] if req
            ],
            ShopSettings(**data["shop_settings"]),
            [Recipe(**r) for r in data["recipe"] if r],
            Usage.from_dict(data["usage"]),
        )
Beispiel #3
0
 def __init__(
     self,
     bot: vbu.Bot,
     level: int,
     id: str,
     name: str,
     description: str,
     emoji: typing.Union[str, int, discord.Emoji],
     loot_table: LootTable,
     quotes: Quotes,
 ):
     self.level = level
     self.id = id
     self.name = name
     self.description = description
     self.emoji = bot.get_emoji(emoji) if isinstance(emoji, int) else emoji
     self.loot_table = loot_table
     self.quotes = quotes
Beispiel #4
0
    def __init__(
        self,
        bot: vbu.Bot,
        id: str,
        type: str,
        rarity: str,
        emoji: typing.Union[int, discord.Emoji],
        name: str,
        description: str,
        skill_requirements: typing.List[SkillRequirements],
        shop_settings: ShopSettings,
        recipe: typing.List[Recipe],
        usage: Usage,
        amount: int = 1,
    ):
        """
        Args:
            bot (:class:`vbu.Bot`): The bot.
            id (`str` UPPER_SNAKE_CASE): The ID of the item.
            type (`str` UPPER_SNAKE_CASE): The type of the item..
            rarity (`str` UPPER_SNAKE_CASE): The rarity of the item.
            emoji (`int` or `str`): The custom ID of the emoji associated with the item.
            name (`str`): The name of the item.
            description (`str`): The description of the item.
            skill_requirements (`list` of :class:`SkillRequirements`): The skill requirements of the item.
            shop_settings (`list` of :class:`ShopSettings`): The shop settings of the item.
            recipe (`list` of :class:`Recipe`): The recipe of the item.
            usage (:class:`Usage`): The usage of the item.
            amount (`int`): The amount of the item.
        """

        self.id = id
        self.type = type
        self.rarity = rarity
        self.emoji = bot.get_emoji(emoji) if isinstance(emoji, int) else emoji
        self.name = name
        self.description = description
        self.skill_requirements = skill_requirements
        self.shop_settings = shop_settings
        self.recipe = recipe
        self.usage = usage
        self.amount = amount