"""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 utils import getParams # pylint: disable=import-error params = getParams() 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["blackjackStart"]) async def blackjackStart(self, ctx): """Start a game of blackjack.""" await self.bot.games.blackjack.start(ctx) @cog_ext.cog_subcommand(**params["blackjackBet"]) async def blackjackBet(self, ctx, bet): """Enter the game of blackjack with a bet.""" await self.bot.games.blackjack.enterGame(ctx, bet) @cog_ext.cog_subcommand(**params["blackjackStand"]) async def blackjackStand(self, ctx, hand=""): """Stand on your hand in blackjack.""" await self.bot.games.blackjack.stand(ctx, hand) @cog_ext.cog_subcommand(**params["blackjackHit"]) async def blackjackHit(self, ctx, hand=0): """Hit on your hand in blackjack.""" await self.bot.games.blackjack.hit(ctx, hand) @cog_ext.cog_subcommand(**params["blackjackDouble"]) async def blackjackDouble(self, ctx, hand=0): """Double in blackjack.""" await self.bot.games.blackjack.double(ctx, hand) @cog_ext.cog_subcommand(**params["blackjackSplit"]) async def blackjackSplit(self, ctx, hand=0): """Split your hand in blackjack.""" await self.bot.games.blackjack.split(ctx, hand) @cog_ext.cog_subcommand(**params["blackjackHilo"]) async def blackjackHilo(self, ctx): """Get the hilo value for the deck in blackjack.""" await self.bot.games.blackjack.hilo(ctx) @cog_ext.cog_subcommand(**params["blackjackShuffle"]) async def blackjackShuffle(self, ctx): """Shuffle the blackjack game.""" await self.bot.games.blackjack.shuffle(ctx) @cog_ext.cog_subcommand(**params["blackjackCards"]) async def blackjackCards(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["connectFourStartUser"]) async def connectFourStartUser(self, ctx, user): """Start a game of connect four against another user.""" await self.bot.games.connectFour.start(ctx, user) @cog_ext.cog_subcommand(**params["connectFourStartGwendolyn"]) async def connectFourStartGwendolyn(self, ctx, difficulty=3): """Start a game of connect four against Gwendolyn.""" await self.bot.games.connectFour.start(ctx, difficulty) @cog_ext.cog_subcommand(**params["connectFourSurrender"]) async def connectFourSurrender(self, ctx): """Surrender the game of connect four.""" await self.bot.games.connectFour.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["hangmanStart"]) async def hangmanStart(self, ctx): """Start a game of hangman.""" await self.bot.games.hangman.start(ctx) @cog_ext.cog_subcommand(**params["hangmanStop"]) async def hangmanStop(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["hexStartUser"]) async def hexStartUser(self, ctx, user): """Start a game of hex against another player.""" await self.hex.start(ctx, user) @cog_ext.cog_subcommand(**params["hexStartGwendolyn"]) async def hexStartGwendolyn(self, ctx, difficulty=2): """Start a game of hex against Gwendolyn.""" await self.hex.start(ctx, difficulty) @cog_ext.cog_subcommand(**params["hexPlace"]) async def hexPlace(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["hexUndo"]) async def hexUndo(self, ctx): """Undo your last hex move.""" await self.hex.undo(ctx) @cog_ext.cog_subcommand(**params["hexSwap"]) async def hexSwap(self, ctx): """Perform a hex swap.""" await self.hex.swap(ctx) @cog_ext.cog_subcommand(**params["hexSurrender"]) async def hexSurrender(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))