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"]
|
race = multi_mystery_options["race"]
|
||||||
create_spoiler = multi_mystery_options["create_spoiler"]
|
create_spoiler = multi_mystery_options["create_spoiler"]
|
||||||
zip_roms = multi_mystery_options["zip_roms"]
|
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"]
|
player_name = multi_mystery_options["player_name"]
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,7 +80,7 @@ if __name__ == "__main__":
|
||||||
import time
|
import time
|
||||||
start = time.perf_counter()
|
start = time.perf_counter()
|
||||||
text = subprocess.check_output(command, shell=True).decode()
|
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 = ""
|
seedname = ""
|
||||||
|
|
||||||
for segment in text.split():
|
for segment in text.split():
|
||||||
|
@ -87,8 +89,9 @@ if __name__ == "__main__":
|
||||||
break
|
break
|
||||||
|
|
||||||
multidataname = f"ER_{seedname}_multidata"
|
multidataname = f"ER_{seedname}_multidata"
|
||||||
|
spoilername = f"ER_{seedname}_Spoiler.txt"
|
||||||
romfilename = ""
|
romfilename = ""
|
||||||
|
|
||||||
if player_name:
|
if player_name:
|
||||||
for file in os.listdir(output_path):
|
for file in os.listdir(output_path):
|
||||||
if player_name in file:
|
if player_name in file:
|
||||||
|
@ -99,28 +102,45 @@ if __name__ == "__main__":
|
||||||
webbrowser.open(romfilename)
|
webbrowser.open(romfilename)
|
||||||
break
|
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")
|
zipname = os.path.join(output_path, f"ER_{seedname}.zip")
|
||||||
print(f"Creating zipfile {zipname}")
|
print(f"Creating zipfile {zipname}")
|
||||||
import zipfile
|
|
||||||
with zipfile.ZipFile(zipname, "w", compression=zipfile.ZIP_DEFLATED, compresslevel=9) as zf:
|
with zipfile.ZipFile(zipname, "w", compression=zipfile.ZIP_DEFLATED, compresslevel=9) as zf:
|
||||||
for file in os.listdir(output_path):
|
for file in os.listdir(output_path):
|
||||||
if file.endswith(".sfc") and seedname in file:
|
if zip_roms and file.endswith(".sfc") and seedname in file:
|
||||||
zf.write(os.path.join(output_path, file), file)
|
pack_file(file)
|
||||||
print(f"Packed {file} into zipfile {zipname}")
|
|
||||||
if zip_roms == 2 and player_name.lower() not in file.lower():
|
if zip_roms == 2 and player_name.lower() not in file.lower():
|
||||||
os.remove(file)
|
remove_zipped_file(file)
|
||||||
print(f"Removed file {file} that is now present in the zipfile")
|
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"):
|
if os.path.exists(os.path.join(output_path, multidataname)):
|
||||||
baseservercommand = "BerserkerMultiServer.exe" # compiled windows
|
if os.path.exists("BerserkerMultiServer.exe"):
|
||||||
elif os.path.exists("BerserkerMultiServer"):
|
baseservercommand = "BerserkerMultiServer.exe" # compiled windows
|
||||||
baseservercommand = "BerserkerMultiServer" # compiled linux
|
elif os.path.exists("BerserkerMultiServer"):
|
||||||
else:
|
baseservercommand = "BerserkerMultiServer" # compiled linux
|
||||||
baseservercommand = f"py -{py_version} MultiServer.py" # source
|
else:
|
||||||
#don't have a mac to test that. If you try to run compiled on mac, good luck.
|
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:
|
except:
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
|
@ -26,12 +26,16 @@ multi_mystery_options:
|
||||||
#does nothing if the name is not found
|
#does nothing if the name is not found
|
||||||
#example: player_name = "Berserker"
|
#example: player_name = "Berserker"
|
||||||
player_name: "" # the hosts name
|
player_name: "" # the hosts name
|
||||||
|
#create a spoiler file
|
||||||
|
create_spoiler: 1
|
||||||
#Zip the resulting roms
|
#Zip the resulting roms
|
||||||
#0 -> Don't
|
#0 -> Don't
|
||||||
#1 -> Create a zip
|
#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)
|
#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
|
zip_roms: 1
|
||||||
#create a spoiler file
|
#include the spoiler log in the zip, 2 -> delete the non-zipped one
|
||||||
create_spoiler: 1
|
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
|
#create roms flagged as race roms
|
||||||
race: 0
|
race: 0
|
Loading…
Reference in New Issue