✅ 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
|
||||
|
||||
|
Reference in New Issue
Block a user