❗ Surrender!!
This commit is contained in:
@ -61,7 +61,7 @@ async def runHex(channel,command,user):
|
|||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
winner = data[str(channel.id)]["winner"]
|
winner = data[str(channel.id)]["winner"]
|
||||||
if winner != 0:
|
if winner != 0:
|
||||||
addMoney(data[str(channel.id)]["players"][winner-1].lower(),20)
|
addMoney(data[str(channel.id)]["players"][winner-1].lower(),50)
|
||||||
|
|
||||||
#deleteGame("hex games",str(channel.id))
|
#deleteGame("hex games",str(channel.id))
|
||||||
with open("resources/games/hexGames.json", "r") as f:
|
with open("resources/games/hexGames.json", "r") as f:
|
||||||
|
@ -53,8 +53,25 @@ def parseHex(command, channel, user):
|
|||||||
return placeHex(channel,commands[1], user)
|
return placeHex(channel,commands[1], user)
|
||||||
except:
|
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
|
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:
|
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 "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, \"!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
|
# Starts the game
|
||||||
@ -248,6 +265,14 @@ def evaluateBoard(board):
|
|||||||
|
|
||||||
return score, isWon
|
return score, isWon
|
||||||
|
|
||||||
|
def undoHex(channel, user):
|
||||||
|
|
||||||
|
message = "yup"
|
||||||
|
gwendoturn = False
|
||||||
|
return message, True, True, False, gwendoturn
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Plays as the AI
|
# Plays as the AI
|
||||||
def hexAI(channel):
|
def hexAI(channel):
|
||||||
|
Reference in New Issue
Block a user