TLOZ: Code Cleanup (#1514)

- consolidated declaration and population of level location lists
- moved floor_location_game_ids_late declaration for consistency
- moved generate_itempool to create_items, where it belongs
- mention that expanded pool includes take any caves in the option description again
- removed unnecessary StartingPosition check regarding Take Any Caves (leftover from older StartingPosition behavior I believe)
- use proper comparisons to option keys instead of hardcoded ints
This commit is contained in:
t3hf1gm3nt
2023-03-08 05:22:14 -05:00
committed by GitHub
parent 17e90ce12c
commit 5a8e6e61f5
5 changed files with 31 additions and 32 deletions

View File

@@ -3,6 +3,7 @@ from typing import TYPE_CHECKING
from ..generic.Rules import add_rule
from .Locations import food_locations, shop_locations
from .ItemPool import dangerous_weapon_locations
from .Options import StartingPosition
if TYPE_CHECKING:
from . import TLoZWorld
@@ -22,7 +23,8 @@ def set_rules(tloz_world: "TLoZWorld"):
# No dungeons without weapons except for the dangerous weapon locations if we're dangerous, no unsafe dungeons
for i, level in enumerate(tloz_world.levels[1:10]):
for location in level.locations:
if world.StartingPosition[player] < 1 or location.name not in dangerous_weapon_locations:
if world.StartingPosition[player] < StartingPosition.option_dangerous \
or location.name not in dangerous_weapon_locations:
add_rule(world.get_location(location.name, player),
lambda state: state.has_group("weapons", player))
if i > 0: # Don't need an extra heart for Level 1
@@ -107,18 +109,17 @@ def set_rules(tloz_world: "TLoZWorld"):
add_rule(world.get_location(location, player),
lambda state: state.has("Stepladder", player))
if world.StartingPosition[player] != 2:
# Don't allow Take Any Items until we can actually get in one
if world.ExpandedPool[player]:
add_rule(world.get_location("Take Any Item Left", player),
lambda state: state.has_group("candles", player) or
state.has("Raft", player))
add_rule(world.get_location("Take Any Item Middle", player),
lambda state: state.has_group("candles", player) or
state.has("Raft", player))
add_rule(world.get_location("Take Any Item Right", player),
lambda state: state.has_group("candles", player) or
state.has("Raft", player))
# Don't allow Take Any Items until we can actually get in one
if world.ExpandedPool[player]:
add_rule(world.get_location("Take Any Item Left", player),
lambda state: state.has_group("candles", player) or
state.has("Raft", player))
add_rule(world.get_location("Take Any Item Middle", player),
lambda state: state.has_group("candles", player) or
state.has("Raft", player))
add_rule(world.get_location("Take Any Item Right", player),
lambda state: state.has_group("candles", player) or
state.has("Raft", player))
for location in tloz_world.levels[4].locations:
add_rule(world.get_location(location.name, player),
lambda state: state.has("Raft", player) or state.has("Recorder", player))