diff --git a/worlds/rogue_legacy/__init__.py b/worlds/rogue_legacy/__init__.py index ad97325f708a..e57efe3c6b77 100644 --- a/worlds/rogue_legacy/__init__.py +++ b/worlds/rogue_legacy/__init__.py @@ -44,9 +44,11 @@ class RogueLegacyWorld(World): web = RogueLegacyWebWorld() boss_order: list[str] + piece_requirement: int def generate_early(self) -> None: self.boss_order = self.options.boss_shuffle.generate_boss_order(self) + self.piece_requirement = self.options.fountain_hunt.generate_requirement(self) def fill_slot_data(self) -> dict[str, Any]: # In theory, I could use self.options.as_dict, but I want more control over the value types. @@ -54,38 +56,36 @@ def fill_slot_data(self) -> dict[str, Any]: # fmt: off # Easy flag to check for updates. - "world_version": WORLD_VERSION, + "world_version": WORLD_VERSION, # Game options relevant to client. - "children": self.options.children.value, - "level_limit": bool(self.options.level_limit.value), - "shuffle_blacksmith": bool(self.options.shuffle_blacksmith.value), - "shuffle_enchantress": bool(self.options.shuffle_enchantress.value), - "chests_brown": self.options.chests_brown.value, - "chests_silver": self.options.chests_silver.value, - "chests_gold": self.options.chests_gold.value, - "chests_fairy": self.options.chests_fairy.value, - "diary_entries": self.options.diary_entries.value, - "neo_bosses": self.options.neo_bosses.current_key, - "additional_challenges": bool(self.options.additional_challenges.value), - "enemy_scaling": self.options.enemy_scaling.value / 100.0, - "castle_scaling": self.options.castle_scaling.value / 100.0, - "ngplus_requirement": self.options.ngplus_requirement.value, - "gold_gain": self.options.gold_gain.value / 100.0, - "charon": bool(self.options.charon.value), - "fountain_hunt": bool(self.options.fountain_hunt.value), - "fountain_pieces_available": self.options.fountain_pieces_available.value, - "fountain_pieces_required": self.options.fountain_pieces_required.value / 100.0, - "character_names_sir": self.options.character_names_sir.value, - "character_names_lady": self.options.character_names_lady.value, - "max_health": self.options.max_health.value, - "max_mana": self.options.max_mana.value, - "max_attack": self.options.max_attack.value, - "max_magic_damage": self.options.max_magic_damage.value, - "death_link": self.options.death_link.current_key, + "children": self.options.children.value, + "level_limit": bool(self.options.level_limit.value), + "shuffle_blacksmith": bool(self.options.shuffle_blacksmith.value), + "shuffle_enchantress": bool(self.options.shuffle_enchantress.value), + "chests_brown": self.options.chests_brown.value, + "chests_silver": self.options.chests_silver.value, + "chests_gold": self.options.chests_gold.value, + "chests_fairy": self.options.chests_fairy.value, + "diary_entries": self.options.diary_entries.value, + "neo_bosses": self.options.neo_bosses.current_key, + "additional_challenges": bool(self.options.additional_challenges.value), + "enemy_scaling": self.options.enemy_scaling.value / 100.0, + "castle_scaling": self.options.castle_scaling.value / 100.0, + "ngplus_requirement": self.options.ngplus_requirement.value, + "gold_gain": self.options.gold_gain.value / 100.0, + "charon": bool(self.options.charon.value), + "character_names_sir": self.options.character_names_sir.value, + "character_names_lady": self.options.character_names_lady.value, + "max_health": self.options.max_health.value, + "max_mana": self.options.max_mana.value, + "max_attack": self.options.max_attack.value, + "max_magic_damage": self.options.max_magic_damage.value, + "death_link": self.options.death_link.current_key, # Computed data. - "boss_order": self.boss_order, + "boss_order": self.boss_order, + "fountain_pieces_required": self.piece_requirement, } # fmt: on diff --git a/worlds/rogue_legacy/options.py b/worlds/rogue_legacy/options.py index e77af1dcbf02..bf3583ab238f 100644 --- a/worlds/rogue_legacy/options.py +++ b/worlds/rogue_legacy/options.py @@ -1,4 +1,5 @@ from dataclasses import dataclass +from math import floor from typing import TYPE_CHECKING from Options import ( @@ -346,6 +347,14 @@ class FountainHunt(Toggle): display_name = "Fountain Hunt" + def generate_requirement(self, world: RogueLegacyWorld) -> int: + if not self: # If disabled + return 0 + + available = world.options.fountain_pieces_available.value + required_factor = world.options.fountain_pieces_required.value / 100.0 + return min(1, floor(available * required_factor)) + class FountainPiecesAvailable(Range): """Determines the number of Fountain Pieces available, if Fountain Hunt is enabled."""