Skip to content

Commit

Permalink
add include modern console games option
Browse files Browse the repository at this point in the history
  • Loading branch information
nbrochu committed Jan 1, 2025
1 parent 7ab8002 commit e777094
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
2 changes: 2 additions & 0 deletions worlds/keymasters_keep/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]]
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion worlds/keymasters_keep/client_gui/client_gui_layouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
Expand Down
15 changes: 15 additions & 0 deletions worlds/keymasters_keep/game_objective_generator.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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,
Expand All @@ -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,
)
Expand Down Expand Up @@ -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]]:
Expand All @@ -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

Expand Down
14 changes: 14 additions & 0 deletions worlds/keymasters_keep/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -356,6 +369,7 @@ class KeymastersKeepOptions(PerGameCommonOptions, GameArchipelagoOptions):
"Game / Objective Selection Options",
[
IncludeAdultOnlyOrUnratedGames,
IncludeModernConsoleGames,
IncludeDifficultObjectives,
ExcludedGamesDifficultObjectives,
IncludeTimeConsumingObjectives,
Expand Down
4 changes: 4 additions & 0 deletions worlds/keymasters_keep/world.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e777094

Please sign in to comment.