import discord, asyncio, json from discord.ext import commands from discord_slash import cog_ext from utils import getParams params = getParams() class GamesCog(commands.Cog): def __init__(self,bot): """Runs game stuff.""" self.bot = bot # Checks user balance @cog_ext.cog_slash(**params["balance"]) async def balance(self, ctx): await self.bot.money.sendBalance(ctx) # Gives another user an amount of GwendoBucks @cog_ext.cog_slash(**params["give"]) async def give(self, ctx, user, amount): await self.bot.money.giveMoney(ctx, user, amount) # Invest GwendoBucks in the stock market @cog_ext.cog_slash(**params["invest"]) async def invest(self, ctx, parameters = "check"): await self.bot.games.invest.parseInvest(ctx, parameters) # Runs a game of trivia @cog_ext.cog_slash(**params["trivia"]) async def trivia(self, ctx, answer = ""): await self.bot.games.trivia.triviaParse(ctx, answer) class BlackjackCog(commands.Cog): def __init__(self,bot): """Runs game stuff.""" self.bot = bot # Starts a game of blackjack @cog_ext.cog_subcommand(**params["blackjackStart"]) async def blackjackStart(self, ctx): await self.bot.games.blackjack.start(ctx) @cog_ext.cog_subcommand(**params["blackjackBet"]) async def blackjackBet(self, ctx, bet): await self.bot.games.blackjack.playerDrawHand(ctx, bet) @cog_ext.cog_subcommand(**params["blackjackStand"]) async def blackjackStand(self, ctx, hand = ""): await self.bot.games.blackjack.stand(ctx, hand) @cog_ext.cog_subcommand(**params["blackjackHit"]) async def blackjackHit(self, ctx, hand = 0): await self.bot.games.blackjack.hit(ctx, hand) @cog_ext.cog_subcommand(**params["blackjackDouble"]) async def blackjackDouble(self, ctx, hand = 0): await self.bot.games.blackjack.double(ctx, hand) @cog_ext.cog_subcommand(**params["blackjackSplit"]) async def blackjackSplit(self, ctx, hand = 0): await self.bot.games.blackjack.split(ctx, hand) @cog_ext.cog_subcommand(**params["blackjackHilo"]) async def blackjackHilo(self, ctx): await self.bot.games.blackjack.hilo(ctx) @cog_ext.cog_subcommand(**params["blackjackShuffle"]) async def blackjackShuffle(self, ctx): await self.bot.games.blackjack.shuffle(ctx) @cog_ext.cog_subcommand(**params["blackjackCards"]) async def blackjackCards(self, ctx): await self.bot.games.blackjack.cards(ctx) class ConnectFourCog(commands.Cog): def __init__(self,bot): """Runs game stuff.""" self.bot = bot # Start a game of connect four against a user @cog_ext.cog_subcommand(**params["connectFourStartUser"]) async def connectFourStartUser(self, ctx, user): await self.bot.games.connectFour.start(ctx, user) # Start a game of connect four against gwendolyn @cog_ext.cog_subcommand(**params["connectFourStartGwendolyn"]) async def connectFourStartGwendolyn(self, ctx, difficulty = 3): await self.bot.games.connectFour.start(ctx, difficulty) # Stop the current game of connect four @cog_ext.cog_subcommand(**params["connectFourSurrender"]) async def connectFourSurrender(self, ctx): await self.bot.games.connectFour.surrender(ctx) class HangmanCog(commands.Cog): def __init__(self,bot): """Runs game stuff.""" self.bot = bot # Starts a game of Hangman @cog_ext.cog_subcommand(**params["hangmanStart"]) async def hangmanStart(self, ctx): await self.bot.games.hangman.start(ctx) # Stops a game of Hangman @cog_ext.cog_subcommand(**params["hangmanStop"]) async def hangmanStop(self, ctx): await self.bot.games.hangman.stop(ctx) class HexCog(commands.Cog): def __init__(self,bot): """Runs game stuff.""" self.bot = bot # Start a game of Hex against another user @cog_ext.cog_subcommand(**params["hexStartUser"]) async def hexStartUser(self, ctx, user): await ctx.defer() await self.bot.games.gameLoops.runHex(ctx, "start "+user.display_name, "#"+str(ctx.author.id)) # Start a game of Hex against Gwendolyn @cog_ext.cog_subcommand(**params["hexStartGwendolyn"]) async def hexStartGwendolyn(self, ctx, difficulty = 2): await ctx.defer() await self.bot.games.gameLoops.runHex(ctx, "start "+str(difficulty), "#"+str(ctx.author.id)) # Undo your last hex move @cog_ext.cog_subcommand(**params["hexUndo"]) async def hexUndo(self, ctx): await self.bot.games.gameLoops.runHex(ctx, "undo", "#"+str(ctx.author.id)) # Perform a hex swap @cog_ext.cog_subcommand(**params["hexSwap"]) async def hexSwap(self, ctx): await self.bot.games.gameLoops.runHex(ctx, "swap", "#"+str(ctx.author.id)) # Surrender the hex game @cog_ext.cog_subcommand(**params["hexSurrender"]) async def hexSurrender(self, ctx): await self.bot.games.gameLoops.runHex(ctx, "surrender", "#"+str(ctx.author.id)) # Place a piece in the hex game @cog_ext.cog_subcommand(**params["hexPlace"]) async def hexPlace(self, ctx, coordinates): await self.bot.games.gameLoops.runHex(ctx, "place "+coordinates, "#"+str(ctx.author.id)) def setup(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))