"""Contains all the cogs that deal with game commands.""" from discord.ext import commands # Has the cog class from discord_slash import cog_ext # Used for slash commands from gwendolyn.utils import get_params # pylint: disable=import-error params = get_params() class GamesCog(commands.Cog): """Contains miscellaneous game commands.""" def __init__(self, bot): """Initialize the cog.""" self.bot = bot @cog_ext.cog_slash(**params["balance"]) async def balance(self, ctx): """Check user balance.""" await self.bot.money.sendBalance(ctx) @cog_ext.cog_slash(**params["give"]) async def give(self, ctx, user, amount): """Give another user an amount of GwendoBucks.""" await self.bot.money.giveMoney(ctx, user, amount) @cog_ext.cog_slash(**params["invest"]) async def invest(self, ctx, parameters="check"): """Invest GwendoBucks in the stock market.""" await self.bot.games.invest.parseInvest(ctx, parameters) @cog_ext.cog_slash(**params["trivia"]) async def trivia(self, ctx, answer=""): """Run a game of trivia.""" await self.bot.games.trivia.triviaParse(ctx, answer) class BlackjackCog(commands.Cog): """Contains the blackjack commands.""" def __init__(self, bot): """Initialize the cog.""" self.bot = bot @cog_ext.cog_subcommand(**params["blackjack_start"]) async def blackjack_start(self, ctx): """Start a game of blackjack.""" await self.bot.games.blackjack.start(ctx) @cog_ext.cog_subcommand(**params["blackjack_bet"]) async def blackjack_bet(self, ctx, bet): """Enter the game of blackjack with a bet.""" await self.bot.games.blackjack.enterGame(ctx, bet) @cog_ext.cog_subcommand(**params["blackjack_stand"]) async def blackjack_stand(self, ctx, hand=""): """Stand on your hand in blackjack.""" await self.bot.games.blackjack.stand(ctx, hand) @cog_ext.cog_subcommand(**params["blackjack_hit"]) async def blackjack_hit(self, ctx, hand=0): """Hit on your hand in blackjack.""" await self.bot.games.blackjack.hit(ctx, hand) @cog_ext.cog_subcommand(**params["blackjack_double"]) async def blackjack_double(self, ctx, hand=0): """Double in blackjack.""" await self.bot.games.blackjack.double(ctx, hand) @cog_ext.cog_subcommand(**params["blackjack_split"]) async def blackjack_split(self, ctx, hand=0): """Split your hand in blackjack.""" await self.bot.games.blackjack.split(ctx, hand) @cog_ext.cog_subcommand(**params["blackjack_hilo"]) async def blackjack_hilo(self, ctx): """Get the hilo value for the deck in blackjack.""" await self.bot.games.blackjack.hilo(ctx) @cog_ext.cog_subcommand(**params["blackjack_shuffle"]) async def blackjack_shuffle(self, ctx): """Shuffle the blackjack game.""" await self.bot.games.blackjack.shuffle(ctx) @cog_ext.cog_subcommand(**params["blackjack_cards"]) async def blackjack_cards(self, ctx): """Get the amount of cards left in the blackjack deck.""" await self.bot.games.blackjack.cards(ctx) class ConnectFourCog(commands.Cog): """Contains all the connect four commands.""" def __init__(self, bot): """Initialize the cog.""" self.bot = bot @cog_ext.cog_subcommand(**params["connect_four_start_user"]) async def connect_four_start_user(self, ctx, user): """Start a game of connect four against another user.""" await self.bot.games.connect_four.start(ctx, user) @cog_ext.cog_subcommand(**params["connect_four_start_gwendolyn"]) async def connect_four_start_gwendolyn(self, ctx, difficulty=3): """Start a game of connect four against Gwendolyn.""" await self.bot.games.connect_four.start(ctx, difficulty) @cog_ext.cog_subcommand(**params["connect_four_surrender"]) async def connect_four_surrender(self, ctx): """Surrender the game of connect four.""" await self.bot.games.connect_four.surrender(ctx) class HangmanCog(commands.Cog): """Contains all the hangman commands.""" def __init__(self, bot): """Initialize the cog.""" self.bot = bot @cog_ext.cog_subcommand(**params["hangman_start"]) async def hangman_start(self, ctx): """Start a game of hangman.""" await self.bot.games.hangman.start(ctx) @cog_ext.cog_subcommand(**params["hangman_stop"]) async def hangman_stop(self, ctx): """Stop the current game of hangman.""" await self.bot.games.hangman.stop(ctx) class HexCog(commands.Cog): """Contains all the hex commands.""" def __init__(self, bot): """Initialize the cog.""" self.bot = bot self.hex = self.bot.games.hex @cog_ext.cog_subcommand(**params["hex_start_user"]) async def hex_start_user(self, ctx, user): """Start a game of hex against another player.""" await self.hex.start(ctx, user) @cog_ext.cog_subcommand(**params["hex_start_gwendolyn"]) async def hex_start_gwendolyn(self, ctx, difficulty=2): """Start a game of hex against Gwendolyn.""" await self.hex.start(ctx, difficulty) @cog_ext.cog_subcommand(**params["hex_place"]) async def hex_place(self, ctx, coordinates): """Place a piece in the hex game.""" await self.hex.placeHex(ctx, coordinates, f"#{ctx.author.id}") @cog_ext.cog_subcommand(**params["hex_undo"]) async def hex_undo(self, ctx): """Undo your last hex move.""" await self.hex.undo(ctx) @cog_ext.cog_subcommand(**params["hex_swap"]) async def hex_swap(self, ctx): """Perform a hex swap.""" await self.hex.swap(ctx) @cog_ext.cog_subcommand(**params["hex_surrender"]) async def hex_surrender(self, ctx): """Surrender the hex game.""" await self.hex.surrender(ctx) def setup(bot): """Add all the cogs to the bot.""" bot.add_cog(GamesCog(bot)) bot.add_cog(BlackjackCog(bot)) bot.add_cog(ConnectFourCog(bot)) bot.add_cog(HangmanCog(bot)) bot.add_cog(HexCog(bot))