!hex swap

This commit is contained in:
jona605a
2020-08-11 21:27:46 +02:00
parent 1d9831d773
commit 71467bbe16
3 changed files with 52 additions and 2 deletions

View File

@ -56,10 +56,22 @@ def parseHex(command, channel, user):
if user in players:
opponent = (players.index(user) + 1) % 2
data[channel]["winner"] = opponent + 1
return "{} surrendered. That means {} won! ".format(getName(user),getName(players[opponent])), False, False, True, False
return "{} surrendered. That means {} won! Adding 30 Gwendobucks to their account.".format(getName(user),getName(players[opponent])), False, False, True, False
else:
return "You can't surrender when you're not a player.", False, False, False, False
# Swap
elif commands[0] == "swap":
with open("resources/games/hexGames.json", "r") as f:
data = json.load(f)
if len(data[channel]["gameHistory"]) == 1: # Only after the first move
data[channel]["players"] = data[channel]["players"][::-1] # Swaps their player-number
# Swaps the color of the hexes on the board drawing:
hexDraw.drawSwap(channel)
return "The color of both players were swapped.", True, True, False, False
else:
return "You can only swap as the second player after the very first move.", False, False, False, False
else:
return "I didn't get that. Use \"!hex start [opponent]\" to start a game, \"!hex place [position]\" to place a piece, \"!hex undo\" to undo your last move or \"!hex stop\" to stop a current game.", False, False, False, False
@ -90,7 +102,7 @@ def hexStart(channel, user, opponent):
return "I can't find that user", False, False, False, False
else:
# Opponent is another player
difficulty = 5
difficulty = 3
diffText = ""
# board is 11x11