Move points calculation outside loop.

This commit is contained in:
Ceda EI 2019-03-19 16:53:04 +05:30
parent 99c1795b93
commit 021467817b
1 changed files with 8 additions and 4 deletions

View File

@ -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))