Refactorings

This commit is contained in:
Jarno Westhof 2021-10-09 11:58:38 +02:00 committed by Fabian Dill
parent b1fb793ea4
commit c7a315ac97
3 changed files with 16 additions and 17 deletions

View File

@ -10,7 +10,7 @@ class LocationData(NamedTuple):
code: Optional[int]
rule: Callable = lambda state: True
def get_locations(world: Optional[MultiWorld], player: Optional[int]):
def get_locations(world: Optional[MultiWorld], player: Optional[int]) -> Tuple[LocationData, ...]:
location_table: Tuple[LocationData, ...] = (
# PresentItemLocations
LocationData('Tutorial', 'Yo Momma 1', 1337000),

View File

@ -150,9 +150,9 @@ def create_regions(world: MultiWorld, player: int, locations: Tuple[LocationData
connect(world, player, names, 'Space time continuum', 'Caves of Banishment (upper)', lambda state: pyramid_keys_unlock == "GateCavesOfBanishment")
def create_location(player: int, name: str, id: Optional[int], region: Region, rule: Callable, location_cache: List[Location]) -> Location:
location = Location(player, name, id, region)
location.access_rule = rule
def create_location(player: int, location_data: LocationData, region: Region, location_cache: List[Location]) -> Location:
location = Location(player, location_data.name, location_data.code, region)
location.access_rule = location_data.rule
if id is None:
location.event = True
@ -169,7 +169,7 @@ def create_region(world: MultiWorld, player: int, locations_per_region: Dict[str
if name in locations_per_region:
for location_data in locations_per_region[name]:
location = create_location(player, location_data.name, location_data.code, region, location_data.rule, location_cache)
location = create_location(player, location_data, region, location_cache)
region.locations.append(location)
return region

View File

@ -84,25 +84,25 @@ def create_item(name: str, player: int) -> Item:
return Item(name, data.progression, data.code, player)
def get_excluded_items_based_on_options(world: MultiWorld, player: int) -> List[str]:
excluded_items: List[str] = []
def get_excluded_items_based_on_options(world: MultiWorld, player: int) -> Set[str]:
excluded_items: Set[str] = []
if is_option_enabled(world, player, "StartWithJewelryBox"):
excluded_items.append('Jewelry Box')
excluded_items.add('Jewelry Box')
if is_option_enabled(world, player, "StartWithMeyef"):
excluded_items.append('Meyef')
excluded_items.add('Meyef')
if is_option_enabled(world, player, "QuickSeed"):
excluded_items.append('Talaria Attachment')
excluded_items.add('Talaria Attachment')
return excluded_items
def assign_starter_items(world: MultiWorld, player: int, excluded_items: List[str], locked_locations: List[str]):
def assign_starter_items(world: MultiWorld, player: int, excluded_items: Set[str], locked_locations: List[str]):
melee_weapon = world.random.choice(starter_melee_weapons)
spell = world.random.choice(starter_spells)
excluded_items.append(melee_weapon)
excluded_items.append(spell)
excluded_items.add(melee_weapon)
excluded_items.add(spell)
melee_weapon_item = create_item(melee_weapon, player)
spell_item = create_item(spell, player)
@ -114,7 +114,7 @@ def assign_starter_items(world: MultiWorld, player: int, excluded_items: List[st
locked_locations.append('Yo Momma 2')
def get_item_pool(world: MultiWorld, player: int, excluded_items: List[str]) -> List[Item]:
def get_item_pool(world: MultiWorld, player: int, excluded_items: Set[str]) -> List[Item]:
pool: List[Item] = []
for name, data in item_table.items():
@ -132,12 +132,11 @@ def fill_item_pool_with_dummy_items(world: MultiWorld, player: int, locked_locat
pool.append(item)
def place_first_progression_item(world: MultiWorld, player: int, excluded_items: List[str],
locked_locations: List[str]):
def place_first_progression_item(world: MultiWorld, player: int, excluded_items: Set[str], locked_locations: List[str]):
progression_item = world.random.choice(starter_progression_items)
location = world.random.choice(starter_progression_locations)
excluded_items.append(progression_item)
excluded_items.add(progression_item)
locked_locations.append(location)
item = create_item(progression_item, player)