diff --git a/PLUGINS.md b/PLUGINS.md index 69f7934e..da7303f4 100644 --- a/PLUGINS.md +++ b/PLUGINS.md @@ -688,6 +688,7 @@ Content of `state` (updated to the current journal entry): | `StationName`[3] | `Optional[str]` | Name of the station we're docked at, if applicable | | `MarketID`[3] | `Optional[str]` | MarketID of the station we're docked at, if applicable | | `StationType`[3] | `Optional[str]` | Type of the station we're docked at, if applicable | +| `Powerplay` | `dict` | `dict` of information on Powerplay [1] - Contents of `NavRoute` not changed if a `NavRouteClear` event is seen, but plugins will see the `NavRouteClear` event. @@ -836,6 +837,12 @@ the 'Body' name value. `StationName`, `MarketID`, and `StationType` added to the `state` dictionary. +New in version 5.13.0: + +`state` now has `Powerplay`, a `dict` including `Rank`, `Merits`, `Power`, +`TimePledged`, and `Votes`. `Votes` should only be populated if playing in +legacy mode, as it is no longer a concept in the current version of the game. + ___ ##### Synthetic Events diff --git a/journal_lock.py b/journal_lock.py index 2aae20a6..3e16b309 100644 --- a/journal_lock.py +++ b/journal_lock.py @@ -51,7 +51,7 @@ class JournalLock: else: try: - self.journal_dir_path = pathlib.Path(self.journal_dir) + self.journal_dir_path = pathlib.Path.expanduser(pathlib.Path(self.journal_dir)) except Exception: # pragma: no cover logger.exception("Couldn't make pathlib.Path from journal_dir") diff --git a/monitor.py b/monitor.py index badc4c71..e37e77c1 100644 --- a/monitor.py +++ b/monitor.py @@ -179,6 +179,13 @@ class EDLogs(FileSystemEventHandler): 'StationName': None, 'NavRoute': None, + 'Powerplay': { + 'Power': None, + 'Rank': None, + 'Merits': None, + 'Votes': None, + 'TimePledged': None, + }, } def start(self, root: 'tkinter.Tk') -> bool: # noqa: CCR001 @@ -1839,6 +1846,13 @@ class EDLogs(FileSystemEventHandler): # There should be a `Backpack` event as you 'come to' in the # new location, so no need to zero out BackPack here. + elif event_type == 'powerplay': + self.state['Powerplay']['Power'] = entry.get('Power', '') + self.state['Powerplay']['Rank'] = entry.get('Rank', 0) + self.state['Powerplay']['Merits'] = entry.get('Merits', 0) + self.state['Powerplay']['Votes'] = entry.get('Votes', 0) + self.state['Powerplay']['TimePledged'] = entry.get('TimePledged', 0) + return entry except Exception as ex: diff --git a/plugins/inara.py b/plugins/inara.py index f2c9830e..b48609f0 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -548,6 +548,10 @@ def journal_entry( # noqa: C901, CCR001 power_defect_data = {'powerName': entry["ToPower"], 'rankValue': 1} new_add_event('setCommanderRankPower', entry['timestamp'], power_defect_data) + elif event_name == 'Powerplay': + power_data = {'powerName': entry["Power"], 'rankValue': entry["Rank"], 'meritsValue': entry["Merits"]} + new_add_event('setCommanderRankPower', entry['timestamp'], power_data) + # Ship change if event_name == 'Loadout' and this.shipswap: this.loadout = make_loadout(state)