Refactorings
This commit is contained in:
parent
b1fb793ea4
commit
c7a315ac97
|
@ -10,7 +10,7 @@ class LocationData(NamedTuple):
|
||||||
code: Optional[int]
|
code: Optional[int]
|
||||||
rule: Callable = lambda state: True
|
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, ...] = (
|
location_table: Tuple[LocationData, ...] = (
|
||||||
# PresentItemLocations
|
# PresentItemLocations
|
||||||
LocationData('Tutorial', 'Yo Momma 1', 1337000),
|
LocationData('Tutorial', 'Yo Momma 1', 1337000),
|
||||||
|
|
|
@ -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")
|
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:
|
def create_location(player: int, location_data: LocationData, region: Region, location_cache: List[Location]) -> Location:
|
||||||
location = Location(player, name, id, region)
|
location = Location(player, location_data.name, location_data.code, region)
|
||||||
location.access_rule = rule
|
location.access_rule = location_data.rule
|
||||||
|
|
||||||
if id is None:
|
if id is None:
|
||||||
location.event = True
|
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:
|
if name in locations_per_region:
|
||||||
for location_data in locations_per_region[name]:
|
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)
|
region.locations.append(location)
|
||||||
|
|
||||||
return region
|
return region
|
||||||
|
|
|
@ -84,25 +84,25 @@ def create_item(name: str, player: int) -> Item:
|
||||||
return Item(name, data.progression, data.code, player)
|
return Item(name, data.progression, data.code, player)
|
||||||
|
|
||||||
|
|
||||||
def get_excluded_items_based_on_options(world: MultiWorld, player: int) -> List[str]:
|
def get_excluded_items_based_on_options(world: MultiWorld, player: int) -> Set[str]:
|
||||||
excluded_items: List[str] = []
|
excluded_items: Set[str] = []
|
||||||
|
|
||||||
if is_option_enabled(world, player, "StartWithJewelryBox"):
|
if is_option_enabled(world, player, "StartWithJewelryBox"):
|
||||||
excluded_items.append('Jewelry Box')
|
excluded_items.add('Jewelry Box')
|
||||||
if is_option_enabled(world, player, "StartWithMeyef"):
|
if is_option_enabled(world, player, "StartWithMeyef"):
|
||||||
excluded_items.append('Meyef')
|
excluded_items.add('Meyef')
|
||||||
if is_option_enabled(world, player, "QuickSeed"):
|
if is_option_enabled(world, player, "QuickSeed"):
|
||||||
excluded_items.append('Talaria Attachment')
|
excluded_items.add('Talaria Attachment')
|
||||||
|
|
||||||
return excluded_items
|
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)
|
melee_weapon = world.random.choice(starter_melee_weapons)
|
||||||
spell = world.random.choice(starter_spells)
|
spell = world.random.choice(starter_spells)
|
||||||
|
|
||||||
excluded_items.append(melee_weapon)
|
excluded_items.add(melee_weapon)
|
||||||
excluded_items.append(spell)
|
excluded_items.add(spell)
|
||||||
|
|
||||||
melee_weapon_item = create_item(melee_weapon, player)
|
melee_weapon_item = create_item(melee_weapon, player)
|
||||||
spell_item = create_item(spell, 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')
|
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] = []
|
pool: List[Item] = []
|
||||||
|
|
||||||
for name, data in item_table.items():
|
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)
|
pool.append(item)
|
||||||
|
|
||||||
|
|
||||||
def place_first_progression_item(world: MultiWorld, player: int, excluded_items: List[str],
|
def place_first_progression_item(world: MultiWorld, player: int, excluded_items: Set[str], locked_locations: List[str]):
|
||||||
locked_locations: List[str]):
|
|
||||||
progression_item = world.random.choice(starter_progression_items)
|
progression_item = world.random.choice(starter_progression_items)
|
||||||
location = world.random.choice(starter_progression_locations)
|
location = world.random.choice(starter_progression_locations)
|
||||||
|
|
||||||
excluded_items.append(progression_item)
|
excluded_items.add(progression_item)
|
||||||
locked_locations.append(location)
|
locked_locations.append(location)
|
||||||
|
|
||||||
item = create_item(progression_item, player)
|
item = create_item(progression_item, player)
|
||||||
|
|
Loading…
Reference in New Issue