Browse Source

Move points calculation outside loop.

v2
Ceda EI 3 years ago
parent
commit
021467817b
  1. 12
      server.py

12
server.py

@ -238,13 +238,15 @@ def update_quest(db):
state = bool(request.values["state"])
if state is True:
quest.state = 1
points = 55 + 10*quest.imp + 15*quest.diff
player.add_points(points)
else:
return jsonify(errors._400_bv), 400
except (ValueError):
return jsonify(errors._400_bv), 400
if quest.state == 1:
points = 55 + 10*quest.imp + 15*quest.diff
player.add_points(points)
quest.update_db()
return jsonify(dictify_quest(quest))
@ -295,13 +297,15 @@ def update_side_quest(db):
state = bool(request.values["state"])
if state is True:
quest.state = 1
points = 10*quest.imp + 15*quest.diff
player.add_points(points)
else:
return jsonify(errors._400_bv), 400
except (ValueError):
return jsonify(errors._400_bv), 400
if quest.state == 1:
points = 10*quest.imp + 15*quest.diff
player.add_points(points)
quest.update_db()
return jsonify(dictify_quest(quest))

Loading…
Cancel
Save