mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-14 08:17:13 +03:00
Send paintjob to EDSM on update if not already set
This commit is contained in:
parent
a2c9383a1f
commit
021fc43345
@ -446,15 +446,21 @@ class AppWindow:
|
||||
if not old_status:
|
||||
self.status['text'] = ''
|
||||
|
||||
# Update credits and send to EDSM
|
||||
if data['commander'].get('credits') is not None:
|
||||
monitor.credits = (data['commander']['credits'], data['commander'].get('debt', 0))
|
||||
if config.getint('output') & config.OUT_SYS_EDSM and not monitor.is_beta:
|
||||
try:
|
||||
# Update credits and ship info and send to EDSM
|
||||
if config.getint('output') & config.OUT_SYS_EDSM and not monitor.is_beta:
|
||||
try:
|
||||
if data['commander'].get('credits') is not None:
|
||||
monitor.credits = (data['commander']['credits'], data['commander'].get('debt', 0))
|
||||
self.edsm.setcredits(monitor.credits)
|
||||
except Exception as e:
|
||||
# Not particularly important so silent on failure
|
||||
if __debug__: print_exc()
|
||||
if monitor.shippaint is None: # paintjob only reported in Journal on change
|
||||
monitor.shipid = data['ship']['id']
|
||||
monitor.shiptype = data['ship']['name'].lower()
|
||||
monitor.shippaint = data['ship']['modules']['PaintJob'] and data['ship']['modules']['PaintJob']['module']['name'].lower() or ''
|
||||
self.edsm.updateship(monitor.shipid, monitor.shiptype, 'paintJob', monitor.shippaint)
|
||||
|
||||
except Exception as e:
|
||||
# Not particularly important so silent on failure
|
||||
if __debug__: print_exc()
|
||||
|
||||
|
||||
except companion.VerificationRequired:
|
||||
@ -533,14 +539,13 @@ 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)
|
||||
self.edsm.updateship(monitor.shipid, monitor.shiptype, 'paintJob', monitor.shippaint)
|
||||
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', '')))
|
||||
self.edsm.updateship(monitor.shipid, monitor.shiptype, 'paintJob', monitor.shippaint)
|
||||
|
||||
# Write EDSM log on change
|
||||
if monitor.mode and entry['event'] in ['Location', 'FSDJump']:
|
||||
|
2
edsm.py
2
edsm.py
@ -215,7 +215,7 @@ class EDSM:
|
||||
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:
|
||||
if slot and thing is not None:
|
||||
args += '&%s=%s' % (slot, thing)
|
||||
self.call('api-commander-v1/update-ship', args)
|
||||
|
||||
|
@ -79,6 +79,7 @@ class EDLogs(FileSystemEventHandler):
|
||||
self.cmdr = None
|
||||
self.shipid = None
|
||||
self.shiptype = None
|
||||
self.shippaint = None
|
||||
self.system = None
|
||||
self.station = None
|
||||
self.coordinates = None
|
||||
@ -224,6 +225,7 @@ class EDLogs(FileSystemEventHandler):
|
||||
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.shippaint = None
|
||||
self.system = None
|
||||
self.station = None
|
||||
self.coordinates = None
|
||||
@ -234,9 +236,14 @@ class EDLogs(FileSystemEventHandler):
|
||||
elif entry['event'] == 'ShipyardNew':
|
||||
self.shipid = entry['NewShipID']
|
||||
self.shiptype = entry['ShipType'].lower()
|
||||
self.shippaint = None
|
||||
elif entry['event'] == 'ShipyardSwap':
|
||||
self.shipid = entry['ShipID']
|
||||
self.shiptype = entry['ShipType'].lower()
|
||||
self.shippaint = None
|
||||
elif entry['event'] in ['ModuleBuy', 'ModuleSell'] and entry['Slot'] == 'PaintJob':
|
||||
symbol = re.match('\$(.+)_name;', entry.get('BuyItem', ''))
|
||||
self.shippaint = symbol and symbol.group(1).lower() or entry.get('BuyItem', '')
|
||||
elif entry['event'] in ['Undocked']:
|
||||
self.station = None
|
||||
elif entry['event'] in ['Location', 'FSDJump', 'Docked']:
|
||||
|
Loading…
x
Reference in New Issue
Block a user