Surrender!!

This commit is contained in:
jona605a
2020-08-08 13:47:38 +02:00
parent 6b4a2e5232
commit 08851182a7
2 changed files with 27 additions and 2 deletions

View File

@ -53,8 +53,25 @@ def parseHex(command, channel, user):
return placeHex(channel,commands[1], user)
except:
return "I didn't get that. To place a piece use \"!hex place [position]\". A valid position is e.g. \"E2\".", False, False, False, False
# Undo
elif commands[0] == "undo":
return undoHex(channel, user)
# Surrender
elif commands[0] == "surrender":
with open("resources/games/hexGames.json", "r") as f:
data = json.load(f)
players = data[channel]["players"]
if user in players:
opponent = (players.index(user) + 1) % 2
data[channel]["winner"] = opponent
return "{} surrendered. Ending game.".format(getName(user)), False, False, True, False
else:
return "You can't surrender when you're not a player.", False, False, False, False
else:
return "I didn't get that. Use \"!hex start [opponent]\" to start a game or \"!hex stop\" to stop a current game.", False, False, False, False
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
# Starts the game
@ -248,6 +265,14 @@ def evaluateBoard(board):
return score, isWon
def undoHex(channel, user):
message = "yup"
gwendoturn = False
return message, True, True, False, gwendoturn
# Plays as the AI
def hexAI(channel):