toconnell / kdm-manager

An interactive campaign manager for the game "Monster", by Kingdom Death. Development blog and release notes at https://blog.kdm-manager.com This project has no affiliation with Kingdom Death and is a totally independent, fan-maintained project.
http://kdm-manager.com
Other
26 stars 11 forks source link

Campaign Summary: un-handled outcome when returning departing survivors #498

Closed toconnell closed 6 years ago

toconnell commented 6 years ago

User OID: 5aa973618740d905cdc7e7ea Method: POST URL: http://api.thewatcher.io/settlement/return_survivors/5aaa5e8f8740d905cb812103 JSON: {u'aftermath': u'defeat', u'serialize_on_response': True}

Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1639, in full_dispatch_request
 rv = self.dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1625, in dispatch_request
 return self.view_functions[rule.endpoint](**req.view_args)
File "/home/toconnell/kdm-manager/v2/api/utils.py", line 516, in wrapped_function
 resp = make_response(f(*args, **kwargs))
File "/home/toconnell/kdm-manager/v2/api/api.py", line 274, in collection_action
 return asset_object.request_response(action)
File "/home/toconnell/kdm-manager/v2/api/models/settlements.py", line 3995, in request_response
 self.return_survivors()
File "/home/toconnell/kdm-manager/v2/api/models/settlements.py", line 1387, in return_survivors
 self.log_event(msg, event_type="survivors_return_%s" % aftermath)
UnboundLocalError: local variable 'msg' referenced before assignment
toconnell commented 6 years ago

This is...still an issue, even after the monkey patch:

User OID: 56d2140a421aa90135fcebbf Method: POST URL: http://api.thewatcher.io/settlement/return_survivors/5ab808d68740d97083581189 JSON: {u'aftermath': u'defeat', u'serialize_on_response': True}


Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1639, in full_dispatch_request
 rv = self.dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1625, in dispatch_request
 return self.view_functions[rule.endpoint](**req.view_args)
File "/home/toconnell/kdm-manager/v2/api/utils.py", line 516, in wrapped_function
 resp = make_response(f(*args, **kwargs))
File "/home/toconnell/kdm-manager/v2/api/api.py", line 274, in collection_action
 return asset_object.request_response(action)
File "/home/toconnell/kdm-manager/v2/api/models/settlements.py", line 3996, in request_response
 self.return_survivors()
File "/home/toconnell/kdm-manager/v2/api/models/settlements.py", line 1388, in return_survivors
 self.log_event(msg, event_type="survivors_return_%s" % aftermath)
UnboundLocalError: local variable 'msg' referenced before assignment
toconnell commented 6 years ago

Turns out this is customer-facing:

defeated_return_err

toconnell commented 6 years ago

OK, this should be fixed:

@@ -1372,19 +1374,19 @@ class Settlement(Models.UserAsset):
         for s in returned:
             if not s.is_dead():
                 live_returns.append(s.survivor['name'])
-
+
+        msg = "Departing Survivors returend to the settlement in %s." % (aftermath)
         if live_returns != []:
             returners = utils.list_to_pretty_string(live_returns)
-            msg = "Departing Survivors returend to the settlement in %s." % (aftermath)
-            if showdown_type == 'normal':
-                msg = "%s returned to the settlement in %s." % (returners, aftermath)
-            elif showdown_type == 'special':
+            if showdown_type == 'special':
                 msg = "%s healed %s." % (request.User.login, returners)
+            else:
+                msg = "%s returned to the settlement in %s." % (returners, aftermath)
         else:
-            if showdown_type == 'normal':
-                msg = "No survivors returned to the settlement."
-            elif showdown_type == 'special':
+            if showdown_type == 'special':
                 msg = 'No survivors were healed after the Special Showdown.'
+            else:
+                msg = "No survivors returned to the settlement."
         self.log_event(msg, event_type="survivors_return_%s" % aftermath)

Basically, we moved the "default" message (which should never make it to the logs) outside of the conditionals and made it so that Special Showdowns have unique handling and normal showdowns and Nemesis Encounters are handled via a big, blanket else.

Fix goes out in the next release.