From 7ac248be7a748e7f5bbd170c6dbbf66a957a0b83 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Thu, 20 Jan 2022 17:45:23 +0000 Subject: [PATCH] inara: Utilise Statistics Current_Wealth for commanderAssets Inara itself seems to be doing this if it has access to CAPI-sourced Journals. If we don't send commanderAssets as part of setCommanderCredits then it does ... something else ... and ends up with your total assets value bouncing between what EDMC is causing and what it sees from the CAPI-sourced journals. So, don't send this from LoadGame any more, instead wait for Statistics, and if it has the relevant data, also send commanderAssets. --- plugins/inara.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/plugins/inara.py b/plugins/inara.py index a3e2a22c..86e3ec25 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -737,17 +737,24 @@ def journal_entry( # noqa: C901, CCR001 logger.debug('Adding events', exc_info=e) return str(e) - # Send credits and stats to Inara on startup only - otherwise may be out of date + # We want to utilise some Statistics data, so don't setCommanderCredits here if event_name == 'LoadGame': - new_add_event( - 'setCommanderCredits', - entry['timestamp'], - {'commanderCredits': state['Credits'], 'commanderLoan': state['Loan']} - ) - this.lastcredits = state['Credits'] elif event_name == 'Statistics': + inara_data = { + 'commanderCredits': state['Credits'], + 'commanderLoan': state['Loan'], + } + if entry.get('Bank_Account') is not None: + if entry['Bank_Account'].get('Current_Wealth') is not None: + inara_data['commanderAssets'] = entry['Bank_Account']['Current_Wealth'] + + new_add_event( + 'setCommanderCredits', + entry['timestamp'], + inara_data + ) new_add_event('setCommanderGameStatistics', entry['timestamp'], state['Statistics']) # may be out of date # Selling / swapping ships