From 690523c9169a88c90fd5b7073c898e216cd8551d Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Tue, 7 May 2024 16:11:30 -0400 Subject: [PATCH] [2228] Handle Unknown FSD Ranges --- edmc_data.py | 3 ++- edshipyard.py | 22 +++++++++++++--------- outfitting.py | 4 ++-- ships.json | 3 +++ 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/edmc_data.py b/edmc_data.py index d76badc6..e8c9518b 100644 --- a/edmc_data.py +++ b/edmc_data.py @@ -357,7 +357,7 @@ outfitting_standard_map = { 'guardianpowerdistributor': 'Guardian Hybrid Power Distributor', 'guardianpowerplant': 'Guardian Hybrid Power Plant', 'hyperdrive': 'Frame Shift Drive', - ('hyperdrive', 'overcharge'): 'Frame Shift Drive', + ('hyperdrive', 'overcharge'): 'Frame Shift Drive (SCO)', 'lifesupport': 'Life Support', # 'planetapproachsuite': handled separately 'powerdistributor': 'Power Distributor', @@ -501,6 +501,7 @@ ship_name_map = { 'mamba': 'Mamba', 'orca': 'Orca', 'python': 'Python', + 'python_nx': 'Python Mk II', 'scout': 'Taipan Fighter', 'sidewinder': 'Sidewinder', 'testbuggy': 'Scarab', diff --git a/edshipyard.py b/edshipyard.py index 1660ad7e..15936dfc 100644 --- a/edshipyard.py +++ b/edshipyard.py @@ -106,7 +106,7 @@ def export(data, filename=None) -> None: # noqa: C901, CCR001 else: name = module['name'] # type: ignore - if name == 'Frame Shift Drive': + if name == 'Frame Shift Drive' or name == 'Frame Shift Drive (SCO)': fsd = module # save for range calculation if mods.get('OutfittingFieldType_FSDOptimalMass'): @@ -167,15 +167,19 @@ def export(data, filename=None) -> None: # noqa: C901, CCR001 try: mass += ships[ship_name_map[data['ship']['name'].lower()]]['hullMass'] string += f'Mass : {mass:.2f} T empty\n {mass + fuel + cargo:.2f} T full\n' + maxfuel = fsd.get('maxfuel', 0) # type: ignore + fuelmul = fsd.get('fuelmul', 0) # type: ignore - multiplier = pow(min(fuel, fsd['maxfuel']) / fsd['fuelmul'], 1.0 # type: ignore - / fsd['fuelpower']) * fsd['optmass'] # type: ignore - - range_unladen = multiplier / (mass + fuel) + jumpboost - range_laden = multiplier / (mass + fuel + cargo) + jumpboost - # As of 2021-04-07 edsy.org says text import not yet implemented, so ignore the possible issue with - # a locale that uses comma for decimal separator. - string += f'Range : {range_unladen:.2f} LY unladen\n {range_laden:.2f} LY laden\n' + try: + multiplier = pow(min(fuel, maxfuel) / fuelmul, 1.0 / fsd['fuelpower']) * fsd['optmass'] # type: ignore + range_unladen = multiplier / (mass + fuel) + jumpboost + range_laden = multiplier / (mass + fuel + cargo) + jumpboost + # As of 2021-04-07 edsy.org says text import not yet implemented, so ignore the possible issue with + # a locale that uses comma for decimal separator. + except ZeroDivisionError: + range_unladen = range_laden = 0.0 + string += (f'Range : {range_unladen:.2f} LY current without cargo\n' + f' {range_laden:.2f} LY current with cargo\n') except Exception: if __debug__: diff --git a/outfitting.py b/outfitting.py index 5632687c..770c47cd 100644 --- a/outfitting.py +++ b/outfitting.py @@ -222,7 +222,7 @@ def lookup(module, ship_map, entitled=False) -> dict | None: # noqa: C901, CCR0 (new['class'], new['rating']) = (str(name[2][4:]), 'H') elif len(name) > 4 and name[1] == 'hyperdrive': # e.g. Int_Hyperdrive_Overcharge_Size6_Class3 - (new['class'], new['rating']) = (str(name[4][-1:]), 'C') + (new['class'], new['rating']) = (str(name[3][-1:]), rating_map[name[4][-1:]]) else: if len(name) < 3: @@ -257,7 +257,7 @@ def lookup(module, ship_map, entitled=False) -> dict | None: # noqa: C901, CCR0 if not m: print(f'No data for module {key}') - elif new['name'] == 'Frame Shift Drive': + elif new['name'] == 'Frame Shift Drive' or new['name'] == 'Frame Shift Drive (SCO)': assert 'mass' in m and 'optmass' in m and 'maxfuel' in m and 'fuelmul' in m and 'fuelpower' in m, m else: diff --git a/ships.json b/ships.json index 4a40ba4f..65a2989e 100644 --- a/ships.json +++ b/ships.json @@ -89,6 +89,9 @@ "Python": { "hullMass": 350 }, + "Python Mk II": { + "hullMass": 450 + }, "Sidewinder": { "hullMass": 25 },