Framework for Hangman

This commit is contained in:
NikolajDanger
2020-08-07 17:38:47 +02:00
parent e0e74f5bc0
commit 5839cd5a8f
12 changed files with 270 additions and 7 deletions

View File

@ -8,6 +8,7 @@ from .fourInARow import parseFourInARow, fourInARowAI
from .blackjack import blackjackContinue, blackjackFinish
from .hex import parseHex, hexAI
from .monopoly import parseMonopoly, monopolyContinue
from .hangman import parseHangman
# Deletes a message
async def deleteMessage(imageLocation,channel):
@ -233,4 +234,17 @@ async def runMonopoly(channel, command, user):
await oldImage.add_reaction("🎲")
except:
logThis("Image deleted before I could react to all of them")
async def runHangman(channel,user,command = "start"):
try:
response, showImage, deleteImage, remainingLetters = parseHangman(str(channel.id),user,command)
except:
logThis("Error parsing command (error code 1701)")
await channel.send(response)
logThis(response,str(channel.id))
if showImage:
if deleteImage:
oldImage = await deleteMessage("hangman"+str(channel.id),channel)
oldImage = await channel.send(file = discord.File("resources/games/hangmanBoards/hangmanBoard"+str(channel.id)+".png"))
with open("resources/games/oldImages/hangman"+str(channel.id), "w") as f:
f.write(str(oldImage.id))