1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-06-13 13:52:13 +03:00

Initial support for Route.json file

This commit is contained in:
Athanasius 2021-03-10 11:20:25 +00:00
parent e293f0f334
commit ef891fa8bd
2 changed files with 15 additions and 1 deletions

View File

@ -426,6 +426,7 @@ Content of `state` (updated to the current journal entry):
| `ModulesValue` | `int` | Value of the current ship's modules | | `ModulesValue` | `int` | Value of the current ship's modules |
| `Rebuy` | `int` | Current ship's rebuy cost | | `Rebuy` | `int` | Current ship's rebuy cost |
| `Modules` | `dict` | Currently fitted modules | | `Modules` | `dict` | Currently fitted modules |
| `Route` | `dict` | Last plotted multi-hop route |
A special "StartUp" entry is sent if EDMC is started while the game is already A special "StartUp" entry is sent if EDMC is started while the game is already
running. In this case you won't receive initial events such as "LoadGame", running. In this case you won't receive initial events such as "LoadGame",
@ -475,6 +476,11 @@ as the mission ID for mission specific cargo
is not written at Commander login (instead the in-Journal `Cargo` event is not written at Commander login (instead the in-Journal `Cargo` event
contains all the data), this will not be populated at login.** contains all the data), this will not be populated at login.**
New in version 5.0.0:
`Route` contains the `json.load()` of `Route.json` as indicated by a journal
`Route` event.
#### Getting Commander Data #### Getting Commander Data
```python ```python

View File

@ -127,6 +127,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
'Rebuy': None, 'Rebuy': None,
'Modules': None, 'Modules': None,
'CargoJSON': None, # The raw data from the last time cargo.json was read 'CargoJSON': None, # The raw data from the last time cargo.json was read
'Route': None, # Last plotted route from Route.json file
} }
def start(self, root: 'tkinter.Tk'): def start(self, root: 'tkinter.Tk'):
@ -459,6 +460,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
'ModulesValue': None, 'ModulesValue': None,
'Rebuy': None, 'Rebuy': None,
'Modules': None, 'Modules': None,
'Route': None,
} }
elif event_type == 'Commander': elif event_type == 'Commander':
@ -666,6 +668,12 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
self.state['Cargo'].update({self.canonicalise(x['Name']): x['Count'] for x in clean}) self.state['Cargo'].update({self.canonicalise(x['Name']): x['Count'] for x in clean})
elif event_type == 'Route':
# Added in ED 3.7 - multi-hop route details in Route.json
with open(join(self.currentdir, 'Route.json'), 'rb') as rf: # type: ignore
entry = json.load(rf)
self.state['Route'] = entry
elif event_type in ('CollectCargo', 'MarketBuy', 'BuyDrones', 'MiningRefined'): elif event_type in ('CollectCargo', 'MarketBuy', 'BuyDrones', 'MiningRefined'):
commodity = self.canonicalise(entry['Type']) commodity = self.canonicalise(entry['Type'])
self.state['Cargo'][commodity] += entry.get('Count', 1) self.state['Cargo'][commodity] += entry.get('Count', 1)