mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-17 17:42:20 +03:00
Backpack: event name is CamelCase, stored in monitor.state, doc
* Surprise! The new event is `BackPack`, not `Backpack`, although the filename *is* `Backpack.json`. * Store the loaded JSON dict in `monitor.state['BackpackJSON']`. That `p` is lower case to match with the filename, not the event name. * Document this in PLUGINS.md. Unless EDSM is telling us to discard this we should now be sending it.
This commit is contained in:
parent
0b9991b092
commit
143a205fb9
@ -599,6 +599,7 @@ Content of `state` (updated to the current journal entry):
|
||||
| `Consumable` | `dict` | 'Consumable' MicroResources in Odyssey, `int` count each. |
|
||||
| `Data` | `dict` | 'Data' MicroResources in Odyssey, `int` count each. |
|
||||
| `BackPack` | `dict` | `dict` of Odyssey MicroResources in backpack. |
|
||||
| `BackpackJSON` | `dict` | Content of Backpack.json as of last read. |
|
||||
| `SuitCurrent` | `dict` | CAPI-returned data of currently worn suit. NB: May be `None` if no data. |
|
||||
| `Suits` | `dict`[1] | CAPI-returned data of owned suits. NB: May be `None` if no data. |
|
||||
| `SuitLoadoutCurrent` | `dict` | CAPI-returned data of current Suit Loadout. NB: May be `None` if no data. |
|
||||
|
@ -151,6 +151,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
|
||||
'Item': defaultdict(int), # BackPack Items
|
||||
'Data': defaultdict(int), # Backpack Data
|
||||
},
|
||||
'BackpackJSON': None, # Raw JSON from `Backpack.json` file, if available
|
||||
'SuitCurrent': None,
|
||||
'Suits': {},
|
||||
'SuitLoadoutCurrent': None,
|
||||
@ -866,17 +867,21 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
|
||||
{self.canonicalise(x['Name']): x['Count'] for x in clean_data}
|
||||
)
|
||||
|
||||
elif event_type == 'Backpack':
|
||||
elif event_type == 'BackPack':
|
||||
# TODO: v31 doc says this is`backpack.json` ... but Howard Chalkley
|
||||
# said it's `Backpack.json`
|
||||
with open(join(self.currentdir, 'Backpack.json'), 'rb') as backpack: # type: ignore
|
||||
try:
|
||||
entry = json.load(backpack)
|
||||
# Preserve property order because why not?
|
||||
entry = json.load(backpack, object_pairs_hook=OrderedDict)
|
||||
|
||||
except json.JSONDecodeError:
|
||||
logger.exception('Failed decoding Backpack.json', exc_info=True)
|
||||
|
||||
else:
|
||||
# Store in monitor.state
|
||||
self.state['BackpackJSON'] = entry
|
||||
|
||||
# Assume this reflects the current state when written
|
||||
self.state['BackPack']['Component'] = defaultdict(int)
|
||||
self.state['BackPack']['Consumable'] = defaultdict(int)
|
||||
|
Loading…
x
Reference in New Issue
Block a user