Webhost race support as a non-breaking change
This commit is contained in:
parent
5f535012f3
commit
aab3a3496a
|
@ -37,9 +37,10 @@ def download_raw_patch(seed_id, player_id):
|
|||
return "Patch not found"
|
||||
else:
|
||||
import io
|
||||
|
||||
pname = patch.seed.multidata["names"][0][patch.player - 1]
|
||||
|
||||
if patch.seed.multidata:
|
||||
pname = patch.seed.multidata["names"][0][patch.player - 1]
|
||||
else:
|
||||
pname = "unknown"
|
||||
patch_data = update_patch_data(patch.data, server="")
|
||||
patch_data = io.BytesIO(patch_data)
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ def gen_game(gen_options, race=False, owner=None, sid=None):
|
|||
del (erargs.progression_balancing)
|
||||
ERmain(erargs, seed)
|
||||
|
||||
return upload_to_db(target.name, owner, sid)
|
||||
return upload_to_db(target.name, owner, sid, race)
|
||||
except BaseException:
|
||||
if sid:
|
||||
with db_session:
|
||||
|
@ -181,9 +181,10 @@ def wait_seed_api(seed: UUID):
|
|||
return {"text": "Generation running"}, 202
|
||||
|
||||
|
||||
def upload_to_db(folder, owner, sid):
|
||||
def upload_to_db(folder, owner, sid, race:bool):
|
||||
patches = set()
|
||||
spoiler = ""
|
||||
|
||||
multidata = None
|
||||
for file in os.listdir(folder):
|
||||
file = os.path.join(folder, file)
|
||||
|
@ -193,20 +194,26 @@ def upload_to_db(folder, owner, sid):
|
|||
elif file.endswith(".txt"):
|
||||
spoiler = open(file, "rt").read()
|
||||
elif file.endswith("multidata"):
|
||||
try:
|
||||
multidata = json.loads(zlib.decompress(open(file, "rb").read()))
|
||||
except Exception as e:
|
||||
flash(e)
|
||||
if multidata:
|
||||
with db_session:
|
||||
if sid:
|
||||
seed = Seed(multidata=multidata, spoiler=spoiler, patches=patches, owner=owner, id=sid)
|
||||
else:
|
||||
seed = Seed(multidata=multidata, spoiler=spoiler, patches=patches, owner=owner)
|
||||
for patch in patches:
|
||||
patch.seed = seed
|
||||
if sid:
|
||||
gen = Generation.get(id=sid)
|
||||
if gen is not None:
|
||||
gen.delete()
|
||||
return seed.id
|
||||
multidata = file
|
||||
|
||||
if not race or len(patches) > 1:
|
||||
try:
|
||||
multidata = json.loads(zlib.decompress(open(multidata, "rb").read()))
|
||||
except Exception as e:
|
||||
flash(e)
|
||||
raise e
|
||||
else:
|
||||
multidata = {}
|
||||
|
||||
with db_session:
|
||||
if sid:
|
||||
seed = Seed(multidata=multidata, spoiler=spoiler, patches=patches, owner=owner, id=sid)
|
||||
else:
|
||||
seed = Seed(multidata=multidata, spoiler=spoiler, patches=patches, owner=owner)
|
||||
for patch in patches:
|
||||
patch.seed = seed
|
||||
if sid:
|
||||
gen = Generation.get(id=sid)
|
||||
if gen is not None:
|
||||
gen.delete()
|
||||
return seed.id
|
||||
|
|
|
@ -19,10 +19,10 @@
|
|||
You can also upload a .zip with multiple YAMLs.
|
||||
A proper menu is in the works.
|
||||
{% if race -%}
|
||||
Race Mode means the spoiler log will be unavailable.
|
||||
Race Mode means the spoiler log will be unavailable, roms will be encrypted and single-player has no multidata.
|
||||
{%- else -%}
|
||||
You can go to <a href="{{ url_for("generate", race=True) }}">Race Mode</a> to create a game without
|
||||
spoiler log.
|
||||
spoiler log and with encryption.
|
||||
{%- endif -%}
|
||||
</p>
|
||||
<p>
|
||||
|
|
|
@ -11,6 +11,11 @@
|
|||
<div id="view-seed-wrapper">
|
||||
<div class="main-content">
|
||||
<h3>Seed Info</h3>
|
||||
{% if not seed.multidata and not seed.spoiler %}
|
||||
<h4>
|
||||
Single Player Race Rom: No spoiler or multidata exists, parts of the rom are encrypted and rooms cannot be created.
|
||||
</h4>
|
||||
{% endif %}
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
|
@ -27,6 +32,7 @@
|
|||
<td><a href="{{ url_for("download_spoiler", seed_id=seed.id) }}">Download</a></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if seed.multidata %}
|
||||
<tr>
|
||||
<td>Players: </td>
|
||||
<td>
|
||||
|
@ -55,6 +61,23 @@
|
|||
{% endcall %}
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td>Patches: </td>
|
||||
<td>
|
||||
<ul>
|
||||
{% for patch in seed.patches %}
|
||||
|
||||
<li>
|
||||
<a href="{{ url_for("download_raw_patch", seed_id=seed.id, player_id=patch.player) }}">Player {{ patch.player }}</a>
|
||||
</li>
|
||||
|
||||
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue