I'm working on my final project for the Web Track and whenever someone wins the game (tictactoe) I get an internal server error and the error message:
RuntimeError: unused values (wp)
Now what this tells me is that my check_win_conditions() function is working properly and that the application correctly redirects to the route "/win". If there is a draw I run into no issues. This is the code in question:
for draw:
if session['winner'] == 'D': dp = 20 db.execute("UPDATE rankings SET points = points + :dp WHERE userID = :u1 OR userID = :u2", dp=dp, u1=u1['id'], u2=u2['id']) return render_template("gameover.html", draw=session['winner'])
for win of 'X':
elif session['winner'] == 'X':
wp = 50
lp = -5
one = 1
db.execute("UPDATE rankings SET TTTWins = TTTWins + :one, TotalWins = TotalWins + :one, points = points + wp WHERE userID = :u1",
one=one, wp=wp, u1=u1['id'])
db.execute("UPDATE rankings SET TTTLosses = TTTLosses + :one, TotalLosses = TotalLosses + :one, points = points + lp WHERE
userID = :u2",
one=one, lp=lp, u2=u2['id'])
return render_template("gameover.html", gInfo = gInfo, tInfo = tInfo, winner=gInfo['PlayerOne'])
for win of 'O':
else:
wp = 50
lp = -5
one = 1
db.execute("UPDATE rankings SET TTTWins = TTTWins + :one, TotalWins = TotalWins + :one, points = points + wp WHERE userID = :u2",
one=one, wp=wp, u2=u2['id'])
db.execute("UPDATE rankings SET TTTLosses = TTTLosses + :one, TotalLosses = TotalLosses + :one, points = points + lp WHERE userID = :u1",
one=one, lp=lp, u1=u1['id'])
return render_template("gameover.html", gInfo = gInfo, tInfo = tInfo, winner=gInfo['PlayerTwo'])
If I declare the variables once alltogether before the if condition I get the same error.
If someone could take a look and possibly point out how to fix it I'd be very grateful!