✅ hexStart now works. Time for hexDraw
This commit is contained in:
@ -55,14 +55,12 @@ def parseHex(command, channel, user):
|
||||
def hexStart(channel, user, opponent):
|
||||
with open("resources/games/hexGames.json", "r") as f:
|
||||
data = json.load(f)
|
||||
logThis("Loaded the existing data")
|
||||
|
||||
if channel not in data:
|
||||
|
||||
if opponent in ["1","2","3","4","5"]:
|
||||
difficulty = int(opponent)
|
||||
diffText = " with difficulty "+opponent
|
||||
opponent = "Gwendolyn"
|
||||
logThis("Playing against Gwendolyn. ")
|
||||
elif opponent.lower() == "gwendolyn":
|
||||
difficulty = 2
|
||||
diffText = " with difficulty 2"
|
||||
@ -82,11 +80,10 @@ def hexStart(channel, user, opponent):
|
||||
difficulty = 5
|
||||
diffText = ""
|
||||
|
||||
logThis("Opponent found. Creating data. ")
|
||||
# board is 11x11
|
||||
board = [ [ 0 for i in range(boardWidth) ] for j in range(boardWidth) ]
|
||||
players = [user,opponent]
|
||||
random.shuffle(players)
|
||||
random.shuffle(players) # random starting player
|
||||
winningPieces = [[""],[""],[""]] # etc.
|
||||
|
||||
data[channel] = {"board": board,"winner":0,
|
||||
@ -94,7 +91,7 @@ def hexStart(channel, user, opponent):
|
||||
|
||||
with open("resources/games/hexGames.json", "w") as f:
|
||||
json.dump(data,f,indent=4)
|
||||
logThis("Data made. Ending the startup.")
|
||||
|
||||
# draw the board
|
||||
#fourInARowDraw.drawImage(channel)
|
||||
# hexDraw() # something something
|
||||
@ -105,7 +102,7 @@ def hexStart(channel, user, opponent):
|
||||
# in case she has the first move
|
||||
gwendoTurn = True
|
||||
|
||||
return "Started game against "+getName(opponent)+diffText+". It's "+getName(players[0])+"'s turn", True, False, False, gwendoTurn
|
||||
return "Started game against "+getName(opponent)+ diffText+". It's "+getName(players[0])+"'s turn", True, False, False, gwendoTurn
|
||||
else:
|
||||
return "There's already a hex game going on in this channel", False, False, False, False
|
||||
|
||||
|
@ -1,2 +1,25 @@
|
||||
# haha good joke as if I can do this manually
|
||||
# just find a picture online
|
||||
import json
|
||||
import math
|
||||
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
from funcs import logThis, getName
|
||||
|
||||
def hexDraw(channel):
|
||||
logThis("Drawing Hex board")
|
||||
|
||||
with open("resources/games/hexGames.json", "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
board = data[channel]["board"]
|
||||
players = data[channel]["players"]
|
||||
if players[0] == "Gwendolyn":
|
||||
player1 = "Gwendolyn"
|
||||
else:
|
||||
player1 = getName(players[0])
|
||||
if players[1] == "Gwendolyn":
|
||||
player2 = "Gwendolyn"
|
||||
else:
|
||||
player2 = getName(players[1])
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user