Send ship and paintjob info to EDSM

This commit is contained in:
Jonathan Harris committed 2016-10-28 11:56:36 +01:00
1 parent e8d93979f0
commit 68f60f4eec
3 files changed
+17

No files matched your search

+6
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'] = ''
+7
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)
+4
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']: