From 8194fd0f8b5f7105f46047aa954208f18a102a6f Mon Sep 17 00:00:00 2001 From: Innovation Date: Wed, 3 Apr 2024 06:29:56 +0100 Subject: [PATCH] Some debugging --- src/nightserver.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/nightserver.py b/src/nightserver.py index 0ab1eed..af2a7ac 100644 --- a/src/nightserver.py +++ b/src/nightserver.py @@ -131,6 +131,7 @@ def setFitness(): # Cyberware management cyberware = [] newCyberwareTemplate = { "uuid": None, "name": None, "hotpluggable": False, "lastMalfunction": None, "canSet": [], "battery": None, "messages": [] } +newMessageTemplate = { "title": None, "message": None, "progress": None } # Messages: { Title, Message, Progress } # Title, Message, and Progress are all technically optional. It's up to the frontend to make heads or tails of what's happening. # Typically, if Progress == None: No progress bar, will show up in the Top Message section on NightUI @@ -203,8 +204,6 @@ def getCyberware(): for c in cyberware: returnArr.append({ 'name': c['name'], 'hotpluggable': c['hotpluggable'], 'lastMalfunction': c['lastMalfunction'], 'battery': c['battery'] }) - resetMalfunctions() - return jsonify(returnArr), 200 @app.route('/api/cyberware/malfunctions') @@ -215,6 +214,8 @@ def getCyberwareMalfunctions(): if c['lastMalfunction'] != None: returnArr.append({ 'name': c['name'], 'lastMalfunction': c['lastMalfunction'] }) + resetMalfunctions() + return jsonify(returnArr), 200 @app.route('/api/cyberware/messages') @@ -224,6 +225,7 @@ def getCyberwareMessages(): for c in cyberware: if c['messages'] != None: returnArr.append({ 'name': c['name'], 'messages': c['messages'] }) + resetMessages() return jsonify(returnArr), 200 @app.route('/api/cyberware/get', methods=['POST']) @@ -277,8 +279,7 @@ def setCyberwareBattery(): @app.route('/api/cyberware/reset_malfunction') def resetAllCyberwareMalfunction(): - for c in cyberware: - c['lastMalfunction'] = None + resetMalfunctions() # Arguments { uuid: STRING } @app.route('/api/cyberware/reset_malfunction', methods=['POST']) @@ -297,6 +298,22 @@ def resetCyberwareMalfunction(): return 'Incorrect usage.\nUsage: { uuid: STRING }\n', 400 return 'UUID Invalid\n', 400 +def resetMalfunctions(): + for c in cyberware: + c['lastMalfunction'] = None + +def resetMessages(): + for c in cyberware: + newMessageList = [] + for m in c['messages']: + if(m['progress'] == None): # Unless we're FULLY resetting messages, we want to keep messages with a progress bar attached. + newMessageList.append(m) + c['messages'] = newMessageList + +def resetMessagesFull(): + for c in cyberware: + c['messages'] = None + def getCyberwareHelper(uuid): i = 0 for c in cyberware: