mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-06-05 18:03:17 +03:00
EDDN: Just use this.horizons
for CAPI data sending
This commit is contained in:
parent
488fdf4976
commit
bd183efbd4
@ -442,14 +442,6 @@ Msg:\n{msg}'''
|
|||||||
"""
|
"""
|
||||||
modules, ships = self.safe_modules_and_ships(data)
|
modules, ships = self.safe_modules_and_ships(data)
|
||||||
|
|
||||||
# Horizons flag - will hit at least Int_PlanetApproachSuite other than at engineer bases ("Colony"),
|
|
||||||
# prison or rescue Megaships, or under Pirate Attack etc
|
|
||||||
horizons: bool = is_horizons(
|
|
||||||
data['lastStarport'].get('economies', {}),
|
|
||||||
modules,
|
|
||||||
ships
|
|
||||||
)
|
|
||||||
|
|
||||||
to_search: Iterator[Mapping[str, Any]] = filter(
|
to_search: Iterator[Mapping[str, Any]] = filter(
|
||||||
lambda m: self.MODULE_RE.search(m['name']) and m.get('sku') in (None, HORIZ_SKU) and
|
lambda m: self.MODULE_RE.search(m['name']) and m.get('sku') in (None, HORIZ_SKU) and
|
||||||
m['name'] != 'Int_PlanetApproachSuite',
|
m['name'] != 'Int_PlanetApproachSuite',
|
||||||
@ -461,7 +453,7 @@ Msg:\n{msg}'''
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Don't send empty modules list - schema won't allow it
|
# Don't send empty modules list - schema won't allow it
|
||||||
if outfitting and this.outfitting != (horizons, outfitting):
|
if outfitting and this.outfitting != (this.horizons, outfitting):
|
||||||
self.send(data['commander']['name'], {
|
self.send(data['commander']['name'], {
|
||||||
'$schemaRef': f'https://eddn.edcd.io/schemas/outfitting/2{"/test" if is_beta else ""}',
|
'$schemaRef': f'https://eddn.edcd.io/schemas/outfitting/2{"/test" if is_beta else ""}',
|
||||||
'message': OrderedDict([
|
'message': OrderedDict([
|
||||||
@ -469,13 +461,13 @@ Msg:\n{msg}'''
|
|||||||
('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),
|
('horizons', this.horizons),
|
||||||
('modules', outfitting),
|
('modules', outfitting),
|
||||||
('odyssey', is_odyssey),
|
('odyssey', is_odyssey),
|
||||||
]),
|
]),
|
||||||
})
|
})
|
||||||
|
|
||||||
this.outfitting = (horizons, outfitting)
|
this.outfitting = (this.horizons, outfitting)
|
||||||
|
|
||||||
def export_shipyard(self, data: CAPIData, is_beta: bool, is_odyssey: bool) -> None:
|
def export_shipyard(self, data: CAPIData, is_beta: bool, is_odyssey: bool) -> None:
|
||||||
"""
|
"""
|
||||||
@ -488,12 +480,6 @@ Msg:\n{msg}'''
|
|||||||
"""
|
"""
|
||||||
modules, ships = self.safe_modules_and_ships(data)
|
modules, ships = self.safe_modules_and_ships(data)
|
||||||
|
|
||||||
horizons: bool = is_horizons(
|
|
||||||
data['lastStarport'].get('economies', {}),
|
|
||||||
modules,
|
|
||||||
ships
|
|
||||||
)
|
|
||||||
|
|
||||||
shipyard: List[Mapping[str, Any]] = sorted(
|
shipyard: List[Mapping[str, Any]] = sorted(
|
||||||
itertools.chain(
|
itertools.chain(
|
||||||
(ship['name'].lower() for ship in (ships['shipyard_list'] or {}).values()),
|
(ship['name'].lower() for ship in (ships['shipyard_list'] or {}).values()),
|
||||||
@ -501,7 +487,7 @@ Msg:\n{msg}'''
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
# Don't send empty ships list - shipyard data is only guaranteed present if user has visited the 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):
|
if shipyard and this.shipyard != (this.horizons, shipyard):
|
||||||
self.send(data['commander']['name'], {
|
self.send(data['commander']['name'], {
|
||||||
'$schemaRef': f'https://eddn.edcd.io/schemas/shipyard/2{"/test" if is_beta else ""}',
|
'$schemaRef': f'https://eddn.edcd.io/schemas/shipyard/2{"/test" if is_beta else ""}',
|
||||||
'message': OrderedDict([
|
'message': OrderedDict([
|
||||||
@ -509,13 +495,13 @@ Msg:\n{msg}'''
|
|||||||
('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),
|
('horizons', this.horizons),
|
||||||
('ships', shipyard),
|
('ships', shipyard),
|
||||||
('odyssey', is_odyssey),
|
('odyssey', is_odyssey),
|
||||||
]),
|
]),
|
||||||
})
|
})
|
||||||
|
|
||||||
this.shipyard = (horizons, shipyard)
|
this.shipyard = (this.horizons, shipyard)
|
||||||
|
|
||||||
def export_journal_commodities(self, cmdr: str, is_beta: bool, entry: Mapping[str, Any]) -> None:
|
def export_journal_commodities(self, cmdr: str, is_beta: bool, entry: Mapping[str, Any]) -> None:
|
||||||
"""
|
"""
|
||||||
@ -571,7 +557,6 @@ Msg:\n{msg}'''
|
|||||||
:param entry: The relevant journal entry
|
:param entry: The relevant journal entry
|
||||||
"""
|
"""
|
||||||
modules: List[Mapping[str, Any]] = entry.get('Items', [])
|
modules: List[Mapping[str, Any]] = entry.get('Items', [])
|
||||||
horizons: bool = entry.get('Horizons', False)
|
|
||||||
# outfitting = sorted([self.MODULE_RE.sub(lambda m: m.group(0).capitalize(), module['Name'])
|
# outfitting = sorted([self.MODULE_RE.sub(lambda m: m.group(0).capitalize(), module['Name'])
|
||||||
# for module in modules if module['Name'] != 'int_planetapproachsuite'])
|
# for module in modules if module['Name'] != 'int_planetapproachsuite'])
|
||||||
outfitting: List[str] = sorted(
|
outfitting: List[str] = sorted(
|
||||||
@ -579,7 +564,7 @@ Msg:\n{msg}'''
|
|||||||
filter(lambda m: m['Name'] != 'int_planetapproachsuite', modules)
|
filter(lambda m: m['Name'] != 'int_planetapproachsuite', modules)
|
||||||
)
|
)
|
||||||
# Don't send empty modules list - schema won't allow it
|
# Don't send empty modules list - schema won't allow it
|
||||||
if outfitting and this.outfitting != (horizons, outfitting):
|
if outfitting and this.outfitting != (this.horizons, outfitting):
|
||||||
self.send(cmdr, {
|
self.send(cmdr, {
|
||||||
'$schemaRef': f'https://eddn.edcd.io/schemas/outfitting/2{"/test" if is_beta else ""}',
|
'$schemaRef': f'https://eddn.edcd.io/schemas/outfitting/2{"/test" if is_beta else ""}',
|
||||||
'message': OrderedDict([
|
'message': OrderedDict([
|
||||||
@ -587,13 +572,13 @@ Msg:\n{msg}'''
|
|||||||
('systemName', entry['StarSystem']),
|
('systemName', entry['StarSystem']),
|
||||||
('stationName', entry['StationName']),
|
('stationName', entry['StationName']),
|
||||||
('marketId', entry['MarketID']),
|
('marketId', entry['MarketID']),
|
||||||
('horizons', horizons),
|
('horizons', this.horizons),
|
||||||
('modules', outfitting),
|
('modules', outfitting),
|
||||||
('odyssey', entry['odyssey'])
|
('odyssey', entry['odyssey'])
|
||||||
]),
|
]),
|
||||||
})
|
})
|
||||||
|
|
||||||
this.outfitting = (horizons, outfitting)
|
this.outfitting = (this.horizons, outfitting)
|
||||||
|
|
||||||
def export_journal_shipyard(self, cmdr: str, is_beta: bool, entry: Mapping[str, Any]) -> None:
|
def export_journal_shipyard(self, cmdr: str, is_beta: bool, entry: Mapping[str, Any]) -> None:
|
||||||
"""
|
"""
|
||||||
@ -606,10 +591,9 @@ Msg:\n{msg}'''
|
|||||||
:param entry: the relevant journal entry
|
:param entry: the relevant journal entry
|
||||||
"""
|
"""
|
||||||
ships: List[Mapping[str, Any]] = entry.get('PriceList') or []
|
ships: List[Mapping[str, Any]] = entry.get('PriceList') or []
|
||||||
horizons: bool = entry.get('Horizons', False)
|
|
||||||
shipyard = sorted(ship['ShipType'] for ship in ships)
|
shipyard = sorted(ship['ShipType'] for ship in ships)
|
||||||
# Don't send empty ships list - shipyard data is only guaranteed present if user has visited the 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):
|
if shipyard and this.shipyard != (this.horizons, shipyard):
|
||||||
self.send(cmdr, {
|
self.send(cmdr, {
|
||||||
'$schemaRef': f'https://eddn.edcd.io/schemas/shipyard/2{"/test" if is_beta else ""}',
|
'$schemaRef': f'https://eddn.edcd.io/schemas/shipyard/2{"/test" if is_beta else ""}',
|
||||||
'message': OrderedDict([
|
'message': OrderedDict([
|
||||||
@ -617,13 +601,13 @@ Msg:\n{msg}'''
|
|||||||
('systemName', entry['StarSystem']),
|
('systemName', entry['StarSystem']),
|
||||||
('stationName', entry['StationName']),
|
('stationName', entry['StationName']),
|
||||||
('marketId', entry['MarketID']),
|
('marketId', entry['MarketID']),
|
||||||
('horizons', horizons),
|
('horizons', this.horizons),
|
||||||
('ships', shipyard),
|
('ships', shipyard),
|
||||||
('odyssey', entry['odyssey'])
|
('odyssey', entry['odyssey'])
|
||||||
]),
|
]),
|
||||||
})
|
})
|
||||||
|
|
||||||
# this.shipyard = (horizons, shipyard)
|
# this.shipyard = (this.horizons, shipyard)
|
||||||
|
|
||||||
def export_journal_entry(self, cmdr: str, entry: Mapping[str, Any], msg: Mapping[str, Any]) -> None:
|
def export_journal_entry(self, cmdr: str, entry: Mapping[str, Any], msg: Mapping[str, Any]) -> None:
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user