🧹 Smaal clean-up with connect four
Removing the unused function in gameLoops and changing the class name to start with a capital letter
This commit is contained in:
@ -19,7 +19,7 @@ AISCORES = {
|
|||||||
ROWCOUNT = 6
|
ROWCOUNT = 6
|
||||||
COLUMNCOUNT = 7
|
COLUMNCOUNT = 7
|
||||||
|
|
||||||
class connectFour():
|
class ConnectFour():
|
||||||
def __init__(self,bot):
|
def __init__(self,bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.draw = drawConnectFour(bot)
|
self.draw = drawConnectFour(bot)
|
||||||
|
@ -21,75 +21,6 @@ class GameLoops():
|
|||||||
|
|
||||||
return oldMessage
|
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
|
# Runs Hex
|
||||||
async def runHex(self,ctx,command,user):
|
async def runHex(self,ctx,command,user):
|
||||||
channelId = ctx.channel_id
|
channelId = ctx.channel_id
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from .invest import Invest
|
from .invest import Invest
|
||||||
from .trivia import Trivia
|
from .trivia import Trivia
|
||||||
from .blackjack import Blackjack
|
from .blackjack import Blackjack
|
||||||
from .connectFour import connectFour
|
from .connectFour import ConnectFour
|
||||||
from .gameLoops import GameLoops
|
from .gameLoops import GameLoops
|
||||||
from .hangman import Hangman
|
from .hangman import Hangman
|
||||||
from .hex import HexGame
|
from .hex import HexGame
|
||||||
@ -13,7 +13,7 @@ class Games():
|
|||||||
self.invest = Invest(bot)
|
self.invest = Invest(bot)
|
||||||
self.trivia = Trivia(bot)
|
self.trivia = Trivia(bot)
|
||||||
self.blackjack = Blackjack(bot)
|
self.blackjack = Blackjack(bot)
|
||||||
self.connectFour = connectFour(bot)
|
self.connectFour = ConnectFour(bot)
|
||||||
self.gameLoops = GameLoops(bot)
|
self.gameLoops = GameLoops(bot)
|
||||||
self.hangman = Hangman(bot)
|
self.hangman = Hangman(bot)
|
||||||
self.hex = HexGame(bot)
|
self.hex = HexGame(bot)
|
||||||
|
Reference in New Issue
Block a user