Implement excluded locations
This commit is contained in:
parent
54b3a57f46
commit
7493b7f35e
5
Main.py
5
Main.py
|
@ -21,7 +21,7 @@ from Fill import distribute_items_restrictive, flood_items, balance_multiworld_p
|
|||
from worlds.alttp.Shops import create_shops, ShopSlotFill, SHOP_ID_START, total_shop_slots, FillDisabledShopSlots
|
||||
from worlds.alttp.ItemPool import generate_itempool, difficulties, fill_prizes
|
||||
from Utils import output_path, parse_player_names, get_options, __version__, version_tuple
|
||||
from worlds.generic.Rules import locality_rules
|
||||
from worlds.generic.Rules import locality_rules, exclusion_rules
|
||||
from worlds import AutoWorld
|
||||
import Patch
|
||||
|
||||
|
@ -252,6 +252,9 @@ def main(args, seed=None):
|
|||
for player in world.alttp_player_ids:
|
||||
set_rules(world, player)
|
||||
|
||||
for player in world.player_ids:
|
||||
exclusion_rules(world, player, args.excluded_locations[player])
|
||||
|
||||
AutoWorld.call_all(world, "generate_basic")
|
||||
|
||||
logger.info("Running Item Plando")
|
||||
|
|
|
@ -547,6 +547,13 @@ def roll_settings(weights: dict, plando_options: typing.Set[str] = frozenset(("b
|
|||
ret.startinventory = startitems
|
||||
ret.start_hints = set(game_weights.get('start_hints', []))
|
||||
|
||||
ret.excluded_locations = set()
|
||||
for location in game_weights.get('exclude_locations', []):
|
||||
if location in world_type.location_names:
|
||||
ret.excluded_locations.add(location)
|
||||
else:
|
||||
raise Exception(f"Could not exclude location {location}, as it was not recognized.")
|
||||
|
||||
if ret.game in AutoWorldRegister.world_types:
|
||||
for option_name, option in AutoWorldRegister.world_types[ret.game].options.items():
|
||||
if option_name in game_weights:
|
||||
|
|
|
@ -9,6 +9,12 @@ def locality_rules(world, player):
|
|||
forbid_items_for_player(location, world.non_local_items[player], 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))
|
||||
|
||||
|
||||
def set_rule(spot, rule):
|
||||
spot.access_rule = rule
|
||||
|
||||
|
|
Loading…
Reference in New Issue