🤖 Better AI

This commit is contained in:
NikolajDanger
2020-08-01 23:28:51 +02:00
parent f7f288f81d
commit 15f097b32e
2 changed files with 174 additions and 38 deletions

View File

@ -32,7 +32,7 @@ async def fiar(channel,command,user):
oldImage = await channel.send(file = discord.File("resources/games/4InARowBoards/board"+str(channel)+".png"))
if gameDone == False:
if gwendoTurn:
await asyncio.sleep(2)
await asyncio.sleep(1)
response, showImage, deleteImage, gameDone, gwendoTurn = fourInARowAI(str(channel))
await channel.send(response)
logThis(response,str(channel))
@ -67,11 +67,22 @@ async def fiar(channel,command,user):
await oldImage.add_reaction("7")
except:
logThis("Image deleted before I could react to all of them")
# else:
# with open("resources/games/oldImages/fourInARow"+str(channel), "w") as f:
# f.write(str(oldImage.id))
if gameDone:
with open("resources/games/games.json", "r") as f:
data = json.load(f)
try:
with open("resources/games/oldImages/fourInARow"+str(channel), "r") as f:
oldImage = await channel.fetch_message(int(f.read()))
await oldImage.delete()
except:
logThis("The old image was already deleted")
winner = data["4 in a row games"][str(channel)]["winner"]
if winner != 0:
with open("resources/games/games.json","w") as f: