* After any Journal event we might as well set it.
* Attempt to update on a `SwitchSuitLoadout` event, assuming the new
slot is one we heard about in the last CAPI data.
I've gone with 'None' for when there's no data, rather than {}. That
makes for simpler checks on if there is data (a dict.get('foo') only
checks for that, not the dict structure otherwise).
If no 'suit' in the data we assume no Odyssey, but otherwise plough on
with dict.get() statements as they'll default to None if it's not
present.
*Users* of this monitor.state[] extra data get to choose what to do if
some data is present but not other.
This at least ensures we're correct after logging back in at a station.
If you relog whilst out at a Settlement then counts will definitely be
wrong now. But there are no events for using consumables, or picking
anything up anyway, so it's almost always going to be off there.
This has an array 'Offered' listing what was traded away.
'Category' & 'Received' is what you got in return, 'Count' many.
Again, we assume this only interacts with ShipLocker, not BackPack.
These are being sold to a Bar Tender.
There's a MicroResources array, one per item name. We assume this is
always selling from ShipLocker, not BackPack.
This is currently only when buying Consumables from a Pioneer Supplies
vendor.
One event per Item type, it's not an array.
We're assuming these go into ShipLocker, not BackPack.
It's unclear from my Journals if this is adding to the current or is the
total state at the time. I think it's the latter, despite not finding
where a '737844537' had come from (looks like from a mission, but that
would be reward and should have gone straight to ShipLocker?).
* We now use event_queue.empty() to see if it is indeed empty.
* Changed AppWindow.journal_event() to also use .empty() rather than
`while True`. Keeping the `'if not entry'` check just in case.
This prevents it from calling monitor.get_entry() when the prior run
through the loop has just emptied the queue. Thus we'll only log when
it genuinely IS unexpectedly empty.
* During *game* Shutdown we can send the synthetic 'Shutdown' event
through, and then find and append the actual game 'Shutdown' event
(i.e. this wasn't a crash, which is what the synthetic event is meant
to react to). But AppWindow.journal_event() loop picks up both events
in one call, so the second <<JournalEvent>> sends it working on an
empty queue.
Thus we log in monitor.get_entry() only if the queue is empty *and*
the game is still running.
* NB: Also adds 'Component' to the OTHER place montitor.state is
initialised.
* monitor.on_foot is now monitor.state['on_foot'] as plugins need to
access it.
* EDDB:journal_entry() now stores that in this.on_foot to check later.
* this.on_foot checked in cmdr_data() to actually set station name from
that data if needs be. This avoids setting it to STATION_UNDOCKED if
data['commander']['docked'] is False, when we're on_foot.
NB: No shipyard in tests because data['ships']['shipyard_list'] is an
empty list. This might be the bug not having been fixed, or the station
might genuinely have no ships for sale. We have no way to check in
Odyssey Alpha Phase 1.
* For taxi-usage you 'Embark' on it to take the trip and 'Disembark'
onto foot at the other end.
* Joining a multi-crew session will mean no longer being on foot.
* When quitting a multi-crew session we might miss that you're back
on-foot. Need to test.
We had a report of a UnicodeDecodeError trying to read an old file. So
try utf-8 first, if it fails try the default, and if nothing else try to
write a new file so the next call should actually work as expected.
* docstrings added as per flake8 complaints.
* Some type hints added (as I was documenting param and return).
* Also reworked two uses of .format()
* A number of functions had noqa added for cognitive complexity.