Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
eudaimonistic authored Oct 26, 2023
2 parents 35a8f25 + 88d69db commit 7de5f5b
Show file tree
Hide file tree
Showing 80 changed files with 1,525 additions and 1,732 deletions.
5 changes: 0 additions & 5 deletions BaseClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,6 @@ def get_out_file_name_base(self, player: int) -> str:
""" the base name (without file extension) for each player's output file for a seed """
return f"AP_{self.seed_name}_P{player}_{self.get_file_safe_player_name(player).replace(' ', '_')}"

def initialize_regions(self, regions=None):
for region in regions if regions else self.regions:
region.multiworld = self
self._region_cache[region.player][region.name] = region

@functools.cached_property
def world_name_lookup(self):
return {self.player_name[player_id]: player_id for player_id in self.player_ids}
Expand Down
2 changes: 1 addition & 1 deletion Generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def main(args=None, callback=ERmain):
for player in range(1, args.multi + 1):
player_path_cache[player] = player_files.get(player, args.weights_file_path)
name_counter = Counter()
erargs.player_settings = {}
erargs.player_options = {}

player = 1
while player <= args.multi:
Expand Down
13 changes: 11 additions & 2 deletions ModuleUpdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,23 @@ def update(yes=False, force=False):
install_pkg_resources(yes=yes)
import pkg_resources

prev = "" # if a line ends in \ we store here and merge later
for req_file in requirements_files:
path = os.path.join(os.path.dirname(sys.argv[0]), req_file)
if not os.path.exists(path):
path = os.path.join(os.path.dirname(__file__), req_file)
with open(path) as requirementsfile:
for line in requirementsfile:
if not line or line[0] == "#":
continue # ignore comments
if not line or line.lstrip(" \t")[0] == "#":
if not prev:
continue # ignore comments
line = ""
elif line.rstrip("\r\n").endswith("\\"):
prev = prev + line.rstrip("\r\n")[:-1] + " " # continue on next line
continue
line = prev + line
line = line.split("--hash=")[0] # remove hashes from requirement for version checking
prev = ""
if line.startswith(("https://", "git+https://")):
# extract name and version for url
rest = line.split('/')[-1]
Expand Down
5 changes: 4 additions & 1 deletion Options.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,10 @@ def as_dict(self, *option_names: str, casing: str = "snake") -> typing.Dict[str,
else:
raise ValueError(f"{casing} is invalid casing for as_dict. "
"Valid names are 'snake', 'camel', 'pascal', 'kebab'.")
option_results[display_name] = getattr(self, option_name).value
value = getattr(self, option_name).value
if isinstance(value, set):
value = sorted(value)
option_results[display_name] = value
else:
raise ValueError(f"{option_name} not found in {tuple(type(self).type_hints)}")
return option_results
Expand Down
28 changes: 20 additions & 8 deletions WebHostLib/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,29 @@ def start_playing():
return render_template(f"startPlaying.html")


@app.route('/weighted-settings')
@cache.cached()
# TODO for back compat. remove around 0.4.5
@app.route("/weighted-settings")
def weighted_settings():
return render_template(f"weighted-settings.html")
return redirect("weighted-options", 301)


@app.route("/weighted-options")
@cache.cached()
def weighted_options():
return render_template("weighted-options.html")


# TODO for back compat. remove around 0.4.5
@app.route("/games/<string:game>/player-settings")
def player_settings(game: str):
return redirect(url_for("player_options", game=game), 301)


# Player settings pages
@app.route('/games/<string:game>/player-settings')
# Player options pages
@app.route("/games/<string:game>/player-options")
@cache.cached()
def player_settings(game):
return render_template(f"player-settings.html", game=game, theme=get_world_theme(game))
def player_options(game: str):
return render_template("player-options.html", game=game, theme=get_world_theme(game))


# Game Info Pages
Expand Down Expand Up @@ -181,6 +193,6 @@ def get_sitemap():
available_games: List[Dict[str, Union[str, bool]]] = []
for game, world in AutoWorldRegister.world_types.items():
if not world.hidden:
has_settings: bool = isinstance(world.web.settings_page, bool) and world.web.settings_page
has_settings: bool = isinstance(world.web.options_page, bool) and world.web.options_page
available_games.append({ 'title': game, 'has_settings': has_settings })
return render_template("siteMap.html", games=available_games)
34 changes: 17 additions & 17 deletions WebHostLib/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def get_html_doc(option_type: type(Options.Option)) -> str:
return "Please document me!"
return "\n".join(line.strip() for line in option_type.__doc__.split("\n")).strip()

weighted_settings = {
weighted_options = {
"baseOptions": {
"description": "Generated by https://archipelago.gg/",
"name": "Player",
Expand All @@ -38,8 +38,8 @@ def get_html_doc(option_type: type(Options.Option)) -> str:

all_options: typing.Dict[str, Options.AssembleOptions] = world.options_dataclass.type_hints

# Generate JSON files for player-settings pages
player_settings = {
# Generate JSON files for player-options pages
player_options = {
"baseOptions": {
"description": f"Generated by https://archipelago.gg/ for {game_name}",
"game": game_name,
Expand Down Expand Up @@ -117,29 +117,29 @@ def get_html_doc(option_type: type(Options.Option)) -> str:
}

else:
logging.debug(f"{option} not exported to Web Settings.")
logging.debug(f"{option} not exported to Web options.")

player_settings["gameOptions"] = game_options
player_options["gameOptions"] = game_options

os.makedirs(os.path.join(target_folder, 'player-settings'), exist_ok=True)
os.makedirs(os.path.join(target_folder, 'player-options'), exist_ok=True)

with open(os.path.join(target_folder, 'player-settings', game_name + ".json"), "w") as f:
json.dump(player_settings, f, indent=2, separators=(',', ': '))
with open(os.path.join(target_folder, 'player-options', game_name + ".json"), "w") as f:
json.dump(player_options, f, indent=2, separators=(',', ': '))

if not world.hidden and world.web.settings_page is True:
# Add the random option to Choice, TextChoice, and Toggle settings
if not world.hidden and world.web.options_page is True:
# Add the random option to Choice, TextChoice, and Toggle options
for option in game_options.values():
if option["type"] == "select":
option["options"].append({"name": "Random", "value": "random"})

if not option["defaultValue"]:
option["defaultValue"] = "random"

weighted_settings["baseOptions"]["game"][game_name] = 0
weighted_settings["games"][game_name] = {}
weighted_settings["games"][game_name]["gameSettings"] = game_options
weighted_settings["games"][game_name]["gameItems"] = tuple(world.item_names)
weighted_settings["games"][game_name]["gameLocations"] = tuple(world.location_names)
weighted_options["baseOptions"]["game"][game_name] = 0
weighted_options["games"][game_name] = {}
weighted_options["games"][game_name]["gameSettings"] = game_options
weighted_options["games"][game_name]["gameItems"] = tuple(world.item_names)
weighted_options["games"][game_name]["gameLocations"] = tuple(world.location_names)

with open(os.path.join(target_folder, 'weighted-settings.json'), "w") as f:
json.dump(weighted_settings, f, indent=2, separators=(',', ': '))
with open(os.path.join(target_folder, 'weighted-options.json'), "w") as f:
json.dump(weighted_options, f, indent=2, separators=(',', ': '))
Loading

0 comments on commit 7de5f5b

Please sign in to comment.