Some debugging

This commit is contained in:
Innovation 2024-04-03 06:29:56 +01:00
parent 6feddf6b36
commit 8194fd0f8b

View file

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