🐛 Small difficulty setting fix

This commit is contained in:
jona605a
2020-08-04 11:44:29 +02:00
parent 3ca56b80ed
commit e1b767be68
2 changed files with 12 additions and 7 deletions

View File

@ -32,11 +32,16 @@ def fourInARowStart(channel, user, opponent):
if opponent in ["1","2","3","4","5"]: if opponent in ["1","2","3","4","5"]:
difficulty = int(opponent) difficulty = int(opponent)
opponent = "Gwendolyn" opponent = "Gwendolyn"
elif opponent in ["0","6","7","8","9","10","69","100","420"]: elif opponent.lower() == "gwendolyn":
return "That difficulty doesn't exist", False, False, False, False difficulty = 3
opponent = "Gwendolyn"
else: else:
# Opponent is another player try:
difficulty = "5" int(opponent)
return "That difficulty doesn't exist", False, False, False, False
except:
# Opponent is another player
difficulty = 5
board = [ [ 0 for i in range(columnCount) ] for j in range(rowCount) ] board = [ [ 0 for i in range(columnCount) ] for j in range(rowCount) ]
players = [user,opponent] players = [user,opponent]
@ -137,7 +142,7 @@ def parseFourInARow(command, channel, user):
return "I didn't get that. Use \"!fourinarow start [opponent]\" to start a game. To play against the computer, use difficulty 1 through 5 as the [opponent].", False, False, False, False return "I didn't get that. Use \"!fourinarow start [opponent]\" to start a game. To play against the computer, use difficulty 1 through 5 as the [opponent].", False, False, False, False
elif commands[0] == "start": elif commands[0] == "start":
# Starting a game # Starting a game
if len(commands) == 1: # if the commands is "!hex start", the opponent is Gwendolyn if len(commands) == 1: # if the commands is "!fourinarow start", the opponent is Gwendolyn
commands.append("3") commands.append("3")
return fourInARowStart(channel,user,commands[1]) # commands[1] is the opponent return fourInARowStart(channel,user,commands[1]) # commands[1] is the opponent

View File

@ -17,7 +17,7 @@ def parseHex(command, channel, user):
elif commands[0] == "start": elif commands[0] == "start":
# Starting a game # Starting a game
if len(commands) == 1: # if the commands is "!hex start", the opponent is Gwendolyn if len(commands) == 1: # if the commands is "!hex start", the opponent is Gwendolyn
commands.append("Gwendolyn") commands.append("2")
return hexStart(channel,user,commands[1]) # commands[1] is the opponent return hexStart(channel,user,commands[1]) # commands[1] is the opponent
# Stopping the game # Stopping the game
@ -46,7 +46,7 @@ def hexStart(channel, user, opponent):
data = json.load(f) data = json.load(f)
if user.lower() != opponent.lower(): if user.lower() != opponent.lower():
if channel not in data["4 in a row games"]: if channel not in data["hex games"]:
if opponent in ["1","2","3","4","5"]: if opponent in ["1","2","3","4","5"]:
difficulty = int(opponent) difficulty = int(opponent)