Four in a row win

This commit is contained in:
NikolajDanger
2020-07-30 16:32:18 +02:00
parent 6822f7bc4f
commit ed7efe7aa4
3 changed files with 154 additions and 14 deletions

View File

@ -576,7 +576,7 @@ async def parseCommands(message,content):
# Runs a game of four in a row
elif content.startswith("fourinarow"):
response, showImage, deleteImage = parseFourInARow(content.replace("fourinarow",""),str(message.channel),message.author.display_name)
response, showImage, deleteImage, gameDone = parseFourInARow(content.replace("fourinarow",""),str(message.channel),message.author.display_name)
await message.channel.send(response)
logThis(response,str(message.channel))
if showImage:
@ -590,6 +590,17 @@ async def parseCommands(message,content):
oldImage = await message.channel.send(file = discord.File("resources/games/4InARowBoards/board"+str(message.channel)+".png"))
with open("resources/games/oldImages/fourInARow"+str(message.channel), "w") as f:
f.write(str(oldImage.id))
if gameDone:
with open("resources/games/games.json", "r") as f:
data = json.load(f)
del data["4 in a row games"][str(message.channel)]
with open("resources/games/games.json","w") as f:
json.dump(data,f,indent=4)
# Not a command
else: