refactor error message for npc reaction

This commit is contained in:
Thomas Rubini 2023-03-19 12:07:35 +01:00
parent 5745c30147
commit 7a2a23729d
No known key found for this signature in database
GPG Key ID: C7D287C8C1CAC373
2 changed files with 3 additions and 4 deletions

View File

@ -134,7 +134,7 @@ class Game:
"""
print(self.reaction_table)
if npc_id not in self.reaction_table:
return 0
return None
trait_id = self.reaction_table[npc_id]
reaction = db.session.execute(

View File

@ -147,9 +147,8 @@ def get_npc_reaction():
npc_id = flask.request.values.get("npcid")
image = game.get_npc_reaction(npc_id)
errors = ["npc not in game","error reading file"]
if image in [0,1]:
return {"error": 1, "msg": errors[image]}
if image == None:
return {"error": 1, "msg": "npc not in game"}
response = flask.make_response(image)
response.headers.set('Content-Type', 'image/png')