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

Send ship and paintjob info to EDSM

This commit is contained in:
Jonathan Harris 2016-10-28 01:12:23 +01:00
parent e8d93979f0
commit 68f60f4eec
3 changed files with 17 additions and 0 deletions

View File

@ -529,9 +529,15 @@ class AppWindow:
# Send ship info to EDSM on startup or change
if entry['event'] in [None, 'LoadGame', 'ShipyardNew', 'ShipyardSwap']:
self.edsm.setshipid(monitor.shipid)
self.edsm.updateship(monitor.shipid, monitor.shiptype)
elif entry['event'] in ['ShipyardBuy', 'ShipyardSell']:
self.edsm.sellship(entry.get('SellShipID'))
# Send paintjob info to EDSM on change
if entry['event'] in ['ModuleBuy', 'ModuleSell'] and entry['Slot'] == 'PaintJob':
symbol = re.match('\$(.+)_name;', entry.get('BuyItem', ''))
self.edsm.updateship(monitor.shipid, monitor.shiptype, 'paintJob', (symbol and symbol.group(1).lower() or entry.get('BuyItem', '')))
# Write EDSM log on change
if monitor.mode and entry['event'] in ['Location', 'FSDJump']:
self.system['image'] = ''

View File

@ -172,6 +172,13 @@ class EDSM:
if shipid is not None:
self.call('api-commander-v1/set-ship-id', '&shipId=%d' % shipid)
def updateship(self, shipid, shiptype, slot = None, thing = None):
if shipid is not None and shiptype:
args = '&shipId=%d&type=%s' % (shipid, shiptype)
if slot:
args += '&%s=%s' % (slot, thing)
self.call('api-commander-v1/update-ship', args)
def sellship(self, shipid):
if shipid is not None:
self.call('api-commander-v1/sell-ship', '&shipId=%d' % shipid)

View File

@ -78,6 +78,7 @@ class EDLogs(FileSystemEventHandler):
self.mode = None
self.cmdr = None
self.shipid = None
self.shiptype = None
self.system = None
self.station = None
self.coordinates = None
@ -222,6 +223,7 @@ class EDLogs(FileSystemEventHandler):
self.cmdr = entry['Commander']
self.mode = entry.get('GameMode') # 'Open', 'Solo', 'Group', or None for CQC
self.shipid = entry.get('ShipID') # None in CQC
self.shiptype = 'Ship' in entry and entry['Ship'].lower() or None # None in CQC
self.system = None
self.station = None
self.coordinates = None
@ -231,8 +233,10 @@ class EDLogs(FileSystemEventHandler):
self.cmdr = entry['Name']
elif entry['event'] == 'ShipyardNew':
self.shipid = entry['NewShipID']
self.shiptype = entry['ShipType'].lower()
elif entry['event'] == 'ShipyardSwap':
self.shipid = entry['ShipID']
self.shiptype = entry['ShipType'].lower()
elif entry['event'] in ['Undocked']:
self.station = None
elif entry['event'] in ['Location', 'FSDJump', 'Docked']: