add zip_spoiler and zip_multidata
This commit is contained in:
parent
18911a1490
commit
e50b9e5ee2
|
@ -37,6 +37,8 @@ if __name__ == "__main__":
|
|||
race = multi_mystery_options["race"]
|
||||
create_spoiler = multi_mystery_options["create_spoiler"]
|
||||
zip_roms = multi_mystery_options["zip_roms"]
|
||||
zip_spoiler = multi_mystery_options["zip_spoiler"]
|
||||
zip_multidata = multi_mystery_options["zip_multidata"]
|
||||
player_name = multi_mystery_options["player_name"]
|
||||
|
||||
|
||||
|
@ -78,7 +80,7 @@ if __name__ == "__main__":
|
|||
import time
|
||||
start = time.perf_counter()
|
||||
text = subprocess.check_output(command, shell=True).decode()
|
||||
print(f"Took {time.perf_counter()-start:.3f} seconds to generate seed.")
|
||||
print(f"Took {time.perf_counter()-start:.3f} seconds to generate rom(s).")
|
||||
seedname = ""
|
||||
|
||||
for segment in text.split():
|
||||
|
@ -87,8 +89,9 @@ if __name__ == "__main__":
|
|||
break
|
||||
|
||||
multidataname = f"ER_{seedname}_multidata"
|
||||
|
||||
spoilername = f"ER_{seedname}_Spoiler.txt"
|
||||
romfilename = ""
|
||||
|
||||
if player_name:
|
||||
for file in os.listdir(output_path):
|
||||
if player_name in file:
|
||||
|
@ -99,28 +102,45 @@ if __name__ == "__main__":
|
|||
webbrowser.open(romfilename)
|
||||
break
|
||||
|
||||
if zip_roms:
|
||||
if any((zip_roms, zip_multidata, zip_spoiler)):
|
||||
import zipfile
|
||||
|
||||
def pack_file(file: str):
|
||||
zf.write(os.path.join(output_path, file), file)
|
||||
print(f"Packed {file} into zipfile {zipname}")
|
||||
|
||||
def remove_zipped_file(file: str):
|
||||
os.remove(os.path.join(output_path, file))
|
||||
print(f"Removed {file} which is now present in the zipfile")
|
||||
|
||||
zipname = os.path.join(output_path, f"ER_{seedname}.zip")
|
||||
print(f"Creating zipfile {zipname}")
|
||||
import zipfile
|
||||
|
||||
with zipfile.ZipFile(zipname, "w", compression=zipfile.ZIP_DEFLATED, compresslevel=9) as zf:
|
||||
for file in os.listdir(output_path):
|
||||
if file.endswith(".sfc") and seedname in file:
|
||||
zf.write(os.path.join(output_path, file), file)
|
||||
print(f"Packed {file} into zipfile {zipname}")
|
||||
if zip_roms and file.endswith(".sfc") and seedname in file:
|
||||
pack_file(file)
|
||||
if zip_roms == 2 and player_name.lower() not in file.lower():
|
||||
os.remove(file)
|
||||
print(f"Removed file {file} that is now present in the zipfile")
|
||||
remove_zipped_file(file)
|
||||
if zip_multidata and os.path.exists(os.path.join(output_path, multidataname)):
|
||||
pack_file(multidataname)
|
||||
if zip_multidata == 2:
|
||||
remove_zipped_file(multidataname)
|
||||
if zip_spoiler and create_spoiler:
|
||||
pack_file(spoilername)
|
||||
if zip_spoiler == 2:
|
||||
remove_zipped_file(spoilername)
|
||||
|
||||
if os.path.exists("BerserkerMultiServer.exe"):
|
||||
baseservercommand = "BerserkerMultiServer.exe" # compiled windows
|
||||
elif os.path.exists("BerserkerMultiServer"):
|
||||
baseservercommand = "BerserkerMultiServer" # compiled linux
|
||||
else:
|
||||
baseservercommand = f"py -{py_version} MultiServer.py" # source
|
||||
#don't have a mac to test that. If you try to run compiled on mac, good luck.
|
||||
if os.path.exists(os.path.join(output_path, multidataname)):
|
||||
if os.path.exists("BerserkerMultiServer.exe"):
|
||||
baseservercommand = "BerserkerMultiServer.exe" # compiled windows
|
||||
elif os.path.exists("BerserkerMultiServer"):
|
||||
baseservercommand = "BerserkerMultiServer" # compiled linux
|
||||
else:
|
||||
baseservercommand = f"py -{py_version} MultiServer.py" # source
|
||||
#don't have a mac to test that. If you try to run compiled on mac, good luck.
|
||||
|
||||
subprocess.call(f"{baseservercommand} --multidata {os.path.join(output_path, multidataname)}")
|
||||
subprocess.call(f"{baseservercommand} --multidata {os.path.join(output_path, multidataname)}")
|
||||
except:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
|
|
@ -26,12 +26,16 @@ multi_mystery_options:
|
|||
#does nothing if the name is not found
|
||||
#example: player_name = "Berserker"
|
||||
player_name: "" # the hosts name
|
||||
#create a spoiler file
|
||||
create_spoiler: 1
|
||||
#Zip the resulting roms
|
||||
#0 -> Don't
|
||||
#1 -> Create a zip
|
||||
#2 -> Create a zip and delete the ROMs that will be in it, except the hosts (requires player_name to be set correctly)
|
||||
zip_roms: 1
|
||||
#create a spoiler file
|
||||
create_spoiler: 1
|
||||
#include the spoiler log in the zip, 2 -> delete the non-zipped one
|
||||
zip_spoiler: 0
|
||||
#include the multidata file in the zip, 2 -> delete the non-zipped one, which also means the server won't autostart
|
||||
zip_multidata: 0
|
||||
#create roms flagged as race roms
|
||||
race: 0
|
Loading…
Reference in New Issue