🎲 monopoly framework

This commit is contained in:
Nikolaj Danger
2020-08-05 18:15:45 +02:00
parent f9c9bcef1b
commit eaabb6d43f
12 changed files with 285 additions and 20 deletions

View File

@ -2,7 +2,7 @@ import asyncio
import discord
import json
from funcs import logThis, addMoney, deleteGame, parseFourInARow, fourInARowAI, blackjackContinue, blackjackFinish, parseHex, hexAI
from funcs import logThis, addMoney, deleteGame, parseFourInARow, fourInARowAI, blackjackContinue, blackjackFinish, parseHex, hexAI, parseMonopoly, monopolyContinue
# Deletes a message
async def deleteMessage(imageLocation,channel):
@ -119,9 +119,6 @@ async def fiar(channel,command,user):
await oldImage.add_reaction(reaction)
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:
@ -192,3 +189,45 @@ async def blackjackLoop(channel,gameRound,gameID):
logThis("Ending loop on round "+str(gameRound),str(channel))
else:
logThis("Ending loop on round "+str(gameRound),str(channel))
async def runMonopoly(channel, command, user):
try:
response, showImage, deleteImage, gameStarted, gameContinue = parseMonopoly(command,str(channel),user)
except:
logThis("Error parsing command (error code 1610)")
if response != "":
await channel.send(response)
logThis(response,str(channel))
if showImage:
if deleteImage:
try:
oldImage = await deleteMessage("monopoly"+str(channel),channel)
except:
logThis("Error deleting message (error code 1601)")
oldImage = await channel.send(file = discord.File("resources/games/monopolyBoards/monopolyBoard"+str(channel)+".png"))
with open("resources/games/oldImages/monopoly"+str(channel), "w") as f:
f.write(str(oldImage.id))
if gameContinue:
if gameStarted:
await asyncio.sleep(60)
else:
await asyncio.sleep(5)
response, showImage, deleteImage, gameDone = monopolyContinue(str(channel))
em = discord.Embed(description=response,colour = 0x59f442)
await channel.send(embed=em)
if showImage:
if deleteImage:
try:
oldImage = await deleteMessage("monopoly"+str(channel),channel)
except:
logThis("Error deleting message (error code 1601)")
oldImage = await channel.send(file = discord.File("resources/games/monopolyBoards/monopolyBoard"+str(channel)+".png"))
with open("resources/games/oldImages/monopoly"+str(channel), "w") as f:
f.write(str(oldImage.id))
if gameDone == False:
try:
await oldImage.add_reaction("🎲")
except:
logThis("Image deleted before I could react to all of them")