mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-17 17:42:20 +03:00
Factor in Horizons flag when de-duplicating
This commit is contained in:
parent
aa1cc6a268
commit
1dc6d04954
@ -198,9 +198,13 @@ class EDDN:
|
||||
def export_outfitting(self, data, is_beta):
|
||||
economies = data['lastStarport'].get('economies') or {}
|
||||
modules = data['lastStarport'].get('modules') or {}
|
||||
horizons = any(economy['name'] == 'Colony' for economy in economies.itervalues()) or any(module.get('sku') == 'ELITE_HORIZONS_V_PLANETARY_LANDINGS' for module in modules.itervalues()) # Should always hit Int_PlanetApproachSuite other than at engineer bases
|
||||
ships = data['lastStarport'].get('ships') or { 'shipyard_list': {}, 'unavailable_list': [] }
|
||||
# Horizons flag - will hit at least Int_PlanetApproachSuite other than at engineer bases ("Colony"), prison or rescue Megaships, or under Pirate Attack etc
|
||||
horizons = (any(economy['name'] == 'Colony' for economy in economies.itervalues()) or
|
||||
any(module.get('sku') == 'ELITE_HORIZONS_V_PLANETARY_LANDINGS' for module in modules.itervalues()) or
|
||||
any(ship.get('sku') == 'ELITE_HORIZONS_V_PLANETARY_LANDINGS' for ship in (ships['shipyard_list'] or {}).values()))
|
||||
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 != (horizons, outfitting): # Don't send empty modules list - schema won't allow it
|
||||
self.send(data['commander']['name'], {
|
||||
'$schemaRef' : 'https://eddn.edcd.io/schemas/outfitting/2' + (is_beta and '/test' or ''),
|
||||
'message' : OrderedDict([
|
||||
@ -212,15 +216,17 @@ class EDDN:
|
||||
('modules', outfitting),
|
||||
]),
|
||||
})
|
||||
this.outfitting = outfitting
|
||||
this.outfitting = (horizons, outfitting)
|
||||
|
||||
def export_shipyard(self, data, is_beta):
|
||||
economies = data['lastStarport'].get('economies') or {}
|
||||
modules = data['lastStarport'].get('modules') or {}
|
||||
ships = data['lastStarport'].get('ships') or { 'shipyard_list': {}, 'unavailable_list': [] }
|
||||
horizons = any(economy['name'] == 'Colony' for economy in economies.itervalues()) or any(module.get('sku') == 'ELITE_HORIZONS_V_PLANETARY_LANDINGS' for module in modules.itervalues()) or any(ship.get('sku') == 'ELITE_HORIZONS_V_PLANETARY_LANDINGS' for ship in (ships['shipyard_list'] or {}).values())
|
||||
horizons = (any(economy['name'] == 'Colony' for economy in economies.itervalues()) or
|
||||
any(module.get('sku') == 'ELITE_HORIZONS_V_PLANETARY_LANDINGS' for module in modules.itervalues()) or
|
||||
any(ship.get('sku') == 'ELITE_HORIZONS_V_PLANETARY_LANDINGS' for ship in (ships['shipyard_list'] or {}).values()))
|
||||
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 != (horizons, shipyard): # Don't send empty ships list - shipyard data is only guaranteed present if user has visited the shipyard.
|
||||
self.send(data['commander']['name'], {
|
||||
'$schemaRef' : 'https://eddn.edcd.io/schemas/shipyard/2' + (is_beta and '/test' or ''),
|
||||
'message' : OrderedDict([
|
||||
@ -232,7 +238,7 @@ class EDDN:
|
||||
('ships', shipyard),
|
||||
]),
|
||||
})
|
||||
this.shipyard = shipyard
|
||||
this.shipyard = (horizons, shipyard)
|
||||
|
||||
def export_journal_commodities(self, cmdr, is_beta, entry):
|
||||
items = entry.get('Items') or []
|
||||
@ -262,8 +268,9 @@ class EDDN:
|
||||
|
||||
def export_journal_outfitting(self, cmdr, is_beta, entry):
|
||||
modules = entry.get('Items') or []
|
||||
horizons = entry.get('Horizons', False)
|
||||
outfitting = sorted([self.MODULE_RE.sub(lambda m: m.group(0).capitalize(), module['Name']) for module in modules if 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 != (horizons, outfitting): # Don't send empty modules list - schema won't allow it
|
||||
self.send(cmdr, {
|
||||
'$schemaRef' : 'https://eddn.edcd.io/schemas/outfitting/2' + (is_beta and '/test' or ''),
|
||||
'message' : OrderedDict([
|
||||
@ -271,16 +278,17 @@ class EDDN:
|
||||
('systemName', entry['StarSystem']),
|
||||
('stationName', entry['StationName']),
|
||||
('marketId', entry['MarketID']),
|
||||
('horizons', entry['Horizons']),
|
||||
('horizons', horizons),
|
||||
('modules', outfitting),
|
||||
]),
|
||||
})
|
||||
this.outfitting = outfitting
|
||||
this.outfitting = (horizons, outfitting)
|
||||
|
||||
def export_journal_shipyard(self, cmdr, is_beta, entry):
|
||||
ships = entry.get('PriceList') or []
|
||||
horizons = entry.get('Horizons', False)
|
||||
shipyard = sorted([ship['ShipType'] for ship in ships])
|
||||
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 != (horizons, shipyard): # Don't send empty ships list - shipyard data is only guaranteed present if user has visited the shipyard.
|
||||
self.send(cmdr, {
|
||||
'$schemaRef' : 'https://eddn.edcd.io/schemas/shipyard/2' + (is_beta and '/test' or ''),
|
||||
'message' : OrderedDict([
|
||||
@ -288,11 +296,11 @@ class EDDN:
|
||||
('systemName', entry['StarSystem']),
|
||||
('stationName', entry['StationName']),
|
||||
('marketId', entry['MarketID']),
|
||||
('horizons', entry['Horizons']),
|
||||
('horizons', horizons),
|
||||
('ships', shipyard),
|
||||
]),
|
||||
})
|
||||
this.shipyard = shipyard
|
||||
this.shipyard = (horizons, shipyard)
|
||||
|
||||
def export_journal_entry(self, cmdr, is_beta, entry):
|
||||
msg = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user