Move points calculation outside loop.
This commit is contained in:
parent
99c1795b93
commit
021467817b
12
server.py
12
server.py
|
@ -238,13 +238,15 @@ def update_quest(db):
|
||||||
state = bool(request.values["state"])
|
state = bool(request.values["state"])
|
||||||
if state is True:
|
if state is True:
|
||||||
quest.state = 1
|
quest.state = 1
|
||||||
points = 55 + 10*quest.imp + 15*quest.diff
|
|
||||||
player.add_points(points)
|
|
||||||
else:
|
else:
|
||||||
return jsonify(errors._400_bv), 400
|
return jsonify(errors._400_bv), 400
|
||||||
except (ValueError):
|
except (ValueError):
|
||||||
return jsonify(errors._400_bv), 400
|
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()
|
quest.update_db()
|
||||||
return jsonify(dictify_quest(quest))
|
return jsonify(dictify_quest(quest))
|
||||||
|
|
||||||
|
@ -295,13 +297,15 @@ def update_side_quest(db):
|
||||||
state = bool(request.values["state"])
|
state = bool(request.values["state"])
|
||||||
if state is True:
|
if state is True:
|
||||||
quest.state = 1
|
quest.state = 1
|
||||||
points = 10*quest.imp + 15*quest.diff
|
|
||||||
player.add_points(points)
|
|
||||||
else:
|
else:
|
||||||
return jsonify(errors._400_bv), 400
|
return jsonify(errors._400_bv), 400
|
||||||
except (ValueError):
|
except (ValueError):
|
||||||
return jsonify(errors._400_bv), 400
|
return jsonify(errors._400_bv), 400
|
||||||
|
|
||||||
|
if quest.state == 1:
|
||||||
|
points = 10*quest.imp + 15*quest.diff
|
||||||
|
player.add_points(points)
|
||||||
|
|
||||||
quest.update_db()
|
quest.update_db()
|
||||||
return jsonify(dictify_quest(quest))
|
return jsonify(dictify_quest(quest))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue