mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-14 08:17:13 +03:00
Add "horizons" flag to outfitting and shipyard messages
This commit is contained in:
parent
6ae3c4c786
commit
728ef3f599
@ -93,6 +93,7 @@ class EDLogs(FileSystemEventHandler):
|
|||||||
'Cargo' : defaultdict(int),
|
'Cargo' : defaultdict(int),
|
||||||
'Credits' : None,
|
'Credits' : None,
|
||||||
'FID' : None, # Frontier Cmdr ID
|
'FID' : None, # Frontier Cmdr ID
|
||||||
|
'Horizons' : None, # Does this user have Horizons?
|
||||||
'Loan' : None,
|
'Loan' : None,
|
||||||
'Raw' : defaultdict(int),
|
'Raw' : defaultdict(int),
|
||||||
'Manufactured' : defaultdict(int),
|
'Manufactured' : defaultdict(int),
|
||||||
@ -314,6 +315,7 @@ class EDLogs(FileSystemEventHandler):
|
|||||||
'Cargo' : defaultdict(int),
|
'Cargo' : defaultdict(int),
|
||||||
'Credits' : None,
|
'Credits' : None,
|
||||||
'FID' : None,
|
'FID' : None,
|
||||||
|
'Horizons' : None,
|
||||||
'Loan' : None,
|
'Loan' : None,
|
||||||
'Raw' : defaultdict(int),
|
'Raw' : defaultdict(int),
|
||||||
'Manufactured' : defaultdict(int),
|
'Manufactured' : defaultdict(int),
|
||||||
@ -351,6 +353,7 @@ class EDLogs(FileSystemEventHandler):
|
|||||||
'Captain' : None,
|
'Captain' : None,
|
||||||
'Credits' : entry['Credits'],
|
'Credits' : entry['Credits'],
|
||||||
'FID' : entry.get('FID'), # From 3.3
|
'FID' : entry.get('FID'), # From 3.3
|
||||||
|
'Horizons' : entry['Horizons'], # From 3.0
|
||||||
'Loan' : entry['Loan'],
|
'Loan' : entry['Loan'],
|
||||||
'Engineers' : {},
|
'Engineers' : {},
|
||||||
'Rank' : {},
|
'Rank' : {},
|
||||||
|
@ -26,6 +26,9 @@ from companion import category_map
|
|||||||
|
|
||||||
this = sys.modules[__name__] # For holding module globals
|
this = sys.modules[__name__] # For holding module globals
|
||||||
|
|
||||||
|
# Per-Cmdr Horizons flag
|
||||||
|
this.horizons = None
|
||||||
|
|
||||||
# Track location to add to Journal events
|
# Track location to add to Journal events
|
||||||
this.systemaddress = None
|
this.systemaddress = None
|
||||||
this.coordinates = None
|
this.coordinates = None
|
||||||
@ -158,7 +161,7 @@ class EDDN:
|
|||||||
|
|
||||||
self.parent.after(self.REPLAYPERIOD, self.sendreplay)
|
self.parent.after(self.REPLAYPERIOD, self.sendreplay)
|
||||||
|
|
||||||
def export_commodities(self, data, is_beta):
|
def export_commodities(self, data, is_beta, horizons):
|
||||||
commodities = []
|
commodities = []
|
||||||
for commodity in data['lastStarport'].get('commodities') or []:
|
for commodity in data['lastStarport'].get('commodities') or []:
|
||||||
if (category_map.get(commodity['categoryname'], True) and # Check marketable
|
if (category_map.get(commodity['categoryname'], True) and # Check marketable
|
||||||
@ -195,7 +198,7 @@ class EDDN:
|
|||||||
})
|
})
|
||||||
this.commodities = commodities
|
this.commodities = commodities
|
||||||
|
|
||||||
def export_outfitting(self, data, is_beta):
|
def export_outfitting(self, data, is_beta, horizons):
|
||||||
modules = data['lastStarport'].get('modules') or {}
|
modules = data['lastStarport'].get('modules') or {}
|
||||||
outfitting = sorted([self.MODULE_RE.sub(lambda m: m.group(0).capitalize(), module['name'].lower()) for module in modules.itervalues() if self.MODULE_RE.search(module['name']) and module.get('sku') in [None, 'ELITE_HORIZONS_V_PLANETARY_LANDINGS'] and module['name'] != 'Int_PlanetApproachSuite'])
|
outfitting = sorted([self.MODULE_RE.sub(lambda m: m.group(0).capitalize(), module['name'].lower()) for module in modules.itervalues() if self.MODULE_RE.search(module['name']) and module.get('sku') in [None, 'ELITE_HORIZONS_V_PLANETARY_LANDINGS'] and module['name'] != 'Int_PlanetApproachSuite'])
|
||||||
if outfitting and this.outfitting != outfitting: # Don't send empty modules list - schema won't allow it
|
if outfitting and this.outfitting != outfitting: # Don't send empty modules list - schema won't allow it
|
||||||
@ -206,12 +209,13 @@ class EDDN:
|
|||||||
('systemName', data['lastSystem']['name']),
|
('systemName', data['lastSystem']['name']),
|
||||||
('stationName', data['lastStarport']['name']),
|
('stationName', data['lastStarport']['name']),
|
||||||
('marketId', data['lastStarport']['id']),
|
('marketId', data['lastStarport']['id']),
|
||||||
|
('horizons', horizons),
|
||||||
('modules', outfitting),
|
('modules', outfitting),
|
||||||
]),
|
]),
|
||||||
})
|
})
|
||||||
this.outfitting = outfitting
|
this.outfitting = outfitting
|
||||||
|
|
||||||
def export_shipyard(self, data, is_beta):
|
def export_shipyard(self, data, is_beta, horizons):
|
||||||
ships = data['lastStarport'].get('ships') or { 'shipyard_list': {}, 'unavailable_list': [] }
|
ships = data['lastStarport'].get('ships') or { 'shipyard_list': {}, 'unavailable_list': [] }
|
||||||
shipyard = sorted([ship['name'].lower() for ship in (ships['shipyard_list'] or {}).values() + ships['unavailable_list']])
|
shipyard = sorted([ship['name'].lower() for ship in (ships['shipyard_list'] or {}).values() + ships['unavailable_list']])
|
||||||
if shipyard and this.shipyard != shipyard: # Don't send empty ships list - shipyard data is only guaranteed present if user has visited the shipyard.
|
if shipyard and this.shipyard != shipyard: # Don't send empty ships list - shipyard data is only guaranteed present if user has visited the shipyard.
|
||||||
@ -222,6 +226,7 @@ class EDDN:
|
|||||||
('systemName', data['lastSystem']['name']),
|
('systemName', data['lastSystem']['name']),
|
||||||
('stationName', data['lastStarport']['name']),
|
('stationName', data['lastStarport']['name']),
|
||||||
('marketId', data['lastStarport']['id']),
|
('marketId', data['lastStarport']['id']),
|
||||||
|
('horizons', horizons),
|
||||||
('ships', shipyard),
|
('ships', shipyard),
|
||||||
]),
|
]),
|
||||||
})
|
})
|
||||||
@ -264,6 +269,7 @@ class EDDN:
|
|||||||
('systemName', entry['StarSystem']),
|
('systemName', entry['StarSystem']),
|
||||||
('stationName', entry['StationName']),
|
('stationName', entry['StationName']),
|
||||||
('marketId', entry['MarketID']),
|
('marketId', entry['MarketID']),
|
||||||
|
('horizons', entry['Horizons']),
|
||||||
('modules', outfitting),
|
('modules', outfitting),
|
||||||
]),
|
]),
|
||||||
})
|
})
|
||||||
@ -280,6 +286,7 @@ class EDDN:
|
|||||||
('systemName', entry['StarSystem']),
|
('systemName', entry['StarSystem']),
|
||||||
('stationName', entry['StationName']),
|
('stationName', entry['StationName']),
|
||||||
('marketId', entry['MarketID']),
|
('marketId', entry['MarketID']),
|
||||||
|
('horizons', entry['Horizons']),
|
||||||
('ships', shipyard),
|
('ships', shipyard),
|
||||||
]),
|
]),
|
||||||
})
|
})
|
||||||
@ -378,6 +385,9 @@ def journal_entry(cmdr, is_beta, system, station, entry, state):
|
|||||||
filtered[k] = v
|
filtered[k] = v
|
||||||
return filtered
|
return filtered
|
||||||
|
|
||||||
|
# Track Horizons
|
||||||
|
this.horizons = state['Horizons']
|
||||||
|
|
||||||
# Track location
|
# Track location
|
||||||
if entry['event'] in ['Location', 'FSDJump', 'Docked']:
|
if entry['event'] in ['Location', 'FSDJump', 'Docked']:
|
||||||
if entry['event'] == 'Location':
|
if entry['event'] == 'Location':
|
||||||
@ -464,9 +474,9 @@ def cmdr_data(data, is_beta):
|
|||||||
if not old_status:
|
if not old_status:
|
||||||
status['text'] = _('Sending data to EDDN...')
|
status['text'] = _('Sending data to EDDN...')
|
||||||
status.update_idletasks()
|
status.update_idletasks()
|
||||||
this.eddn.export_commodities(data, is_beta)
|
this.eddn.export_commodities(data, is_beta, this.horizons)
|
||||||
this.eddn.export_outfitting(data, is_beta)
|
this.eddn.export_outfitting(data, is_beta, this.horizons)
|
||||||
this.eddn.export_shipyard(data, is_beta)
|
this.eddn.export_shipyard(data, is_beta, this.horizons)
|
||||||
if not old_status:
|
if not old_status:
|
||||||
status['text'] = ''
|
status['text'] = ''
|
||||||
status.update_idletasks()
|
status.update_idletasks()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user