Archipelago/worlds/timespinner/LogicExtensions.py

115 lines
5.2 KiB
Python
Raw Normal View History

from typing import Union, Optional
from BaseClasses import CollectionState
from .Options import TimespinnerOptions
Timespinner: many new stuffs (#1433) * Timespinner: added RisingTides and DadPercent flags * Implemented logic for DadPercent and RisingTides * Fixed TODO's * Logic fixes * Fixed + removed LogicMixins * Fixes * More Fixes * Added UnchainedKeys flag * Fixed available items in pool with UnchainedKeys * Fixed typing callable * Fixed generation failures * More refactorings * Implemented traps * Fixed more typo * Fixed copy paste bug * Fixed teleporter logic * Fixed traps from pool * Fixed pyramid gates bug that causes a crash on connecting * Fixed seed reproduceability * Fixed logic eye for eye spy Now consider warp beacons as starter progression items * Attempt to add tracker icons using table * Replaced table layout with css grid * Fixed tracker + added Timespinner was apworld capatible * Updated archipelago items description * updated URL * Cleared up text * Fixed based on self review of PR * Fixed unit tests * Fixed seed reproduceability when the traps yaml option is not provided * Fixed logic for flooded basement * Implemented Beserkers review result I am not sure why, i guess this is just to make adding future games less conflicting? Co-authored-by: Fabian Dill <Berserker66@users.noreply.github.com> * Added two new options (thanks to WeffJebster) * Apply suggestions from code review Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com> * Addition review results --------- Co-authored-by: Fabian Dill <Berserker66@users.noreply.github.com> Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com>
2023-02-19 20:22:30 +00:00
from .PreCalculatedWeights import PreCalculatedWeights
class TimespinnerLogic:
player: int
flag_unchained_keys: bool
flag_eye_spy: bool
flag_specific_keycards: bool
pyramid_keys_unlock: Optional[str]
present_keys_unlock: Optional[str]
past_keys_unlock: Optional[str]
time_keys_unlock: Optional[str]
Timespinner: many new stuffs (#1433) * Timespinner: added RisingTides and DadPercent flags * Implemented logic for DadPercent and RisingTides * Fixed TODO's * Logic fixes * Fixed + removed LogicMixins * Fixes * More Fixes * Added UnchainedKeys flag * Fixed available items in pool with UnchainedKeys * Fixed typing callable * Fixed generation failures * More refactorings * Implemented traps * Fixed more typo * Fixed copy paste bug * Fixed teleporter logic * Fixed traps from pool * Fixed pyramid gates bug that causes a crash on connecting * Fixed seed reproduceability * Fixed logic eye for eye spy Now consider warp beacons as starter progression items * Attempt to add tracker icons using table * Replaced table layout with css grid * Fixed tracker + added Timespinner was apworld capatible * Updated archipelago items description * updated URL * Cleared up text * Fixed based on self review of PR * Fixed unit tests * Fixed seed reproduceability when the traps yaml option is not provided * Fixed logic for flooded basement * Implemented Beserkers review result I am not sure why, i guess this is just to make adding future games less conflicting? Co-authored-by: Fabian Dill <Berserker66@users.noreply.github.com> * Added two new options (thanks to WeffJebster) * Apply suggestions from code review Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com> * Addition review results --------- Co-authored-by: Fabian Dill <Berserker66@users.noreply.github.com> Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com>
2023-02-19 20:22:30 +00:00
def __init__(self, player: int, options: Optional[TimespinnerOptions],
precalculated_weights: Optional[PreCalculatedWeights]):
Timespinner: many new stuffs (#1433) * Timespinner: added RisingTides and DadPercent flags * Implemented logic for DadPercent and RisingTides * Fixed TODO's * Logic fixes * Fixed + removed LogicMixins * Fixes * More Fixes * Added UnchainedKeys flag * Fixed available items in pool with UnchainedKeys * Fixed typing callable * Fixed generation failures * More refactorings * Implemented traps * Fixed more typo * Fixed copy paste bug * Fixed teleporter logic * Fixed traps from pool * Fixed pyramid gates bug that causes a crash on connecting * Fixed seed reproduceability * Fixed logic eye for eye spy Now consider warp beacons as starter progression items * Attempt to add tracker icons using table * Replaced table layout with css grid * Fixed tracker + added Timespinner was apworld capatible * Updated archipelago items description * updated URL * Cleared up text * Fixed based on self review of PR * Fixed unit tests * Fixed seed reproduceability when the traps yaml option is not provided * Fixed logic for flooded basement * Implemented Beserkers review result I am not sure why, i guess this is just to make adding future games less conflicting? Co-authored-by: Fabian Dill <Berserker66@users.noreply.github.com> * Added two new options (thanks to WeffJebster) * Apply suggestions from code review Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com> * Addition review results --------- Co-authored-by: Fabian Dill <Berserker66@users.noreply.github.com> Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com>
2023-02-19 20:22:30 +00:00
self.player = player
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)
self.flag_prism_break = bool(options and options.prism_break)
Timespinner: many new stuffs (#1433) * Timespinner: added RisingTides and DadPercent flags * Implemented logic for DadPercent and RisingTides * Fixed TODO's * Logic fixes * Fixed + removed LogicMixins * Fixes * More Fixes * Added UnchainedKeys flag * Fixed available items in pool with UnchainedKeys * Fixed typing callable * Fixed generation failures * More refactorings * Implemented traps * Fixed more typo * Fixed copy paste bug * Fixed teleporter logic * Fixed traps from pool * Fixed pyramid gates bug that causes a crash on connecting * Fixed seed reproduceability * Fixed logic eye for eye spy Now consider warp beacons as starter progression items * Attempt to add tracker icons using table * Replaced table layout with css grid * Fixed tracker + added Timespinner was apworld capatible * Updated archipelago items description * updated URL * Cleared up text * Fixed based on self review of PR * Fixed unit tests * Fixed seed reproduceability when the traps yaml option is not provided * Fixed logic for flooded basement * Implemented Beserkers review result I am not sure why, i guess this is just to make adding future games less conflicting? Co-authored-by: Fabian Dill <Berserker66@users.noreply.github.com> * Added two new options (thanks to WeffJebster) * Apply suggestions from code review Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com> * Addition review results --------- Co-authored-by: Fabian Dill <Berserker66@users.noreply.github.com> Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com>
2023-02-19 20:22:30 +00:00
if precalculated_weights:
if self.flag_unchained_keys:
self.pyramid_keys_unlock = None
self.present_keys_unlock = precalculated_weights.present_key_unlock
self.past_keys_unlock = precalculated_weights.past_key_unlock
self.time_keys_unlock = precalculated_weights.time_key_unlock
else:
self.pyramid_keys_unlock = precalculated_weights.pyramid_keys_unlock
self.present_keys_unlock = None
self.past_keys_unlock = None
self.time_keys_unlock = None
def has_timestop(self, state: CollectionState) -> bool:
return state.has_any({'Timespinner Wheel', 'Succubus Hairpin', 'Lightwall', 'Celestial Sash'}, self.player)
def has_doublejump(self, state: CollectionState) -> bool:
return state.has_any({'Succubus Hairpin', 'Lightwall', 'Celestial Sash'}, self.player)
def has_forwarddash_doublejump(self, state: CollectionState) -> bool:
return self.has_upwarddash(state) \
or (state.has('Talaria Attachment', self.player) and self.has_doublejump(state))
def has_doublejump_of_npc(self, state: CollectionState) -> bool:
return self.has_upwarddash(state) \
or (state.has('Timespinner Wheel', self.player) and self.has_doublejump(state))
def has_fastjump_on_npc(self, state: CollectionState) -> bool:
return state.has_all({'Timespinner Wheel', 'Talaria Attachment'}, self.player)
def has_multiple_small_jumps_of_npc(self, state: CollectionState) -> bool:
return state.has('Timespinner Wheel', self.player) or self.has_upwarddash(state)
def has_upwarddash(self, state: CollectionState) -> bool:
return state.has_any({'Lightwall', 'Celestial Sash'}, self.player)
def has_fire(self, state: CollectionState) -> bool:
return state.has_any({'Fire Orb', 'Infernal Flames', 'Pyro Ring', 'Djinn Inferno'}, self.player)
def has_pink(self, state: CollectionState) -> bool:
return state.has_any({'Plasma Orb', 'Plasma Geyser', 'Royal Ring'}, self.player)
def has_keycard_A(self, state: CollectionState) -> bool:
return state.has('Security Keycard A', self.player)
def has_keycard_B(self, state: CollectionState) -> bool:
if self.flag_specific_keycards:
return state.has('Security Keycard B', self.player)
else:
return state.has_any({'Security Keycard A', 'Security Keycard B'}, self.player)
def has_keycard_C(self, state: CollectionState) -> bool:
if self.flag_specific_keycards:
return state.has('Security Keycard C', self.player)
else:
return state.has_any({'Security Keycard A', 'Security Keycard B', 'Security Keycard C'}, self.player)
def has_keycard_D(self, state: CollectionState) -> bool:
if self.flag_specific_keycards:
return state.has('Security Keycard D', self.player)
else:
return state.has_any({'Security Keycard A', 'Security Keycard B', 'Security Keycard C', 'Security Keycard D'}, self.player)
def can_break_walls(self, state: CollectionState) -> bool:
if self.flag_eye_spy:
return state.has('Oculus Ring', self.player)
else:
return True
def can_kill_all_3_bosses(self, state: CollectionState) -> bool:
if self.flag_prism_break:
return state.has_all({'Laser Access M', 'Laser Access I', 'Laser Access A'}, self.player)
Timespinner: many new stuffs (#1433) * Timespinner: added RisingTides and DadPercent flags * Implemented logic for DadPercent and RisingTides * Fixed TODO's * Logic fixes * Fixed + removed LogicMixins * Fixes * More Fixes * Added UnchainedKeys flag * Fixed available items in pool with UnchainedKeys * Fixed typing callable * Fixed generation failures * More refactorings * Implemented traps * Fixed more typo * Fixed copy paste bug * Fixed teleporter logic * Fixed traps from pool * Fixed pyramid gates bug that causes a crash on connecting * Fixed seed reproduceability * Fixed logic eye for eye spy Now consider warp beacons as starter progression items * Attempt to add tracker icons using table * Replaced table layout with css grid * Fixed tracker + added Timespinner was apworld capatible * Updated archipelago items description * updated URL * Cleared up text * Fixed based on self review of PR * Fixed unit tests * Fixed seed reproduceability when the traps yaml option is not provided * Fixed logic for flooded basement * Implemented Beserkers review result I am not sure why, i guess this is just to make adding future games less conflicting? Co-authored-by: Fabian Dill <Berserker66@users.noreply.github.com> * Added two new options (thanks to WeffJebster) * Apply suggestions from code review Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com> * Addition review results --------- Co-authored-by: Fabian Dill <Berserker66@users.noreply.github.com> Co-authored-by: black-sliver <59490463+black-sliver@users.noreply.github.com>
2023-02-19 20:22:30 +00:00
return state.has_all({'Killed Maw', 'Killed Twins', 'Killed Aelana'}, self.player)
def has_teleport(self, state: CollectionState) -> bool:
return self.flag_unchained_keys or state.has('Twin Pyramid Key', self.player)
def can_teleport_to(self, state: CollectionState, era: str, gate: str) -> bool:
if not self.flag_unchained_keys:
return self.pyramid_keys_unlock == gate
if era == "Present":
return self.present_keys_unlock == gate and state.has("Modern Warp Beacon", self.player)
elif era == "Past":
return self.past_keys_unlock == gate and state.has("Timeworn Warp Beacon", self.player)
elif era == "Time":
return self.time_keys_unlock == gate and state.has("Mysterious Warp Beacon", self.player)
else:
raise Exception("Invallid Era: {}".format(era))