Skip to content

Commit

Permalink
Timespinner: migrate to new options api and correct random (Archipela…
Browse files Browse the repository at this point in the history
…goMW#2485)

* Implemented new options system into Timespinner

* Fixed typo

* Fixed typo

* Fixed slotdata maybe

* Fixes

* more fixes

* Fixed failing unit tests

* Implemented options backwards comnpatibility

* Fixed option fallbacks

* Implemented review results

* Fixed logic bug

* Fixed python 3.8/3.9 compatibility

* Replaced one more multiworld option usage

* Update worlds/timespinner/Options.py

Co-authored-by: Exempt-Medic <[email protected]>

* Updated logging of options replacement to include player name and also write it to spoiler
Fixed generation bug
Implemented review results

---------

Co-authored-by: Exempt-Medic <[email protected]>
  • Loading branch information
2 people authored and agilbert1412 committed Aug 24, 2024
1 parent a7f566a commit 647c28c
Show file tree
Hide file tree
Showing 6 changed files with 424 additions and 240 deletions.
21 changes: 10 additions & 11 deletions worlds/timespinner/Locations.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List, Optional, Callable, NamedTuple
from BaseClasses import MultiWorld, CollectionState
from .Options import is_option_enabled
from BaseClasses import CollectionState
from .Options import TimespinnerOptions
from .PreCalculatedWeights import PreCalculatedWeights
from .LogicExtensions import TimespinnerLogic

Expand All @@ -14,11 +14,10 @@ class LocationData(NamedTuple):
rule: Optional[Callable[[CollectionState], bool]] = None


def get_location_datas(world: Optional[MultiWorld], player: Optional[int],
precalculated_weights: PreCalculatedWeights) -> List[LocationData]:

flooded: PreCalculatedWeights = precalculated_weights
logic = TimespinnerLogic(world, player, precalculated_weights)
def get_location_datas(player: Optional[int], options: Optional[TimespinnerOptions],
precalculated_weights: Optional[PreCalculatedWeights]) -> List[LocationData]:
flooded: Optional[PreCalculatedWeights] = precalculated_weights
logic = TimespinnerLogic(player, options, precalculated_weights)

# 1337000 - 1337155 Generic locations
# 1337171 - 1337175 New Pickup checks
Expand Down Expand Up @@ -203,7 +202,7 @@ def get_location_datas(world: Optional[MultiWorld], player: Optional[int],
]

# 1337156 - 1337170 Downloads
if not world or is_option_enabled(world, player, "DownloadableItems"):
if not options or options.downloadable_items:
location_table += (
LocationData('Library', 'Library: Terminal 2 (Lachiem)', 1337156, lambda state: state.has('Tablet', player)),
LocationData('Library', 'Library: Terminal 1 (Windaria)', 1337157, lambda state: state.has('Tablet', player)),
Expand All @@ -223,13 +222,13 @@ def get_location_datas(world: Optional[MultiWorld], player: Optional[int],
)

# 1337176 - 1337176 Cantoran
if not world or is_option_enabled(world, player, "Cantoran"):
if not options or options.cantoran:
location_table += (
LocationData('Left Side forest Caves', 'Lake Serene: Cantoran', 1337176),
)

# 1337177 - 1337198 Lore Checks
if not world or is_option_enabled(world, player, "LoreChecks"):
if not options or options.lore_checks:
location_table += (
LocationData('Lower lake desolation', 'Lake Desolation: Memory - Coyote Jump (Time Messenger)', 1337177),
LocationData('Library', 'Library: Memory - Waterway (A Message)', 1337178),
Expand Down Expand Up @@ -258,7 +257,7 @@ def get_location_datas(world: Optional[MultiWorld], player: Optional[int],
# 1337199 - 1337236 Reserved for future use

# 1337237 - 1337245 GyreArchives
if not world or is_option_enabled(world, player, "GyreArchives"):
if not options or options.gyre_archives:
location_table += (
LocationData('Ravenlord\'s Lair', 'Ravenlord: Post fight (pedestal)', 1337237),
LocationData('Ifrit\'s Lair', 'Ifrit: Post fight (pedestal)', 1337238),
Expand Down
23 changes: 12 additions & 11 deletions worlds/timespinner/LogicExtensions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Union
from BaseClasses import MultiWorld, CollectionState
from .Options import is_option_enabled
from typing import Union, Optional
from BaseClasses import CollectionState
from .Options import TimespinnerOptions
from .PreCalculatedWeights import PreCalculatedWeights


Expand All @@ -10,17 +10,18 @@ class TimespinnerLogic:
flag_unchained_keys: bool
flag_eye_spy: bool
flag_specific_keycards: bool
pyramid_keys_unlock: Union[str, None]
present_keys_unlock: Union[str, None]
past_keys_unlock: Union[str, None]
time_keys_unlock: Union[str, None]
pyramid_keys_unlock: Optional[str]
present_keys_unlock: Optional[str]
past_keys_unlock: Optional[str]
time_keys_unlock: Optional[str]

def __init__(self, world: MultiWorld, player: int, precalculated_weights: PreCalculatedWeights):
def __init__(self, player: int, options: Optional[TimespinnerOptions],
precalculated_weights: Optional[PreCalculatedWeights]):
self.player = player

self.flag_specific_keycards = is_option_enabled(world, player, "SpecificKeycards")
self.flag_eye_spy = is_option_enabled(world, player, "EyeSpy")
self.flag_unchained_keys = is_option_enabled(world, player, "UnchainedKeys")
self.flag_specific_keycards = bool(options and options.specific_keycards)
self.flag_eye_spy = bool(options and options.eye_spy)
self.flag_unchained_keys = bool(options and options.unchained_keys)

if precalculated_weights:
if self.flag_unchained_keys:
Expand Down
Loading

0 comments on commit 647c28c

Please sign in to comment.