from atexit import register import logging import discord from distutils import config from redbot.core import commands, Config from .check import Check from .commands import RPGCommands from .actions import RPGActions from .shop import RPGShops from .menu import RPGMenu from .inventory import RPGInventory class RPG(commands.Cog): def __init__(self, bot): self.bot = bot self.menu = RPGMenu(self) self.commands = RPGCommands(self, bot) self.actions = RPGActions(self) self.shop = RPGShops(self) self.inventory = RPGInventory(self) self.log = logging.getLogger("red.rpg") self.config = Config.get_conf(self, identifier=6857309412) default_guild_settings = { "characters": { "default_stats": { # Nested under 'characters' "Strength": 1, "Defense": 1, "Agility": 1, "Magic": 1, "Luck": 1, "Health": 100, "Mana": 50, "Stamina": 50, "Experience": 0, "Gold": 0, "Damage": 1, "Recovery": 1, "Resist": 1, "Critical": 1, "Speed": 1, "Level": 1, "Class": [], "Skills": [], "Inventory": [], "Equipment": {}, "Quests": [], "Guild": None, "Location": None, "Followers": None, "Pets": None, }, "default_statsmax": { # Nested under 'characters' "Strength": 999, "Defense": 999, "Agility": 999, "Magic": 999, "Luck": 999, "Health": 999, "Mana": 999, "Stamina": 999, "Experience": 999999999, "Gold": 999999999, "Damage": 999, "Recovery": 999, "Resist": 999, "Critical": 999, "Speed": 999, "Level": 999999999, } }, "classes": { # Definitions of available classes "Warrior": { "stats": { "Strength": 5, "Defense": 4, "Agility": 3, # ... other stats with appropriate values for a warrior }, "description": "A brave and sturdy warrior, skilled in melee combat." }, "Mage": { "stats": { "Strength": 2, "Defense": 2, "Magic": 5, # ... other stats with appropriate values for a mage }, "description": "A wise and powerful mage, capable of wielding arcane magic." }, "Rogue": { "stats": { "Strength": 3, "Defense": 3, "Agility": 5, # ... other stats with appropriate values for a rogue }, "description": "A nimble and cunning rogue, adept at stealth and trickery." } # ... add more classes as needed }, "active_character": {}, # Store the name of the currently active character for each member } default_user_settings = { "active_character": None, } default_shop = { "Items": [], "Prices": [], "Currency": "Gold", "Currency_Symbol": "G", "Currency_Plural": "Gold", "Currency_Plural_Symbol": "G", "Currency_Emoji": "💰", } default_quest = { "Name": None, "Description": None, "Reward": None, "Requirements": None, "Progress": None, "Status": None, "Type": None, "Repeat": None, "Time": None, "Location": None, "Guild": None, "Followers": None, "Pets": None, } self.config.register_guild(**default_guild_settings) self.config.register_user(**default_user_settings) self.config.register_global(**default_shop) self.config.register_global(**default_quest) self.commands = RPGCommands(self, bot) self.actions = RPGActions(self) self.shop = RPGShops(self) self.menu = RPGMenu(self) self.inventory = RPGInventory(self) async def register_guild(self, ctx): await self.config.register_guild(ctx.guild, **default_guild_settings) await self.send_message(ctx, "Guild registered for RPG system.") async def register_user(self, ctx): await self.config.register_user(ctx.author, **default_user_settings) await self.send_message(ctx, "User registered for RPG system.") async def register_shop(self, ctx): await self.config.register_global(**default_shop) await self.send_message(ctx, "Shop registered for RPG system.") async def register_quest(self, ctx): await self.config.register_global(**default_quest) await self.send_message(ctx, "Quest registered for RPG system.") async def unregister_guild(self, ctx): await self.config.unregister_guild(ctx.guild) await self.send_message(ctx, "Guild unregistered for RPG system.") async def unregister_user(self, ctx): await self.config.unregister_user(ctx.author) await self.send_message(ctx, "User unregistered for RPG system.") async def unregister_shop(self, ctx): await self.config.unregister_global("Shop") await self.send_message(ctx, "Shop unregistered for RPG system.") async def unregister_quest(self, ctx): await self.config.unregister_global("Quest") await self.send_message(ctx, "Quest unregistered for RPG system.") async def send_message(self, ctx, message, interaction, embed=None): if embed: await ctx.send(message, embed=embed) elif interaction: await interaction.response.send(message) else: await ctx.send(message)