Skip to content

Commit

Permalink
Revert changes for backend logic (#1599)
Browse files Browse the repository at this point in the history
* missed some (#1596)

add flush info (#1597)

* add flush info

* Update Spoiler.py

Update all world/region data to be tied to the spoiler itself. (#1595)

* Update files

* resolve locations

* spoiler.

* fix region data

* format

* Revert "missed some (#1596)"

This reverts commit 0280d6a.

* Revert "Merge branch 'dev' into sad"

This reverts commit 4040c45, reversing
changes made to 7916df6.
  • Loading branch information
Killklli authored Sep 9, 2023
1 parent ea2fb2a commit e8167de
Show file tree
Hide file tree
Showing 29 changed files with 863 additions and 883 deletions.
105 changes: 50 additions & 55 deletions randomizer/CompileHints.py

Large diffs are not rendered by default.

869 changes: 428 additions & 441 deletions randomizer/Fill.py

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions randomizer/ItemPool.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
from randomizer.Enums.Types import Types
from randomizer.Lists.Item import ItemFromKong
from randomizer.Lists.LevelInfo import LevelInfoList
from randomizer.Lists.Location import ChunkyMoveLocations, DiddyMoveLocations, DonkeyMoveLocations, LankyMoveLocations, LocationList, SharedMoveLocations, TinyMoveLocations, TrainingBarrelLocations
from randomizer.Lists.ShufflableExit import ShufflableExits
from randomizer.Patching.Lib import IsItemSelected


def PlaceConstants(spoiler):
def PlaceConstants(settings):
"""Place items which are to be put in a hard-coded location."""
# Settings-dependent locations
settings = spoiler.settings
# Determine what types of locations are being shuffled
typesOfItemsShuffled = []
if settings.kong_rando:
Expand All @@ -35,44 +35,44 @@ def PlaceConstants(spoiler):
# Invert this list because I think it'll be faster
typesOfItemsNotShuffled = [typ for typ in Types if typ not in typesOfItemsShuffled]
# Place the default item at every location of a type we're not shuffling
for location in spoiler.LocationList:
if spoiler.LocationList[location].type in typesOfItemsNotShuffled:
spoiler.LocationList[location].PlaceDefaultItem(spoiler)
for location in LocationList:
if LocationList[location].type in typesOfItemsNotShuffled:
LocationList[location].PlaceDefaultItem()
else:
spoiler.LocationList[location].constant = False
spoiler.LocationList[location].item = None
LocationList[location].constant = False
LocationList[location].item = None
# While we're looping here, also reset shops that became inaccessible due to fill lockouts
if spoiler.LocationList[location].type == Types.Shop:
spoiler.LocationList[location].inaccessible = spoiler.LocationList[location].smallerShopsInaccessible
if LocationList[location].type == Types.Shop:
LocationList[location].inaccessible = LocationList[location].smallerShopsInaccessible
# Make extra sure the Helm Key is right
if settings.key_8_helm:
spoiler.LocationList[Locations.HelmKey].PlaceItem(spoiler, Items.HideoutHelmKey)
LocationList[Locations.HelmKey].PlaceItem(Items.HideoutHelmKey)
# Handle key placements
if settings.shuffle_loading_zones == ShuffleLoadingZones.levels and Types.Key not in settings.shuffled_location_types:
# Place keys in the lobbies they normally belong in
# Ex. Whatever level is in the Japes lobby entrance will always have the Japes key
for level in LevelInfoList.values():
# If level exit isn't shuffled, use vanilla key
if not ShufflableExits[level.TransitionTo].shuffled:
spoiler.LocationList[level.KeyLocation].PlaceConstantItem(spoiler, level.KeyItem)
LocationList[level.KeyLocation].PlaceConstantItem(level.KeyItem)
else:
# Find the transition this exit is attached to, and use that to get the proper location to place this key
dest = ShufflableExits[level.TransitionTo].shuffledId
shuffledTo = [x for x in LevelInfoList.values() if x.TransitionTo == dest][0]
spoiler.LocationList[shuffledTo.KeyLocation].PlaceConstantItem(spoiler, level.KeyItem)
LocationList[shuffledTo.KeyLocation].PlaceConstantItem(level.KeyItem)
# The key in Helm is always Key 8 in these settings
spoiler.LocationList[Locations.HelmKey].PlaceConstantItem(spoiler, Items.HideoutHelmKey)
LocationList[Locations.HelmKey].PlaceConstantItem(Items.HideoutHelmKey)

# Empty out some locations based on the settings
if settings.starting_kongs_count == 5:
spoiler.LocationList[Locations.DiddyKong].PlaceConstantItem(spoiler, Items.NoItem)
spoiler.LocationList[Locations.LankyKong].PlaceConstantItem(spoiler, Items.NoItem)
spoiler.LocationList[Locations.TinyKong].PlaceConstantItem(spoiler, Items.NoItem)
spoiler.LocationList[Locations.ChunkyKong].PlaceConstantItem(spoiler, Items.NoItem)
LocationList[Locations.DiddyKong].PlaceConstantItem(Items.NoItem)
LocationList[Locations.LankyKong].PlaceConstantItem(Items.NoItem)
LocationList[Locations.TinyKong].PlaceConstantItem(Items.NoItem)
LocationList[Locations.ChunkyKong].PlaceConstantItem(Items.NoItem)
if settings.shockwave_status == ShockwaveStatus.start_with:
spoiler.LocationList[Locations.CameraAndShockwave].PlaceConstantItem(spoiler, Items.NoItem)
LocationList[Locations.CameraAndShockwave].PlaceConstantItem(Items.NoItem)
if settings.start_with_slam:
spoiler.LocationList[Locations.IslesFirstMove].PlaceConstantItem(spoiler, Items.ProgressiveSlam)
LocationList[Locations.IslesFirstMove].PlaceConstantItem(Items.ProgressiveSlam)


def AllItems(settings):
Expand Down
2 changes: 1 addition & 1 deletion randomizer/Lists/DoorLocations.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from randomizer.Enums.Levels import Levels
from randomizer.Enums.Regions import Regions
from randomizer.Lists.MapsAndExits import Maps
from randomizer.Logic import Regions as RegionList
from randomizer.LogicClasses import TransitionFront
from randomizer.Logic import RegionsOriginal as RegionList


class DoorData:
Expand Down
47 changes: 27 additions & 20 deletions randomizer/Lists/Location.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,61 +80,61 @@ def __init__(self, level, name, default, location_type, kong=Kongs.any, data=Non
if self.default_mapid_data is not None and len(self.default_mapid_data) > 0 and type(self.default_mapid_data[0]) is MapIDCombo and self.default_mapid_data[0].id == -1 and self.type != Types.Kong:
self.is_reward = True

def PlaceItem(self, spoiler, item):
def PlaceItem(self, item):
"""Place item at this location."""
self.item = item
# If we're placing a real move here, lock out mutually exclusive shop locations
if item != Items.NoItem and self.type == Types.Shop:
for location in ShopLocationReference[self.level][self.vendor]:
if spoiler.LocationList[location].smallerShopsInaccessible:
if LocationList[location].smallerShopsInaccessible:
continue
# If this is a shared spot, lock out kong-specific locations in this shop
if self.kong == Kongs.any and spoiler.LocationList[location].kong != Kongs.any:
spoiler.LocationList[location].inaccessible = True
if self.kong == Kongs.any and LocationList[location].kong != Kongs.any:
LocationList[location].inaccessible = True
# If this is a kong-specific spot, lock out the shared location in this shop
if self.kong != Kongs.any and spoiler.LocationList[location].kong == Kongs.any:
spoiler.LocationList[location].inaccessible = True
if self.kong != Kongs.any and LocationList[location].kong == Kongs.any:
LocationList[location].inaccessible = True
break # There's only one shared spot to block

def PlaceConstantItem(self, spoiler, item):
def PlaceConstantItem(self, item):
"""Place item at this location, and set constant so it's ignored in the spoiler."""
self.PlaceItem(spoiler, item)
self.PlaceItem(item)
self.constant = True

def SetDelayedItem(self, item):
"""Set an item to be added back later."""
self.delayedItem = item

def PlaceDelayedItem(self, spoiler):
def PlaceDelayedItem(self):
"""Place the delayed item at this location."""
self.PlaceItem(spoiler, self.delayedItem)
self.PlaceItem(self.delayedItem)
self.delayedItem = None

def PlaceDefaultItem(self, spoiler):
def PlaceDefaultItem(self):
"""Place whatever this location's default (vanilla) item is at it."""
self.PlaceItem(spoiler, self.default)
self.PlaceItem(self.default)
self.constant = True

def UnplaceItem(self, spoiler):
def UnplaceItem(self):
"""Unplace an item here, which may affect the placement of other items."""
self.item = None
# If this is a shop location, we may have locked out a location we now need to undo
if self.type == Types.Shop:
# Check other locations in this shop
for location_id in ShopLocationReference[self.level][self.vendor]:
if spoiler.LocationList[location_id].smallerShopsInaccessible:
if LocationList[location_id].smallerShopsInaccessible:
continue
if spoiler.LocationList[location_id].kong == Kongs.any and spoiler.LocationList[location_id].inaccessible:
if LocationList[location_id].kong == Kongs.any and LocationList[location_id].inaccessible:
# If there are no other items remaining in this shop, then we can unlock the shared location
itemsInThisShop = len([location for location in ShopLocationReference[self.level][self.vendor] if spoiler.LocationList[location].item not in (None, Items.NoItem)])
itemsInThisShop = len([location for location in ShopLocationReference[self.level][self.vendor] if LocationList[location].item not in (None, Items.NoItem)])
if itemsInThisShop == 0:
spoiler.LocationList[location_id].inaccessible = False
LocationList[location_id].inaccessible = False
# Locations are only inaccessible due to lockouts. If any exist, they're because this location caused them to be locked out.
elif spoiler.LocationList[location_id].inaccessible:
spoiler.LocationList[location_id].inaccessible = False
elif LocationList[location_id].inaccessible:
LocationList[location_id].inaccessible = False


LocationListOriginal = {
LocationList = {
# Training Barrel locations
Locations.IslesVinesTrainingBarrel: Location(Levels.DKIsles, "Isles Vines Training Barrel", Items.Vines, Types.TrainingBarrel, Kongs.any, [123]),
Locations.IslesSwimTrainingBarrel: Location(Levels.DKIsles, "Isles Dive Training Barrel", Items.Swim, Types.TrainingBarrel, Kongs.any, [120]),
Expand Down Expand Up @@ -1103,3 +1103,10 @@ def UnplaceItem(self, spoiler):
]
ShopLocationReference[Levels.DKIsles] = {}
ShopLocationReference[Levels.DKIsles][VendorType.Cranky] = [Locations.DonkeyIslesPotion, Locations.DiddyIslesPotion, Locations.LankyIslesPotion, Locations.TinyIslesPotion, Locations.ChunkyIslesPotion, Locations.SimianSlam]


def ResetLocationList():
"""Reset the LocationList to values conducive to a new fill."""
for location in LocationList.values():
location.PlaceDefaultItem()
# Known to be incomplete - it should also confirm the correct locations of Fairies, Dirt, and Crowns
2 changes: 1 addition & 1 deletion randomizer/Lists/Plandomizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from randomizer.Enums.Plandomizer import ItemToPlandoItemMap, PlandoItems
from randomizer.Enums.Types import Types
from randomizer.Lists.Item import ItemList
from randomizer.Lists.Location import LocationList
from randomizer.Lists.MapsAndExits import RegionMapList
from randomizer.Lists.Minigame import BarrelMetaData, MinigameRequirements
from randomizer.LogicFiles.AngryAztec import LogicRegions as AngryAztecRegions
Expand All @@ -16,7 +17,6 @@
from randomizer.LogicFiles.FungiForest import LogicRegions as FungiForestRegions
from randomizer.LogicFiles.GloomyGalleon import LogicRegions as GloomyGalleonRegions
from randomizer.LogicFiles.JungleJapes import LogicRegions as JungleJapesRegions
from randomizer.Lists.Location import LocationListOriginal as LocationList


def getKongString(kongEnum):
Expand Down
Loading

0 comments on commit e8167de

Please sign in to comment.