From 80ac6e5803678adb74eab2dd575d4e9bfcf32be1 Mon Sep 17 00:00:00 2001 From: aussig Date: Tue, 13 Jun 2023 19:35:56 +0100 Subject: [PATCH] Add TW tissue sample collection and handin --- CHANGELOG.md | 1 + bgstally/activity.py | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 035a830..7025c5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Bug Fixes: * Fix failure of networking thread, and therefore all subsequent networking calls, if an API discovery request detects new API features during startup. +* Fix Thargoid tissue sample Search and Rescue pickup and handin. ## v3.1.0-a2 - 2023-08-05 diff --git a/bgstally/activity.py b/bgstally/activity.py index afe2af5..2941f01 100644 --- a/bgstally/activity.py +++ b/bgstally/activity.py @@ -441,6 +441,11 @@ def trade_sold(self, journal_entry:dict, state:State): current_system = self.systems.get(state.current_system_id) if not current_system: return + # Handle SandR tissue samples first + if 'thargoidtissuesample' in journal_entry.get('Type', "").lower(): + self._search_and_rescue_handin('t', journal_entry.get('Count', 0)) + # Fall through to BGS tracking for standard trade sale + faction = current_system['Factions'].get(state.station_faction) if faction: self.dirty = True @@ -600,6 +605,7 @@ def collect_cargo(self, journal_entry: dict, state: State): case 'damagedescapepod': key = 'dp' case 'occupiedcryopod': key = 'op' case 'usscargoblackbox': key = 'bb' + case _ as cargo_type if "thargoidtissuesample" in cargo_type: key = 't' if key is None: return @@ -612,20 +618,28 @@ def search_and_rescue(self, journal_entry: dict, state: State): Handle search and rescue hand-in """ key:str = None + count:int = int(journal_entry.get('Count', 0)) + # There is no tissue sample tracking here as those are treated a commodities match journal_entry.get('Name', "").lower(): case 'damagedescapepod': key = 'dp' case 'occupiedcryopod': key = 'op' case 'usscargoblackbox': key = 'bb' - if key is None: return + if key is None or count == 0: return + + self._search_and_rescue_handin(key, count) + + + def _search_and_rescue_handin(self, key:str, count:int): + """ + Tally a search and rescue handin. These can originate from SearchAndRescue or TradeSell events + """ # S&R can be handed in in any system, but the effect counts for the system the items were collected in. However, # we have no way of knowing exactly which items were handed in, so just iterate through all our known systems # looking for previously scooped cargo of the correct type. - count:int = int(journal_entry.get('Count', 0)) - for system in self.systems.values(): if count <= 0: break # Finish when we've accounted for all items