From 1802ffb31c42b4521cf9f910893168ae5ac8a892 Mon Sep 17 00:00:00 2001 From: Jonathan Harris Date: Wed, 12 Apr 2017 01:00:53 +0100 Subject: [PATCH] Handle removal of fuel and cargo capacity from API --- EDMarketConnector.py | 2 -- edshipyard.py | 18 ++++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/EDMarketConnector.py b/EDMarketConnector.py index 9bd9a752..3e1fd784 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -519,8 +519,6 @@ class AppWindow: props = [] else: props = [ - ('cargoCapacity', ship['cargo']['capacity']), - ('fuelMainCapacity', ship['fuel']['main']['capacity']), ('linkToCoriolis', coriolis.url(data)), ('linkToEDShipyard', edshipyard.url(data)), ] diff --git a/edshipyard.py b/edshipyard.py index de764c0f..4bc38af1 100644 --- a/edshipyard.py +++ b/edshipyard.py @@ -62,6 +62,8 @@ def export(data, filename=None): loadout = defaultdict(list) mass = 0.0 + fuel = 0 + cargo = 0 fsd = None for slot in sorted(data['ship']['modules']): @@ -77,7 +79,11 @@ def export(data, filename=None): mass += module.get('mass', 0) # Specials - if 'Fuel Tank'in module['name'] or 'Cargo Rack' in module['name']: + if 'Fuel Tank'in module['name']: + fuel += 2**int(module['class']) + name = '%s (Capacity: %d)' % (module['name'], 2**int(module['class'])) + elif 'Cargo Rack' in module['name']: + cargo += 2**int(module['class']) name = '%s (Capacity: %d)' % (module['name'], 2**int(module['class'])) else: name = module['name'] @@ -109,7 +115,7 @@ def export(data, filename=None): elif slot in loadout: for name in loadout[slot]: string += '%s: %s\n' % (slot, name) - string += '---\nCargo : %d T\nFuel : %d T\n' % (data['ship']['cargo']['capacity'], data['ship']['fuel']['main']['capacity']) + string += '---\nCargo : %d T\nFuel : %d T\n' % (cargo, fuel) # Add mass and range assert data['ship']['name'].lower() in companion.ship_map, data['ship']['name'] @@ -117,11 +123,11 @@ def export(data, filename=None): try: # https://github.com/cmmcleod/coriolis/blob/master/app/js/shipyard/module-shipyard.js#L184 mass += ships[companion.ship_map[data['ship']['name'].lower()]]['hullMass'] - string += 'Mass : %.1f T empty\n %.1f T full\n' % (mass, mass + data['ship']['fuel']['main']['capacity']+ data['ship']['cargo']['capacity']) - multiplier = pow(min(data['ship']['fuel']['main']['capacity'], fsd['maxfuel']) / fsd['fuelmul'], 1.0 / fsd['fuelpower']) * fsd['optmass'] + string += 'Mass : %.1f T empty\n %.1f T full\n' % (mass, mass + fuel + cargo) + multiplier = pow(min(fuel, fsd['maxfuel']) / fsd['fuelmul'], 1.0 / fsd['fuelpower']) * fsd['optmass'] string += 'Range : %.2f LY unladen\n %.2f LY laden\n' % ( - multiplier / (mass + data['ship']['fuel']['main']['capacity']), - multiplier / (mass + data['ship']['fuel']['main']['capacity'] + data['ship']['cargo']['capacity'])) + multiplier / (mass + fuel), + multiplier / (mass + fuel + cargo)) except: if __debug__: raise