Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude-locations updates #30

Merged
merged 3 commits into from
Jul 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions BaseClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,7 @@ class Item():
world: Optional[MultiWorld] = None
game: str = "Generic"
type: str = None
never_exclude = False # change manually to ensure that a specific nonprogression item never goes on an excluded location
pedestal_credit_text: str = "and the Unknown Item"
sickkid_credit_text: Optional[str] = None
magicshop_credit_text: Optional[str] = None
Expand Down
7 changes: 7 additions & 0 deletions Fill.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,15 @@ def distribute_items_restrictive(world: MultiWorld, gftower_trash=False, fill_lo
# get items to distribute
world.random.shuffle(world.itempool)
progitempool = []
nonexcludeditempool = []
localrestitempool = {player: [] for player in range(1, world.players + 1)}
restitempool = []

for item in world.itempool:
if item.advancement:
progitempool.append(item)
elif item.never_exclude: # this only gets nonprogression items which should not appear in excluded locations
nonexcludeditempool.append(item)
elif item.name in world.local_items[item.player]:
localrestitempool[item.player].append(item)
else:
Expand Down Expand Up @@ -137,6 +140,10 @@ def distribute_items_restrictive(world: MultiWorld, gftower_trash=False, fill_lo
world.random.shuffle(fill_locations)
fill_restrictive(world, world.state, fill_locations, progitempool)

if nonexcludeditempool:
world.random.shuffle(fill_locations)
fill_restrictive(world, world.state, fill_locations, nonexcludeditempool) # needs logical fill to not conflict with local items

if any(localrestitempool.values()): # we need to make sure some fills are limited to certain worlds
local_locations = {player: [] for player in world.player_ids}
for location in fill_locations:
Expand Down
2 changes: 1 addition & 1 deletion worlds/generic/Rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def locality_rules(world, player):
def exclusion_rules(world, player: int, excluded_locations: set):
for loc_name in excluded_locations:
location = world.get_location(loc_name, player)
add_item_rule(location, lambda i: not (i.advancement or i.smallkey or i.bigkey))
add_item_rule(location, lambda i: not (i.advancement or i.smallkey or i.bigkey or i.never_exclude))


def set_rule(spot, rule):
Expand Down
6 changes: 3 additions & 3 deletions worlds/minecraft/Items.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ class MinecraftItem(Item):
"4 Emeralds": ItemData(45017, False),
"Channeling Book": ItemData(45018, True),
"Silk Touch Book": ItemData(45019, True),
"Sharpness III Book": ItemData(45020, True),
"Sharpness III Book": ItemData(45020, False),
"Piercing IV Book": ItemData(45021, True),
"Looting III Book": ItemData(45022, True),
"Infinity Book": ItemData(45023, True),
"Looting III Book": ItemData(45022, False),
"Infinity Book": ItemData(45023, False),
"4 Diamond Ore": ItemData(45024, False),
"16 Iron Ore": ItemData(45025, False),
"500 XP": ItemData(45026, False),
Expand Down
5 changes: 4 additions & 1 deletion worlds/minecraft/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,7 @@ def fill_slot_data(self):

def create_item(self, name: str) -> Item:
item_data = item_table[name]
return MinecraftItem(name, item_data.progression, item_data.code, self.player)
item = MinecraftItem(name, item_data.progression, item_data.code, self.player)
if "Book" in name: # prevent enchanted books from being excluded
item.never_exclude = True
return item