Skip to content

Commit

Permalink
add explicit error for unknown weights to hopefully easier notice iss…
Browse files Browse the repository at this point in the history
…ues with yamls and default genrePresets
  • Loading branch information
qwint committed Nov 23, 2024
1 parent b113f10 commit 1b37117
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions worlds/sgtpuzzles/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
from math import ceil
from BaseClasses import Item, Region, Entrance, Tutorial, ItemClassification
from Options import OptionError
from .items import SimonTathamPuzzlesItem, item_table, max_puzzles
from .locations import SimonTathamPuzzlesLocation, advancement_table
from .options import SimonTathamPuzzlesOptions, genrePresets, sgtpuzzles_option_groups
Expand Down Expand Up @@ -49,6 +50,10 @@ def generate_early(self):
genre_min_difficulty=self.options.genre_min_difficulty.value,
genre_max_difficulty=self.options.genre_max_difficulty.value)

invalid_weights = [genre for genre in self.options.genre_weights if genre not in genrePresets]
if invalid_weights:
raise OptionError(f"Unknown weights in genre_weights: {invalid_weights}")

for genre in genrePresets:
weight = self.options.genre_weights.get(genre, default_genre_weight if genre != "group" else 0)
if weight > 0:
Expand Down

0 comments on commit 1b37117

Please sign in to comment.