Skip to content

Commit c163a9f

Browse files
Berserker66qwint
authored andcommitted
WebHost: use settings defaults for /api/generate and options -> Single Player Generate (ArchipelagoMW#3411)
1 parent 0a6b144 commit c163a9f

File tree

3 files changed

+15
-27
lines changed

3 files changed

+15
-27
lines changed

WebHostLib/generate.py

+13-15
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import tempfile
77
import zipfile
88
from collections import Counter
9-
from typing import Any, Dict, List, Optional, Union
9+
from typing import Any, Dict, List, Optional, Union, Set
1010

1111
from flask import flash, redirect, render_template, request, session, url_for
1212
from pony.orm import commit, db_session
@@ -16,32 +16,30 @@
1616
from Main import main as ERmain
1717
from Utils import __version__
1818
from WebHostLib import app
19+
from settings import ServerOptions, GeneratorOptions
1920
from worlds.alttp.EntranceRandomizer import parse_arguments
2021
from .check import get_yaml_data, roll_options
2122
from .models import Generation, STATE_ERROR, STATE_QUEUED, Seed, UUID
2223
from .upload import upload_zip_to_db
2324

2425

2526
def get_meta(options_source: dict, race: bool = False) -> Dict[str, Union[List[str], Dict[str, Any]]]:
26-
plando_options = {
27-
options_source.get("plando_bosses", ""),
28-
options_source.get("plando_items", ""),
29-
options_source.get("plando_connections", ""),
30-
options_source.get("plando_texts", "")
31-
}
32-
plando_options -= {""}
27+
plando_options: Set[str] = set()
28+
for substr in ("bosses", "items", "connections", "texts"):
29+
if options_source.get(f"plando_{substr}", substr in GeneratorOptions.plando_options):
30+
plando_options.add(substr)
3331

3432
server_options = {
35-
"hint_cost": int(options_source.get("hint_cost", 10)),
36-
"release_mode": options_source.get("release_mode", "goal"),
37-
"remaining_mode": options_source.get("remaining_mode", "disabled"),
38-
"collect_mode": options_source.get("collect_mode", "disabled"),
39-
"item_cheat": bool(int(options_source.get("item_cheat", 1))),
33+
"hint_cost": int(options_source.get("hint_cost", ServerOptions.hint_cost)),
34+
"release_mode": options_source.get("release_mode", ServerOptions.release_mode),
35+
"remaining_mode": options_source.get("remaining_mode", ServerOptions.remaining_mode),
36+
"collect_mode": options_source.get("collect_mode", ServerOptions.collect_mode),
37+
"item_cheat": bool(int(options_source.get("item_cheat", not ServerOptions.disable_item_cheat))),
4038
"server_password": options_source.get("server_password", None),
4139
}
4240
generator_options = {
43-
"spoiler": int(options_source.get("spoiler", 0)),
44-
"race": race
41+
"spoiler": int(options_source.get("spoiler", GeneratorOptions.spoiler)),
42+
"race": race,
4543
}
4644

4745
if race:

WebHostLib/options.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from Utils import local_path
1212
from worlds.AutoWorld import AutoWorldRegister
1313
from . import app, cache
14+
from .generate import get_meta
1415

1516

1617
def create() -> None:
@@ -50,7 +51,7 @@ def render_options_page(template: str, world_name: str, is_complex: bool = False
5051

5152
def generate_game(options: Dict[str, Union[dict, str]]) -> Union[Response, str]:
5253
from .generate import start_generation
53-
return start_generation(options, {"plando_options": ["items", "connections", "texts", "bosses"]})
54+
return start_generation(options, get_meta({}))
5455

5556

5657
def send_yaml(player_name: str, formatted_options: dict) -> Response:

settings.py

-11
Original file line numberDiff line numberDiff line change
@@ -643,17 +643,6 @@ class Spoiler(IntEnum):
643643
PLAYTHROUGH = 2
644644
FULL = 3
645645

646-
class GlitchTriforceRoom(IntEnum):
647-
"""
648-
Glitch to Triforce room from Ganon
649-
When disabled, you have to have a weapon that can hurt ganon (master sword or swordless/easy item functionality
650-
+ hammer) and have completed the goal required for killing ganon to be able to access the triforce room.
651-
1 -> Enabled.
652-
0 -> Disabled (except in no-logic)
653-
"""
654-
OFF = 0
655-
ON = 1
656-
657646
class PlandoOptions(str):
658647
"""
659648
List of options that can be plando'd. Can be combined, for example "bosses, items"

0 commit comments

Comments
 (0)