mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-06-02 08:31:16 +03:00
Handle removal of fuel and cargo capacity from API
This commit is contained in:
parent
01de54859e
commit
1802ffb31c
@ -519,8 +519,6 @@ class AppWindow:
|
|||||||
props = []
|
props = []
|
||||||
else:
|
else:
|
||||||
props = [
|
props = [
|
||||||
('cargoCapacity', ship['cargo']['capacity']),
|
|
||||||
('fuelMainCapacity', ship['fuel']['main']['capacity']),
|
|
||||||
('linkToCoriolis', coriolis.url(data)),
|
('linkToCoriolis', coriolis.url(data)),
|
||||||
('linkToEDShipyard', edshipyard.url(data)),
|
('linkToEDShipyard', edshipyard.url(data)),
|
||||||
]
|
]
|
||||||
|
@ -62,6 +62,8 @@ def export(data, filename=None):
|
|||||||
|
|
||||||
loadout = defaultdict(list)
|
loadout = defaultdict(list)
|
||||||
mass = 0.0
|
mass = 0.0
|
||||||
|
fuel = 0
|
||||||
|
cargo = 0
|
||||||
fsd = None
|
fsd = None
|
||||||
|
|
||||||
for slot in sorted(data['ship']['modules']):
|
for slot in sorted(data['ship']['modules']):
|
||||||
@ -77,7 +79,11 @@ def export(data, filename=None):
|
|||||||
mass += module.get('mass', 0)
|
mass += module.get('mass', 0)
|
||||||
|
|
||||||
# Specials
|
# 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']))
|
name = '%s (Capacity: %d)' % (module['name'], 2**int(module['class']))
|
||||||
else:
|
else:
|
||||||
name = module['name']
|
name = module['name']
|
||||||
@ -109,7 +115,7 @@ def export(data, filename=None):
|
|||||||
elif slot in loadout:
|
elif slot in loadout:
|
||||||
for name in loadout[slot]:
|
for name in loadout[slot]:
|
||||||
string += '%s: %s\n' % (slot, name)
|
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
|
# Add mass and range
|
||||||
assert data['ship']['name'].lower() in companion.ship_map, data['ship']['name']
|
assert data['ship']['name'].lower() in companion.ship_map, data['ship']['name']
|
||||||
@ -117,11 +123,11 @@ def export(data, filename=None):
|
|||||||
try:
|
try:
|
||||||
# https://github.com/cmmcleod/coriolis/blob/master/app/js/shipyard/module-shipyard.js#L184
|
# https://github.com/cmmcleod/coriolis/blob/master/app/js/shipyard/module-shipyard.js#L184
|
||||||
mass += ships[companion.ship_map[data['ship']['name'].lower()]]['hullMass']
|
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'])
|
string += 'Mass : %.1f T empty\n %.1f T full\n' % (mass, mass + fuel + cargo)
|
||||||
multiplier = pow(min(data['ship']['fuel']['main']['capacity'], fsd['maxfuel']) / fsd['fuelmul'], 1.0 / fsd['fuelpower']) * fsd['optmass']
|
multiplier = pow(min(fuel, fsd['maxfuel']) / fsd['fuelmul'], 1.0 / fsd['fuelpower']) * fsd['optmass']
|
||||||
string += 'Range : %.2f LY unladen\n %.2f LY laden\n' % (
|
string += 'Range : %.2f LY unladen\n %.2f LY laden\n' % (
|
||||||
multiplier / (mass + data['ship']['fuel']['main']['capacity']),
|
multiplier / (mass + fuel),
|
||||||
multiplier / (mass + data['ship']['fuel']['main']['capacity'] + data['ship']['cargo']['capacity']))
|
multiplier / (mass + fuel + cargo))
|
||||||
except:
|
except:
|
||||||
if __debug__: raise
|
if __debug__: raise
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user