mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-21 11:27:38 +03:00
Initial support for Route.json file
This commit is contained in:
parent
e293f0f334
commit
ef891fa8bd
@ -426,6 +426,7 @@ Content of `state` (updated to the current journal entry):
|
||||
| `ModulesValue` | `int` | Value of the current ship's modules |
|
||||
| `Rebuy` | `int` | Current ship's rebuy cost |
|
||||
| `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
|
||||
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
|
||||
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
|
||||
|
||||
```python
|
||||
|
10
monitor.py
10
monitor.py
@ -126,7 +126,8 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
|
||||
'ModulesValue': None,
|
||||
'Rebuy': 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'):
|
||||
@ -459,6 +460,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
|
||||
'ModulesValue': None,
|
||||
'Rebuy': None,
|
||||
'Modules': None,
|
||||
'Route': None,
|
||||
}
|
||||
|
||||
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})
|
||||
|
||||
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'):
|
||||
commodity = self.canonicalise(entry['Type'])
|
||||
self.state['Cargo'][commodity] += entry.get('Count', 1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user