1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-17 17:42:20 +03:00

UseConsumable: Rely on BackpackChange instead, to avoid double-accounting

This commit is contained in:
Athanasius 2021-05-20 11:26:04 +01:00
parent 8b3094dd6b
commit 0fd2264d53

View File

@ -1019,24 +1019,28 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
self.state['BackPack'][entry['Type']][i] = 0 self.state['BackPack'][entry['Type']][i] = 0
elif event_type == 'UseConsumable': elif event_type == 'UseConsumable':
# alpha4
# When using an item from the players inventory (backpack)
#
# Parameters:
# • Name
# • Type
# TODO: XXX: From v31 doc # TODO: XXX: From v31 doc
# 12.2 BackpackChange # 12.2 BackpackChange
# This is written when there is any change to the contents of the # This is written when there is any change to the contents of the
# suit backpack note this can be written at the same time as other # suit backpack note this can be written at the same time as other
# events like UseConsumable # events like UseConsumable
for c in self.state['BackPack']['Consumable']:
if c == entry['Name']: # In 4.0.0.100 it is observed that:
self.state['BackPack']['Consumable'][c] -= 1 #
# Paranoia in case we lost track # 1. Throw of any grenade type *only* causes a BackpackChange event, no
if self.state['BackPack']['Consumable'][c] < 0: # accompanying 'UseConsumable'.
self.state['BackPack']['Consumable'][c] = 0 # 2. Using an Energy Cell causes both UseConsumable and BackpackChange,
# in that order.
# 3. Medkit acts the same as Energy Cell.
#
# Thus we'll just ignore 'UseConsumable' for now.
# for c in self.state['BackPack']['Consumable']:
# if c == entry['Name']:
# self.state['BackPack']['Consumable'][c] -= 1
# # Paranoia in case we lost track
# if self.state['BackPack']['Consumable'][c] < 0:
# self.state['BackPack']['Consumable'][c] = 0
...
# TODO: # TODO:
# <https://forums.frontier.co.uk/threads/575010/> # <https://forums.frontier.co.uk/threads/575010/>