Skip to content

Commit

Permalink
[2051] Sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Rixxan committed Nov 17, 2023
1 parent e787555 commit aff0996
Show file tree
Hide file tree
Showing 5 changed files with 362 additions and 444 deletions.
82 changes: 34 additions & 48 deletions coriolis-update-files.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
project structure is used for this purpose. If you want to utilize the
FDevIDs/ version of the file, copy it over the local one.
"""


import json
import subprocess
import sys
Expand All @@ -22,22 +24,16 @@

def add(modules, name, attributes) -> None:
"""Add the given module to the modules dict."""
assert (
name not in modules or modules[name] == attributes
), f"{name}: {modules.get(name)} != {attributes}"
assert name not in modules or modules[name] == attributes, f'{name}: {modules.get(name)} != {attributes}'
assert name not in modules, name
modules[name] = attributes

# Regenerate coriolis-data distribution
subprocess.check_call(
"npm install",
cwd="coriolis-data",
shell=True,
stdout=sys.stdout,
stderr=sys.stderr,
)
subprocess.check_call('npm install', cwd='coriolis-data', shell=True, stdout=sys.stdout, stderr=sys.stderr)

data = json.load(open("coriolis-data/dist/index.json"))
file_path = 'coriolis-data/dist/index.json'
with open(file_path) as file:
data = json.load(file)

# Symbolic name from in-game name
reverse_ship_map = {v: k for k, v in list(ship_name_map.items())}
Expand All @@ -48,58 +44,48 @@ def add(modules, name, attributes) -> None:
modules = {}

# Ship and armour masses
for m in list(data["Ships"].values()):
name = coriolis_ship_map.get(
m["properties"]["name"], str(m["properties"]["name"])
)
for m in list(data['Ships'].values()):
name = coriolis_ship_map.get(m['properties']['name'], str(m['properties']['name']))
assert name in reverse_ship_map, name
ships[name] = {"hullMass": m["properties"]["hullMass"]}
for i in range(len(bulkheads)):
modules["_".join([reverse_ship_map[name], "armour", bulkheads[i]])] = {
"mass": m["bulkheads"][i]["mass"]
}

ships = OrderedDict(
[(k, ships[k]) for k in sorted(ships)]
) # sort for easier diffing
ships[name] = {'hullMass': m['properties']['hullMass']}
for i, bulkhead in enumerate(bulkheads):
modules['_'.join([reverse_ship_map[name], 'armour', bulkhead])] = {'mass': m['bulkheads'][i]['mass']}

ships = OrderedDict([(k, ships[k]) for k in sorted(ships)]) # sort for easier diffing
with open("resources/ships.json", "w") as ships_file:
json.dump(ships, ships_file, indent=4)

# Module masses
for cat in list(data["Modules"].values()):
for cat in list(data['Modules'].values()):
for grp, mlist in list(cat.items()):
for m in mlist:
assert "symbol" in m, m
key = str(m["symbol"].lower())
if grp == "fsd":
assert 'symbol' in m, m
key = str(m['symbol'].lower())
if grp == 'fsd':
modules[key] = {
"mass": m["mass"],
"optmass": m["optmass"],
"maxfuel": m["maxfuel"],
"fuelmul": m["fuelmul"],
"fuelpower": m["fuelpower"],
'mass': m['mass'],
'optmass': m['optmass'],
'maxfuel': m['maxfuel'],
'fuelmul': m['fuelmul'],
'fuelpower': m['fuelpower'],
}
elif grp == "gfsb":
elif grp == 'gfsb':
modules[key] = {
"mass": m["mass"],
"jumpboost": m["jumpboost"],
'mass': m['mass'],
'jumpboost': m['jumpboost'],
}
else:
modules[key] = {
"mass": m.get("mass", 0)
} # Some modules don't have mass
modules[key] = {'mass': m.get('mass', 0)} # Some modules don't have mass

# Pre 3.3 modules
add(modules, "int_stellarbodydiscoveryscanner_standard", {"mass": 2})
add(modules, "int_stellarbodydiscoveryscanner_intermediate", {"mass": 2})
add(modules, "int_stellarbodydiscoveryscanner_advanced", {"mass": 2})
add(modules, 'int_stellarbodydiscoveryscanner_standard', {'mass': 2})
add(modules, 'int_stellarbodydiscoveryscanner_intermediate', {'mass': 2})
add(modules, 'int_stellarbodydiscoveryscanner_advanced', {'mass': 2})

# Missing
add(modules, "hpt_multicannon_fixed_small_advanced", {"mass": 2})
add(modules, "hpt_multicannon_fixed_medium_advanced", {"mass": 4})
add(modules, 'hpt_multicannon_fixed_small_advanced', {'mass': 2})
add(modules, 'hpt_multicannon_fixed_medium_advanced', {'mass': 4})

modules = OrderedDict(
[(k, modules[k]) for k in sorted(modules)]
) # sort for easier diffing
with open("modules.json", "w") as modules_file:
modules = OrderedDict([(k, modules[k]) for k in sorted(modules)]) # sort for easier diffing
with open("resources/modules.json", "w") as modules_file:
json.dump(modules, modules_file, indent=4)
2 changes: 1 addition & 1 deletion docs/Releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ Before you create a new install each time you should:
1. `cd coriolis-data`
2. `git pull`
3. `npm install` - to check it's worked.
3. Run `coriolis-update-files.py` to update `modules.p` and `ships.p`. **NB:
3. Run `coriolis-update-files.py` to update `modules.json` and `ships.json`. **NB:
The submodule might have been updated by a GitHub workflow/PR/merge, so
be sure to perform this step for every build.**
4. XXX: Test ?
Expand Down
Loading

0 comments on commit aff0996

Please sign in to comment.