WebHost: use settings defaults for /api/generate and options -> Single Player Generate (#3411)
This commit is contained in:
parent
527559395c
commit
e31a7093de
|
@ -6,7 +6,7 @@ import random
|
||||||
import tempfile
|
import tempfile
|
||||||
import zipfile
|
import zipfile
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
from typing import Any, Dict, List, Optional, Union
|
from typing import Any, Dict, List, Optional, Union, Set
|
||||||
|
|
||||||
from flask import flash, redirect, render_template, request, session, url_for
|
from flask import flash, redirect, render_template, request, session, url_for
|
||||||
from pony.orm import commit, db_session
|
from pony.orm import commit, db_session
|
||||||
|
@ -16,6 +16,7 @@ from Generate import PlandoOptions, handle_name
|
||||||
from Main import main as ERmain
|
from Main import main as ERmain
|
||||||
from Utils import __version__
|
from Utils import __version__
|
||||||
from WebHostLib import app
|
from WebHostLib import app
|
||||||
|
from settings import ServerOptions, GeneratorOptions
|
||||||
from worlds.alttp.EntranceRandomizer import parse_arguments
|
from worlds.alttp.EntranceRandomizer import parse_arguments
|
||||||
from .check import get_yaml_data, roll_options
|
from .check import get_yaml_data, roll_options
|
||||||
from .models import Generation, STATE_ERROR, STATE_QUEUED, Seed, UUID
|
from .models import Generation, STATE_ERROR, STATE_QUEUED, Seed, UUID
|
||||||
|
@ -23,25 +24,22 @@ from .upload import upload_zip_to_db
|
||||||
|
|
||||||
|
|
||||||
def get_meta(options_source: dict, race: bool = False) -> Dict[str, Union[List[str], Dict[str, Any]]]:
|
def get_meta(options_source: dict, race: bool = False) -> Dict[str, Union[List[str], Dict[str, Any]]]:
|
||||||
plando_options = {
|
plando_options: Set[str] = set()
|
||||||
options_source.get("plando_bosses", ""),
|
for substr in ("bosses", "items", "connections", "texts"):
|
||||||
options_source.get("plando_items", ""),
|
if options_source.get(f"plando_{substr}", substr in GeneratorOptions.plando_options):
|
||||||
options_source.get("plando_connections", ""),
|
plando_options.add(substr)
|
||||||
options_source.get("plando_texts", "")
|
|
||||||
}
|
|
||||||
plando_options -= {""}
|
|
||||||
|
|
||||||
server_options = {
|
server_options = {
|
||||||
"hint_cost": int(options_source.get("hint_cost", 10)),
|
"hint_cost": int(options_source.get("hint_cost", ServerOptions.hint_cost)),
|
||||||
"release_mode": options_source.get("release_mode", "goal"),
|
"release_mode": options_source.get("release_mode", ServerOptions.release_mode),
|
||||||
"remaining_mode": options_source.get("remaining_mode", "disabled"),
|
"remaining_mode": options_source.get("remaining_mode", ServerOptions.remaining_mode),
|
||||||
"collect_mode": options_source.get("collect_mode", "disabled"),
|
"collect_mode": options_source.get("collect_mode", ServerOptions.collect_mode),
|
||||||
"item_cheat": bool(int(options_source.get("item_cheat", 1))),
|
"item_cheat": bool(int(options_source.get("item_cheat", not ServerOptions.disable_item_cheat))),
|
||||||
"server_password": options_source.get("server_password", None),
|
"server_password": options_source.get("server_password", None),
|
||||||
}
|
}
|
||||||
generator_options = {
|
generator_options = {
|
||||||
"spoiler": int(options_source.get("spoiler", 0)),
|
"spoiler": int(options_source.get("spoiler", GeneratorOptions.spoiler)),
|
||||||
"race": race
|
"race": race,
|
||||||
}
|
}
|
||||||
|
|
||||||
if race:
|
if race:
|
||||||
|
|
|
@ -11,6 +11,7 @@ import Options
|
||||||
from Utils import local_path
|
from Utils import local_path
|
||||||
from worlds.AutoWorld import AutoWorldRegister
|
from worlds.AutoWorld import AutoWorldRegister
|
||||||
from . import app, cache
|
from . import app, cache
|
||||||
|
from .generate import get_meta
|
||||||
|
|
||||||
|
|
||||||
def create() -> None:
|
def create() -> None:
|
||||||
|
@ -50,7 +51,7 @@ def render_options_page(template: str, world_name: str, is_complex: bool = False
|
||||||
|
|
||||||
def generate_game(options: Dict[str, Union[dict, str]]) -> Union[Response, str]:
|
def generate_game(options: Dict[str, Union[dict, str]]) -> Union[Response, str]:
|
||||||
from .generate import start_generation
|
from .generate import start_generation
|
||||||
return start_generation(options, {"plando_options": ["items", "connections", "texts", "bosses"]})
|
return start_generation(options, get_meta({}))
|
||||||
|
|
||||||
|
|
||||||
def send_yaml(player_name: str, formatted_options: dict) -> Response:
|
def send_yaml(player_name: str, formatted_options: dict) -> Response:
|
||||||
|
|
11
settings.py
11
settings.py
|
@ -643,17 +643,6 @@ class GeneratorOptions(Group):
|
||||||
PLAYTHROUGH = 2
|
PLAYTHROUGH = 2
|
||||||
FULL = 3
|
FULL = 3
|
||||||
|
|
||||||
class GlitchTriforceRoom(IntEnum):
|
|
||||||
"""
|
|
||||||
Glitch to Triforce room from Ganon
|
|
||||||
When disabled, you have to have a weapon that can hurt ganon (master sword or swordless/easy item functionality
|
|
||||||
+ hammer) and have completed the goal required for killing ganon to be able to access the triforce room.
|
|
||||||
1 -> Enabled.
|
|
||||||
0 -> Disabled (except in no-logic)
|
|
||||||
"""
|
|
||||||
OFF = 0
|
|
||||||
ON = 1
|
|
||||||
|
|
||||||
class PlandoOptions(str):
|
class PlandoOptions(str):
|
||||||
"""
|
"""
|
||||||
List of options that can be plando'd. Can be combined, for example "bosses, items"
|
List of options that can be plando'd. Can be combined, for example "bosses, items"
|
||||||
|
|
Loading…
Reference in New Issue