diff --git a/funcs/games/connectFour.py b/funcs/games/connectFour.py index 365ebf2..7c5a11e 100644 --- a/funcs/games/connectFour.py +++ b/funcs/games/connectFour.py @@ -19,7 +19,7 @@ AISCORES = { ROWCOUNT = 6 COLUMNCOUNT = 7 -class connectFour(): +class ConnectFour(): def __init__(self,bot): self.bot = bot self.draw = drawConnectFour(bot) diff --git a/funcs/games/gameLoops.py b/funcs/games/gameLoops.py index da6fec8..c5215d4 100644 --- a/funcs/games/gameLoops.py +++ b/funcs/games/gameLoops.py @@ -21,75 +21,6 @@ class GameLoops(): return oldMessage - # Runs connect four - async def connectFour(self, ctx, command, user = None, channelId = None): - if user is None: - user = "#"+str(ctx.author.id) - - if channelId is None: - channelId = str(ctx.channel_id) - - response, showImage, deleteImage, gameDone, gwendoTurn = self.bot.games.connectFour.parseconnectFour(command,channelId, user) - - if hasattr(ctx, "send"): - await ctx.send(response) - else: - await ctx.channel.send(response) - self.bot.log(response, channelId) - if showImage: - if deleteImage: - oldImage = await self.deleteMessage("connectFour"+channelId,ctx.channel) - oldImage = await ctx.channel.send(file = discord.File("resources/games/connect4Boards/board"+channelId+".png")) - if gameDone == False: - if gwendoTurn: - response, showImage, deleteImage, gameDone, gwendoTurn = await self.bot.games.connectFour.connectFourAI(channelId) - await ctx.channel.send(response) - self.bot.log(response,channelId) - if showImage: - if deleteImage: - await oldImage.delete() - oldImage = await ctx.channel.send(file = discord.File("resources/games/connect4Boards/board"+channelId+".png")) - if gameDone == False: - with open("resources/games/oldImages/connectFour"+channelId, "w") as f: - f.write(str(oldImage.id)) - try: - reactions = ["1️⃣","2️⃣","3️⃣","4️⃣","5️⃣","6️⃣","7️⃣"] - for reaction in reactions: - await oldImage.add_reaction(reaction) - - except: - self.bot.log("Image deleted before I could react to all of them") - - else: - with open("resources/games/oldImages/connectFour"+channelId, "w") as f: - f.write(str(oldImage.id)) - try: - reactions = ["1️⃣","2️⃣","3️⃣","4️⃣","5️⃣","6️⃣","7️⃣"] - for reaction in reactions: - await oldImage.add_reaction(reaction) - except: - self.bot.log("Image deleted before I could react to all of them") - - if gameDone: - game = self.bot.database["connect 4 games"].find_one({"_id":channelId}) - - try: - with open("resources/games/oldImages/connectFour"+channelId, "r") as f: - oldImage = await channel.fetch_message(int(f.read())) - - await oldImage.delete() - except: - self.bot.log("The old image was already deleted") - - winner = game["winner"] - difficulty = int(game["difficulty"]) - reward = difficulty**2 + 5 - if winner != 0: - if game["players"][winner-1].lower() != "gwendolyn": - self.bot.money.addMoney(game["players"][winner-1].lower(),reward) - - self.bot.databaseFuncs.deleteGame("connect 4 games",channelId) - # Runs Hex async def runHex(self,ctx,command,user): channelId = ctx.channel_id diff --git a/funcs/games/gamesContainer.py b/funcs/games/gamesContainer.py index 1afee45..099acff 100644 --- a/funcs/games/gamesContainer.py +++ b/funcs/games/gamesContainer.py @@ -1,7 +1,7 @@ from .invest import Invest from .trivia import Trivia from .blackjack import Blackjack -from .connectFour import connectFour +from .connectFour import ConnectFour from .gameLoops import GameLoops from .hangman import Hangman from .hex import HexGame @@ -13,7 +13,7 @@ class Games(): self.invest = Invest(bot) self.trivia = Trivia(bot) self.blackjack = Blackjack(bot) - self.connectFour = connectFour(bot) + self.connectFour = ConnectFour(bot) self.gameLoops = GameLoops(bot) self.hangman = Hangman(bot) self.hex = HexGame(bot)