From e777094dafe70e0a3ca890bc080a5020f577e137 Mon Sep 17 00:00:00 2001 From: Nicholas Brochu Date: Wed, 1 Jan 2025 13:36:00 -0500 Subject: [PATCH] add include modern console games option --- worlds/keymasters_keep/client.py | 2 ++ .../client_gui/client_gui_layouts.py | 3 ++- .../keymasters_keep/game_objective_generator.py | 15 +++++++++++++++ worlds/keymasters_keep/options.py | 14 ++++++++++++++ worlds/keymasters_keep/world.py | 4 ++++ 5 files changed, 37 insertions(+), 1 deletion(-) diff --git a/worlds/keymasters_keep/client.py b/worlds/keymasters_keep/client.py index 913998fdfeb5..644330b98a80 100644 --- a/worlds/keymasters_keep/client.py +++ b/worlds/keymasters_keep/client.py @@ -53,6 +53,7 @@ class KeymastersKeepContext(CommonClient.CommonContext): hints_reveal_objectives: bool include_adult_only_or_unrated_games: bool include_difficult_objectives: bool + include_modern_console_games: bool include_time_consuming_objectives: bool location_ids_checked: Set[int] lock_combinations: Dict[KeymastersKeepRegions, Optional[List[KeymastersKeepItems]]] @@ -141,6 +142,7 @@ def on_package(self, cmd: str, _args: Any) -> None: self.hints_reveal_objectives = _args["slot_data"]["hints_reveal_objectives"] self.include_adult_only_or_unrated_games = _args["slot_data"]["include_adult_only_or_unrated_games"] self.include_difficult_objectives = _args["slot_data"]["include_difficult_objectives"] + self.include_modern_console_games = _args["slot_data"]["include_modern_console_games"] self.include_time_consuming_objectives = _args["slot_data"]["include_time_consuming_objectives"] self.lock_combinations = dict() diff --git a/worlds/keymasters_keep/client_gui/client_gui_layouts.py b/worlds/keymasters_keep/client_gui/client_gui_layouts.py index 938f7086421b..ec6b6e637874 100644 --- a/worlds/keymasters_keep/client_gui/client_gui_layouts.py +++ b/worlds/keymasters_keep/client_gui/client_gui_layouts.py @@ -356,13 +356,14 @@ def __init__(self, ctx: KeymastersKeepContext): f"Area Trials (Maximum): [color=00FA9A]{self.ctx.area_trials_maximum}[/color]\n\n" f"Game Medley Mode: [color=00FA9A]{game_medley_mode_label}[/color]\n\n" f"Include 18+ / Unrated Games: [color=00FA9A]{lm[self.ctx.include_adult_only_or_unrated_games]}[/color]\n" + f"Include Modern Console Games: [color=00FA9A]{lm[self.ctx.include_modern_console_games]}[/color]\n" f"Include Difficult Objectives: [color=00FA9A]{lm[self.ctx.include_difficult_objectives]}[/color]\n" f"Include Time Consuming Objectives: [color=00FA9A]{lm[self.ctx.include_time_consuming_objectives]}[/color]\n\n" f"Hints Reveal Objectives: [color=00FA9A]{lm[self.ctx.hints_reveal_objectives]}[/color]" ), markup=True, size_hint_y=None, - height="300dp", + height="320dp", halign="left", valign="top", ) diff --git a/worlds/keymasters_keep/game_objective_generator.py b/worlds/keymasters_keep/game_objective_generator.py index 936a6600731d..125319265abd 100644 --- a/worlds/keymasters_keep/game_objective_generator.py +++ b/worlds/keymasters_keep/game_objective_generator.py @@ -1,6 +1,8 @@ from random import Random from typing import Any, List, Tuple, Type, Union +from .enums import KeymastersKeepGamePlatforms + from .game import Game from .games import AutoGameRegister @@ -22,6 +24,7 @@ def __init__( self, allowable_games: List[str] = None, include_adult_only_or_unrated_games: bool = False, + include_modern_console_games: bool = False, include_difficult_objectives: bool = False, include_time_consuming_objectives: bool = False, archipelago_options: Any = None, @@ -31,6 +34,7 @@ def __init__( self.games = self._filter_games( allowable_games, include_adult_only_or_unrated_games, + include_modern_console_games, include_difficult_objectives, include_time_consuming_objectives, ) @@ -126,6 +130,7 @@ def _filter_games( self, allowable_games: List[str], include_adult_only_or_unrated_games: bool, + include_modern_console_games: bool, include_difficult_objectives: bool, include_time_consuming_objectives: bool ) -> List[Type[Game]]: @@ -142,6 +147,16 @@ def _filter_games( if not include_adult_only_or_unrated_games and game.is_adult_only_or_unrated: continue + modern_consoles: List[KeymastersKeepGamePlatforms] = [ + KeymastersKeepGamePlatforms.PS5, + KeymastersKeepGamePlatforms.SW, + KeymastersKeepGamePlatforms.XSX, + ] + + # We only want to filter out games that are exclusive to modern consoles, hence the primary platform check + if not include_modern_console_games and game.platform in modern_consoles: + continue + if not include_difficult_objectives and game_instance.only_has_difficult_objectives: continue diff --git a/worlds/keymasters_keep/options.py b/worlds/keymasters_keep/options.py index ec3e4ec59832..23f3d6bb4f17 100644 --- a/worlds/keymasters_keep/options.py +++ b/worlds/keymasters_keep/options.py @@ -232,11 +232,23 @@ class MetagameSelection(OptionSet): class IncludeAdultOnlyOrUnratedGames(Toggle): """ Determines if adult only or unrated games should be considered for the game pool. + + Can be a useful filter to adhere to the rules of certain communities. """ display_name: str = "Include Adult Only or Unrated Games" +class IncludeModernConsoleGames(Toggle): + """ + Determines if modern console games should be considered for the game pool. + + Can be a useful filter to adhere to the rules of certain communities. + """ + + display_name: str = "Include Modern Console Games" + + class IncludeDifficultObjectives(Toggle): """ Determines if difficult objectives should be considered. @@ -320,6 +332,7 @@ class KeymastersKeepOptions(PerGameCommonOptions, GameArchipelagoOptions): game_selection: GameSelection metagame_selection: MetagameSelection include_adult_only_or_unrated_games: IncludeAdultOnlyOrUnratedGames + include_modern_console_games: IncludeModernConsoleGames include_difficult_objectives: IncludeDifficultObjectives excluded_games_difficult_objectives: ExcludedGamesDifficultObjectives include_time_consuming_objectives: IncludeTimeConsumingObjectives @@ -356,6 +369,7 @@ class KeymastersKeepOptions(PerGameCommonOptions, GameArchipelagoOptions): "Game / Objective Selection Options", [ IncludeAdultOnlyOrUnratedGames, + IncludeModernConsoleGames, IncludeDifficultObjectives, ExcludedGamesDifficultObjectives, IncludeTimeConsumingObjectives, diff --git a/worlds/keymasters_keep/world.py b/worlds/keymasters_keep/world.py index d33c63ffc9c9..e2441b6daead 100644 --- a/worlds/keymasters_keep/world.py +++ b/worlds/keymasters_keep/world.py @@ -101,6 +101,7 @@ class KeymastersKeepWorld(World): hints_reveal_objectives: bool include_adult_only_or_unrated_games: bool include_difficult_objectives: bool + include_modern_console_games: bool include_time_consuming_objectives: bool keep_areas: int keep_data: Any @@ -211,6 +212,7 @@ def generate_early(self) -> None: self.metagame_selection = list(self.options.metagame_selection.value) self.include_adult_only_or_unrated_games = bool(self.options.include_adult_only_or_unrated_games) + self.include_modern_console_games = bool(self.options.include_modern_console_games) self.include_difficult_objectives = bool(self.options.include_difficult_objectives) self.excluded_games_difficult_objectives = list(self.options.excluded_games_difficult_objectives.value) @@ -438,6 +440,7 @@ def fill_slot_data(self) -> Dict[str, Any]: "hints_reveal_objectives": self.hints_reveal_objectives, "include_adult_only_or_unrated_games": self.include_adult_only_or_unrated_games, "include_difficult_objectives": self.include_difficult_objectives, + "include_modern_console_games": self.include_modern_console_games, "include_time_consuming_objectives": self.include_time_consuming_objectives, "lock_combinations": dict(), "lock_magic_keys_maximum": self.lock_magic_keys_maximum, @@ -582,6 +585,7 @@ def _generate_game_objective_data(self) -> None: generator: GameObjectiveGenerator = GameObjectiveGenerator( game_selection, self.include_adult_only_or_unrated_games, + self.include_modern_console_games, self.include_difficult_objectives, self.include_time_consuming_objectives, self.options