From c12ed316cff03014810aa610248f95cbb53036af Mon Sep 17 00:00:00 2001 From: Jarno Date: Wed, 16 Oct 2024 23:06:14 +0200 Subject: [PATCH] Timespinner: Make hidden options pickleables (#4050) * Make timespinner hidden options pickleables * Keep changes minimal * Change line endings --- worlds/timespinner/Options.py | 81 ++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 39 deletions(-) diff --git a/worlds/timespinner/Options.py b/worlds/timespinner/Options.py index 20ad8132c45f..f6a3dba3e311 100644 --- a/worlds/timespinner/Options.py +++ b/worlds/timespinner/Options.py @@ -417,13 +417,16 @@ class HiddenTraps(Traps): """List of traps that may be in the item pool to find""" visibility = Visibility.none -class OptionsHider: - @classmethod - def hidden(cls, option: Type[Option[Any]]) -> Type[Option]: - new_option = AssembleOptions(f"{option}Hidden", option.__bases__, vars(option).copy()) - new_option.visibility = Visibility.none - new_option.__doc__ = option.__doc__ - return new_option +class HiddenDeathLink(DeathLink): + """When you die, everyone who enabled death link dies. Of course, the reverse is true too.""" + visibility = Visibility.none + +def hidden(option: Type[Option[Any]]) -> Type[Option]: + new_option = AssembleOptions(f"{option.__name__}Hidden", option.__bases__, vars(option).copy()) + new_option.visibility = Visibility.none + new_option.__doc__ = option.__doc__ + globals()[f"{option.__name__}Hidden"] = new_option + return new_option class HasReplacedCamelCase(Toggle): """For internal use will display a warning message if true""" @@ -431,41 +434,41 @@ class HasReplacedCamelCase(Toggle): @dataclass class BackwardsCompatiableTimespinnerOptions(TimespinnerOptions): - StartWithJewelryBox: OptionsHider.hidden(StartWithJewelryBox) # type: ignore - DownloadableItems: OptionsHider.hidden(DownloadableItems) # type: ignore - EyeSpy: OptionsHider.hidden(EyeSpy) # type: ignore - StartWithMeyef: OptionsHider.hidden(StartWithMeyef) # type: ignore - QuickSeed: OptionsHider.hidden(QuickSeed) # type: ignore - SpecificKeycards: OptionsHider.hidden(SpecificKeycards) # type: ignore - Inverted: OptionsHider.hidden(Inverted) # type: ignore - GyreArchives: OptionsHider.hidden(GyreArchives) # type: ignore - Cantoran: OptionsHider.hidden(Cantoran) # type: ignore - LoreChecks: OptionsHider.hidden(LoreChecks) # type: ignore - BossRando: OptionsHider.hidden(BossRando) # type: ignore - DamageRando: OptionsHider.hidden(DamageRando) # type: ignore + StartWithJewelryBox: hidden(StartWithJewelryBox) # type: ignore + DownloadableItems: hidden(DownloadableItems) # type: ignore + EyeSpy: hidden(EyeSpy) # type: ignore + StartWithMeyef: hidden(StartWithMeyef) # type: ignore + QuickSeed: hidden(QuickSeed) # type: ignore + SpecificKeycards: hidden(SpecificKeycards) # type: ignore + Inverted: hidden(Inverted) # type: ignore + GyreArchives: hidden(GyreArchives) # type: ignore + Cantoran: hidden(Cantoran) # type: ignore + LoreChecks: hidden(LoreChecks) # type: ignore + BossRando: hidden(BossRando) # type: ignore + DamageRando: hidden(DamageRando) # type: ignore DamageRandoOverrides: HiddenDamageRandoOverrides - HpCap: OptionsHider.hidden(HpCap) # type: ignore - LevelCap: OptionsHider.hidden(LevelCap) # type: ignore - ExtraEarringsXP: OptionsHider.hidden(ExtraEarringsXP) # type: ignore - BossHealing: OptionsHider.hidden(BossHealing) # type: ignore - ShopFill: OptionsHider.hidden(ShopFill) # type: ignore - ShopWarpShards: OptionsHider.hidden(ShopWarpShards) # type: ignore - ShopMultiplier: OptionsHider.hidden(ShopMultiplier) # type: ignore - LootPool: OptionsHider.hidden(LootPool) # type: ignore - DropRateCategory: OptionsHider.hidden(DropRateCategory) # type: ignore - FixedDropRate: OptionsHider.hidden(FixedDropRate) # type: ignore - LootTierDistro: OptionsHider.hidden(LootTierDistro) # type: ignore - ShowBestiary: OptionsHider.hidden(ShowBestiary) # type: ignore - ShowDrops: OptionsHider.hidden(ShowDrops) # type: ignore - EnterSandman: OptionsHider.hidden(EnterSandman) # type: ignore - DadPercent: OptionsHider.hidden(DadPercent) # type: ignore - RisingTides: OptionsHider.hidden(RisingTides) # type: ignore + HpCap: hidden(HpCap) # type: ignore + LevelCap: hidden(LevelCap) # type: ignore + ExtraEarringsXP: hidden(ExtraEarringsXP) # type: ignore + BossHealing: hidden(BossHealing) # type: ignore + ShopFill: hidden(ShopFill) # type: ignore + ShopWarpShards: hidden(ShopWarpShards) # type: ignore + ShopMultiplier: hidden(ShopMultiplier) # type: ignore + LootPool: hidden(LootPool) # type: ignore + DropRateCategory: hidden(DropRateCategory) # type: ignore + FixedDropRate: hidden(FixedDropRate) # type: ignore + LootTierDistro: hidden(LootTierDistro) # type: ignore + ShowBestiary: hidden(ShowBestiary) # type: ignore + ShowDrops: hidden(ShowDrops) # type: ignore + EnterSandman: hidden(EnterSandman) # type: ignore + DadPercent: hidden(DadPercent) # type: ignore + RisingTides: hidden(RisingTides) # type: ignore RisingTidesOverrides: HiddenRisingTidesOverrides - UnchainedKeys: OptionsHider.hidden(UnchainedKeys) # type: ignore - PresentAccessWithWheelAndSpindle: OptionsHider.hidden(PresentAccessWithWheelAndSpindle) # type: ignore - TrapChance: OptionsHider.hidden(TrapChance) # type: ignore + UnchainedKeys: hidden(UnchainedKeys) # type: ignore + PresentAccessWithWheelAndSpindle: hidden(PresentAccessWithWheelAndSpindle) # type: ignore + TrapChance: hidden(TrapChance) # type: ignore Traps: HiddenTraps # type: ignore - DeathLink: OptionsHider.hidden(DeathLink) # type: ignore + DeathLink: HiddenDeathLink # type: ignore has_replaced_options: HasReplacedCamelCase def handle_backward_compatibility(self) -> None: