Skip to content

Commit

Permalink
WebHost: use settings defaults for /api/generate and options -> Singl…
Browse files Browse the repository at this point in the history
…e Player Generate (ArchipelagoMW#3411)
  • Loading branch information
Berserker66 authored and James Schurig committed Jun 13, 2024
1 parent f29601f commit a7f4130
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 27 deletions.
28 changes: 13 additions & 15 deletions WebHostLib/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import tempfile
import zipfile
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 pony.orm import commit, db_session
Expand All @@ -16,32 +16,30 @@
from Main import main as ERmain
from Utils import __version__
from WebHostLib import app
from settings import ServerOptions, GeneratorOptions
from worlds.alttp.EntranceRandomizer import parse_arguments
from .check import get_yaml_data, roll_options
from .models import Generation, STATE_ERROR, STATE_QUEUED, Seed, UUID
from .upload import upload_zip_to_db


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

server_options = {
"hint_cost": int(options_source.get("hint_cost", 10)),
"release_mode": options_source.get("release_mode", "goal"),
"remaining_mode": options_source.get("remaining_mode", "disabled"),
"collect_mode": options_source.get("collect_mode", "disabled"),
"item_cheat": bool(int(options_source.get("item_cheat", 1))),
"hint_cost": int(options_source.get("hint_cost", ServerOptions.hint_cost)),
"release_mode": options_source.get("release_mode", ServerOptions.release_mode),
"remaining_mode": options_source.get("remaining_mode", ServerOptions.remaining_mode),
"collect_mode": options_source.get("collect_mode", ServerOptions.collect_mode),
"item_cheat": bool(int(options_source.get("item_cheat", not ServerOptions.disable_item_cheat))),
"server_password": options_source.get("server_password", None),
}
generator_options = {
"spoiler": int(options_source.get("spoiler", 0)),
"race": race
"spoiler": int(options_source.get("spoiler", GeneratorOptions.spoiler)),
"race": race,
}

if race:
Expand Down
3 changes: 2 additions & 1 deletion WebHostLib/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from Utils import local_path
from worlds.AutoWorld import AutoWorldRegister
from . import app, cache
from .generate import get_meta


def create() -> None:
Expand Down Expand Up @@ -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]:
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:
Expand Down
11 changes: 0 additions & 11 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,17 +643,6 @@ class Spoiler(IntEnum):
PLAYTHROUGH = 2
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):
"""
List of options that can be plando'd. Can be combined, for example "bosses, items"
Expand Down

0 comments on commit a7f4130

Please sign in to comment.