Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
aussig committed Jun 13, 2023
2 parents ed1ae70 + 80ac6e5 commit 4aec058
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 17 additions & 3 deletions bgstally/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down

0 comments on commit 4aec058

Please sign in to comment.