Skip to content

Commit

Permalink
Merge pull request #2347 from colsw/stateupdate
Browse files Browse the repository at this point in the history
Include 'missing?' Loadout event properties in 'state'
  • Loading branch information
Rixxan authored Feb 8, 2025
2 parents 2f73933 + 583ee4f commit 9a9246c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions PLUGINS.md
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,10 @@ Content of `state` (updated to the current journal entry):
| `ShipType` | `str` | Internal name for the current ship type |
| `HullValue` | `int` | Current ship value, excluding modules |
| `ModulesValue` | `int` | Value of the current ship's modules |
| `UnladenMass` | `float` | Unladen mass of current ship |
| `CargoCapacity` | `int` | Max cargo capacity of current ship |
| `MaxJumpRange` | `float` | Unladen jump range of current ship |
| `FuelCapacity` | `dict[str,float]` | Current max capacity of Main & Reserve tanks |
| `Rebuy` | `int` | Current ship's rebuy cost |
| `Modules` | `dict` | Currently fitted modules |
| `NavRoute` | `dict` | Last plotted multi-hop route[1] |
Expand Down
10 changes: 10 additions & 0 deletions monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ def __init_state(self) -> None:
'ShipType': None,
'HullValue': None,
'ModulesValue': None,
'UnladenMass': None,
'CargoCapacity': None,
'MaxJumpRange': None,
'FuelCapacity': None,
'Rebuy': None,
'Modules': None,
'CargoJSON': None, # The raw data from the last time cargo.json was read
Expand Down Expand Up @@ -680,6 +684,12 @@ def parse_entry(self, line: bytes) -> MutableMapping[str, Any]: # noqa: C901, C
self.state['ShipType'] = self.canonicalise(entry['Ship'])
self.state['HullValue'] = entry.get('HullValue') # not present on exiting Outfitting
self.state['ModulesValue'] = entry.get('ModulesValue') # not present on exiting Outfitting
self.state['UnladenMass'] = entry.get('UnladenMass')
self.state['CargoCapacity'] = entry.get('CargoCapacity')
self.state['MaxJumpRange'] = entry.get('MaxJumpRange')
self.state['FuelCapacity'] = {}
self.state['FuelCapacity']['Main'] = entry.get('FuelCapacity')['Main']
self.state['FuelCapacity']['Reserve'] = entry.get('FuelCapacity')['Reserve']
self.state['Rebuy'] = entry.get('Rebuy')
# Remove spurious differences between initial Loadout event and subsequent
self.state['Modules'] = {}
Expand Down

0 comments on commit 9a9246c

Please sign in to comment.