core: write the plando settings to the spoiler log (#1248)
Co-authored-by: Zach Parks <zach@alliware.com>
This commit is contained in:
parent
e96602d31b
commit
dd3ae5ecbd
|
@ -1,20 +1,20 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
from argparse import Namespace
|
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
from enum import unique, IntEnum, IntFlag
|
|
||||||
import logging
|
|
||||||
import json
|
|
||||||
import functools
|
import functools
|
||||||
from collections import OrderedDict, Counter, deque
|
import json
|
||||||
from typing import List, Dict, Optional, Set, Iterable, Union, Any, Tuple, TypedDict, Callable, NamedTuple
|
import logging
|
||||||
import typing # this can go away when Python 3.8 support is dropped
|
|
||||||
import secrets
|
|
||||||
import random
|
import random
|
||||||
|
import secrets
|
||||||
|
import typing # this can go away when Python 3.8 support is dropped
|
||||||
|
from argparse import Namespace
|
||||||
|
from collections import OrderedDict, Counter, deque
|
||||||
|
from enum import unique, IntEnum, IntFlag
|
||||||
|
from typing import List, Dict, Optional, Set, Iterable, Union, Any, Tuple, TypedDict, Callable, NamedTuple
|
||||||
|
|
||||||
|
import NetUtils
|
||||||
import Options
|
import Options
|
||||||
import Utils
|
import Utils
|
||||||
import NetUtils
|
|
||||||
|
|
||||||
|
|
||||||
class Group(TypedDict, total=False):
|
class Group(TypedDict, total=False):
|
||||||
|
@ -48,6 +48,7 @@ class MultiWorld():
|
||||||
precollected_items: Dict[int, List[Item]]
|
precollected_items: Dict[int, List[Item]]
|
||||||
state: CollectionState
|
state: CollectionState
|
||||||
|
|
||||||
|
plando_settings: PlandoSettings
|
||||||
accessibility: Dict[int, Options.Accessibility]
|
accessibility: Dict[int, Options.Accessibility]
|
||||||
early_items: Dict[int, Dict[str, int]]
|
early_items: Dict[int, Dict[str, int]]
|
||||||
local_early_items: Dict[int, Dict[str, int]]
|
local_early_items: Dict[int, Dict[str, int]]
|
||||||
|
@ -160,6 +161,7 @@ class MultiWorld():
|
||||||
self.custom_data = {}
|
self.custom_data = {}
|
||||||
self.worlds = {}
|
self.worlds = {}
|
||||||
self.slot_seeds = {}
|
self.slot_seeds = {}
|
||||||
|
self.plando_settings = PlandoSettings.none
|
||||||
|
|
||||||
def get_all_ids(self) -> Tuple[int, ...]:
|
def get_all_ids(self) -> Tuple[int, ...]:
|
||||||
return self.player_ids + tuple(self.groups)
|
return self.player_ids + tuple(self.groups)
|
||||||
|
@ -1558,6 +1560,7 @@ class Spoiler():
|
||||||
Utils.__version__, self.multiworld.seed))
|
Utils.__version__, self.multiworld.seed))
|
||||||
outfile.write('Filling Algorithm: %s\n' % self.multiworld.algorithm)
|
outfile.write('Filling Algorithm: %s\n' % self.multiworld.algorithm)
|
||||||
outfile.write('Players: %d\n' % self.multiworld.players)
|
outfile.write('Players: %d\n' % self.multiworld.players)
|
||||||
|
outfile.write(f'Plando Options: {self.multiworld.plando_settings}\n')
|
||||||
AutoWorld.call_stage(self.multiworld, "write_spoiler_header", outfile)
|
AutoWorld.call_stage(self.multiworld, "write_spoiler_header", outfile)
|
||||||
|
|
||||||
for player in range(1, self.multiworld.players + 1):
|
for player in range(1, self.multiworld.players + 1):
|
||||||
|
@ -1674,6 +1677,45 @@ class Tutorial(NamedTuple):
|
||||||
authors: List[str]
|
authors: List[str]
|
||||||
|
|
||||||
|
|
||||||
|
class PlandoSettings(IntFlag):
|
||||||
|
none = 0b0000
|
||||||
|
items = 0b0001
|
||||||
|
connections = 0b0010
|
||||||
|
texts = 0b0100
|
||||||
|
bosses = 0b1000
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_option_string(cls, option_string: str) -> PlandoSettings:
|
||||||
|
result = cls(0)
|
||||||
|
for part in option_string.split(","):
|
||||||
|
part = part.strip().lower()
|
||||||
|
if part:
|
||||||
|
result = cls._handle_part(part, result)
|
||||||
|
return result
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_set(cls, option_set: Set[str]) -> PlandoSettings:
|
||||||
|
result = cls(0)
|
||||||
|
for part in option_set:
|
||||||
|
result = cls._handle_part(part, result)
|
||||||
|
return result
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _handle_part(cls, part: str, base: PlandoSettings) -> PlandoSettings:
|
||||||
|
try:
|
||||||
|
part = cls[part]
|
||||||
|
except Exception as e:
|
||||||
|
raise KeyError(f"{part} is not a recognized name for a plando module. "
|
||||||
|
f"Known options: {', '.join(flag.name for flag in cls)}") from e
|
||||||
|
else:
|
||||||
|
return base | part
|
||||||
|
|
||||||
|
def __str__(self) -> str:
|
||||||
|
if self.value:
|
||||||
|
return ", ".join(flag.name for flag in PlandoSettings if self.value & flag.value)
|
||||||
|
return "None"
|
||||||
|
|
||||||
|
|
||||||
seeddigits = 20
|
seeddigits = 20
|
||||||
|
|
||||||
|
|
||||||
|
|
53
Generate.py
53
Generate.py
|
@ -2,14 +2,13 @@ from __future__ import annotations
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
import random
|
|
||||||
import urllib.request
|
|
||||||
import urllib.parse
|
|
||||||
from typing import Set, Dict, Tuple, Callable, Any, Union
|
|
||||||
import os
|
import os
|
||||||
from collections import Counter, ChainMap
|
import random
|
||||||
import string
|
import string
|
||||||
import enum
|
import urllib.parse
|
||||||
|
import urllib.request
|
||||||
|
from collections import Counter, ChainMap
|
||||||
|
from typing import Dict, Tuple, Callable, Any, Union
|
||||||
|
|
||||||
import ModuleUpdate
|
import ModuleUpdate
|
||||||
|
|
||||||
|
@ -18,52 +17,17 @@ ModuleUpdate.update()
|
||||||
import Utils
|
import Utils
|
||||||
from worlds.alttp import Options as LttPOptions
|
from worlds.alttp import Options as LttPOptions
|
||||||
from worlds.generic import PlandoConnection
|
from worlds.generic import PlandoConnection
|
||||||
from Utils import parse_yamls, version_tuple, __version__, tuplize_version, get_options, local_path, user_path
|
from Utils import parse_yamls, version_tuple, __version__, tuplize_version, get_options, user_path
|
||||||
from worlds.alttp.EntranceRandomizer import parse_arguments
|
from worlds.alttp.EntranceRandomizer import parse_arguments
|
||||||
from Main import main as ERmain
|
from Main import main as ERmain
|
||||||
from BaseClasses import seeddigits, get_seed
|
from BaseClasses import seeddigits, get_seed, PlandoSettings
|
||||||
import Options
|
import Options
|
||||||
from worlds.alttp.Text import TextTable
|
from worlds.alttp.Text import TextTable
|
||||||
from worlds.AutoWorld import AutoWorldRegister
|
from worlds.AutoWorld import AutoWorldRegister
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
|
|
||||||
class PlandoSettings(enum.IntFlag):
|
|
||||||
items = 0b0001
|
|
||||||
connections = 0b0010
|
|
||||||
texts = 0b0100
|
|
||||||
bosses = 0b1000
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def from_option_string(cls, option_string: str) -> PlandoSettings:
|
|
||||||
result = cls(0)
|
|
||||||
for part in option_string.split(","):
|
|
||||||
part = part.strip().lower()
|
|
||||||
if part:
|
|
||||||
result = cls._handle_part(part, result)
|
|
||||||
return result
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def from_set(cls, option_set: Set[str]) -> PlandoSettings:
|
|
||||||
result = cls(0)
|
|
||||||
for part in option_set:
|
|
||||||
result = cls._handle_part(part, result)
|
|
||||||
return result
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def _handle_part(cls, part: str, base: PlandoSettings) -> PlandoSettings:
|
|
||||||
try:
|
|
||||||
part = cls[part]
|
|
||||||
except Exception as e:
|
|
||||||
raise KeyError(f"{part} is not a recognized name for a plando module. "
|
|
||||||
f"Known options: {', '.join(flag.name for flag in cls)}") from e
|
|
||||||
else:
|
|
||||||
return base | part
|
|
||||||
|
|
||||||
def __str__(self) -> str:
|
|
||||||
if self.value:
|
|
||||||
return ", ".join(flag.name for flag in PlandoSettings if self.value & flag.value)
|
|
||||||
return "Off"
|
|
||||||
|
|
||||||
|
|
||||||
def mystery_argparse():
|
def mystery_argparse():
|
||||||
|
@ -170,6 +134,7 @@ def main(args=None, callback=ERmain):
|
||||||
f"A mix is also permitted.")
|
f"A mix is also permitted.")
|
||||||
erargs = parse_arguments(['--multi', str(args.multi)])
|
erargs = parse_arguments(['--multi', str(args.multi)])
|
||||||
erargs.seed = seed
|
erargs.seed = seed
|
||||||
|
erargs.plando_settings = args.plando
|
||||||
erargs.glitch_triforce = options["generator"]["glitch_triforce_room"]
|
erargs.glitch_triforce = options["generator"]["glitch_triforce_room"]
|
||||||
erargs.spoiler = args.spoiler
|
erargs.spoiler = args.spoiler
|
||||||
erargs.race = args.race
|
erargs.race = args.race
|
||||||
|
@ -226,7 +191,7 @@ def main(args=None, callback=ERmain):
|
||||||
elif not erargs.name[player]: # if name was not specified, generate it from filename
|
elif not erargs.name[player]: # if name was not specified, generate it from filename
|
||||||
erargs.name[player] = os.path.splitext(os.path.split(path)[-1])[0]
|
erargs.name[player] = os.path.splitext(os.path.split(path)[-1])[0]
|
||||||
erargs.name[player] = handle_name(erargs.name[player], player, name_counter)
|
erargs.name[player] = handle_name(erargs.name[player], player, name_counter)
|
||||||
|
|
||||||
player += 1
|
player += 1
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise ValueError(f"File {path} is destroyed. Please fix your yaml.") from e
|
raise ValueError(f"File {path} is destroyed. Please fix your yaml.") from e
|
||||||
|
|
1
Main.py
1
Main.py
|
@ -38,6 +38,7 @@ def main(args, seed=None, baked_server_options: Optional[Dict[str, object]] = No
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
world.set_seed(seed, args.race, str(args.outputname if args.outputname else world.seed))
|
world.set_seed(seed, args.race, str(args.outputname if args.outputname else world.seed))
|
||||||
|
world.plando_settings = args.plando_settings
|
||||||
|
|
||||||
world.shuffle = args.shuffle.copy()
|
world.shuffle = args.shuffle.copy()
|
||||||
world.logic = args.logic.copy()
|
world.logic = args.logic.copy()
|
||||||
|
|
Loading…
Reference in New Issue