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

Inspirational status drop-down generation throws an error #534

Closed toconnell closed 5 years ago

toconnell commented 5 years ago
  File "/home/toconnell/kdm-manager-api/app/models/settlements.py", line 4163, in request_response
    return Response(response=self.serialize('campaign'), status=200, mimetype="application/json")
  File "/home/toconnell/kdm-manager-api/app/models/settlements.py", line 510, in serialize
    output['game_assets']['inspirational_statue_options'] = self.get_available_fighting_arts(exclude_dead_survivors=False, return_type='JSON')
  File "/home/toconnell/kdm-manager-api/app/models/settlements.py", line 2364, in get_available_fighting_arts
    fa_dict['select_disabled'] = True
TypeError: 'NoneType' object does not support item assignment
toconnell commented 5 years ago

This is because this really old settlement has fighting arts whose "handles" are actually their names. There's a lookup problem....that I think we can fix just by using the built-in get_asset() switch that backs off to names...

toconnell commented 5 years ago
@@ -2359,7 +2364,11 @@ class Settlement(models.UserAsset):
         elif return_type == "JSON":
             output = []
             for fa_handle in sorted(fa_handles):
-                fa_dict = self.FightingArts.get_asset(fa_handle, raise_exception_if_not_found=False)
+                fa_dict = self.FightingArts.get_asset(
+                    fa_handle,
+                    backoff_to_name=True,
+                    raise_exception_if_not_found=False
+                )
                 if fa_handle in dead_survivors and fa_handle not in live_survivors:
                     fa_dict['select_disabled'] = True
                 output.append(fa_dict)

We're going out with this in the patch release.