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

Timeline: the Settlement's get_available_endeavors() method throws a timeline-related error #492

Closed toconnell closed 6 years ago

toconnell commented 6 years ago

Method: GET URL: http://api.thewatcher.io/settlement/get_campaign/5aa6ff728740d905cdc7cef5 JSON: None

The full traceback is as follows:

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 505, in wrapped_function
 resp = make_response(f(*args, **kwargs))
File "/usr/lib/python2.7/dist-packages/celery/local.py", line 188, in __call__
 return self._get_current_object()(*a, **kw)
File "/usr/lib/python2.7/dist-packages/celery/app/task.py", line 420, in __call__
 return self.run(*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 3801, in request_response
 return Response(response=self.serialize('campaign'), status=200, mimetype="application/json")
File "/home/toconnell/kdm-manager/v2/api/models/settlements.py", line 487, in serialize
 available_endeavors, available_endeavor_count = self.get_available_endeavors()
File "/home/toconnell/kdm-manager/v2/api/models/settlements.py", line 2102, in get_available_endeavors
 current_ly = self.get_timeline_year(self.get_current_ly())
File "/home/toconnell/kdm-manager/v2/api/models/settlements.py", line 3151, in get_timeline_year
 for ly in self.settlement['timeline']:
KeyError: 'timeline'

It's almost gotta be some kind of order of operations thing.

toconnell commented 6 years ago

Alright, so I pulled this one down into dev, and it literally has no Timeline: the error is legit.

I guess...we add some code to the _bugfixes() method for settlements so that it re-inits the timeline if it somehow dies during a critical operation and gets saved in a state without a timeline?

This is nuts.

toconnell commented 6 years ago

Mystery solved: dude removed the Sunstalker from his PotSun campaign, which must have...triggered some really exciting cascading failures when he did it.

It looks like...mandatory expansions going to need to be a feature, if we really want this thing to be user-proofed.

toconnell commented 6 years ago

Alright, we're user-proofing this in the JS and doing some visual stuff just to make it clear that campaign-mandated expansion content cannot be removed.