📝 Gameloops updated to Hex functions and names
This commit is contained in:
@ -36,7 +36,7 @@ def fourInARowStart(channel, user, opponent):
|
||||
return "That difficulty doesn't exist", False, False, False, False
|
||||
else:
|
||||
# Opponent is another player
|
||||
difficulty = "NA"
|
||||
difficulty = "5"
|
||||
|
||||
board = [ [ 0 for i in range(columnCount) ] for j in range(rowCount) ]
|
||||
players = [user,opponent]
|
||||
|
46
gameLoops.py
46
gameLoops.py
@ -33,61 +33,41 @@ async def runhex(channel,command,user):
|
||||
except:
|
||||
logThis("Error deleting old image (error code 1501)")
|
||||
oldImage = await channel.send(file = discord.File("resources/games/hexBoards/board"+str(channel)+".png"))
|
||||
if gameDone == False:
|
||||
if not gameDone:
|
||||
if gwendoTurn:
|
||||
try:
|
||||
response, showImage, deleteImage, gameDone, gwendoTurn = hexAI(str(channel))
|
||||
except:
|
||||
logThis("AI error (error code 1420)")
|
||||
logThis("AI error (error code 1520)")
|
||||
await channel.send(response)
|
||||
logThis(response,str(channel))
|
||||
if showImage:
|
||||
if deleteImage:
|
||||
await oldImage.delete()
|
||||
oldImage = await channel.send(file = discord.File("resources/games/4InARowBoards/board"+str(channel)+".png"))
|
||||
if gameDone == False:
|
||||
with open("resources/games/oldImages/fourInARow"+str(channel), "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:
|
||||
logThis("Image deleted before I could react to all of them")
|
||||
oldImage = await channel.send(file = discord.File("resources/games/hexBoards/board"+str(channel)+".png"))
|
||||
|
||||
else:
|
||||
with open("resources/games/oldImages/fourInARow"+str(channel), "w") as f:
|
||||
with open("resources/games/oldImages/hex"+str(channel), "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:
|
||||
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:
|
||||
with open("resources/games/oldImages/hex"+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"]
|
||||
winner = data["hex games"][str(channel)]["winner"]
|
||||
if winner != 0:
|
||||
addMoney(data["4 in a row games"][str(channel)]["players"][winner-1].lower(),20)
|
||||
addMoney(data["hex games"][str(channel)]["players"][winner-1].lower(),20)
|
||||
with open("resources/games/games.json", "r") as f:
|
||||
data = json.load(f)
|
||||
data = json.load(f) #why is this here?
|
||||
|
||||
deleteGame("4 in a row games",str(channel))
|
||||
deleteGame("hex games",str(channel))
|
||||
|
||||
|
||||
|
||||
@ -156,10 +136,12 @@ async def fiar(channel,command,user):
|
||||
logThis("The old image was already deleted")
|
||||
|
||||
winner = data["4 in a row games"][str(channel)]["winner"]
|
||||
reward = int(data["4 in a row games"][str(channel)]["difficulty"])
|
||||
reward = reward^2 + 5
|
||||
if winner != 0:
|
||||
addMoney(data["4 in a row games"][str(channel)]["players"][winner-1].lower(),20)
|
||||
addMoney(data["4 in a row games"][str(channel)]["players"][winner-1].lower(),reward)
|
||||
with open("resources/games/games.json", "r") as f:
|
||||
data = json.load(f)
|
||||
data = json.load(f) #why is this here?
|
||||
|
||||
deleteGame("4 in a row games",str(channel))
|
||||
|
||||
|
Reference in New Issue
Block a user