Skip to content

Commit 2ea1884

Browse files
authored
Merge pull request #314 from Emerassi/homepointhustlerefactor
refactor homepoints so they don't need as much special logic. Also f…
2 parents 7fd6a4b + 168f006 commit 2ea1884

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

worlds/crystal_project/__init__.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
from .constants.teleport_stones import *
1010
from .constants.item_groups import *
1111
from .constants.region_passes import *
12+
from .home_points import get_home_points
1213
from .items import item_table, optional_scholar_abilities, get_random_starting_jobs, filler_items, \
1314
get_item_names_per_category, progressive_equipment, non_progressive_equipment, get_starting_jobs, \
1415
set_jobs_at_default_locations, default_starting_job_list, key_rings, dungeon_keys, singleton_keys, \
15-
display_region_name_to_pass_dict, job_crystal_beginner_dictionary, job_crystal_advanced_dictionary, job_crystal_expert_dictionary, home_point_item_index_offset
16-
from .home_points import get_home_points
16+
display_region_name_to_pass_dict, job_crystal_beginner_dictionary, job_crystal_advanced_dictionary, job_crystal_expert_dictionary, home_point_item_index_offset, ItemData
1717
from .locations import get_treasure_and_npc_locations, get_boss_locations, get_shop_locations, get_region_completion_locations, LocationData, get_location_names_per_category, \
1818
get_location_name_to_id, get_crystal_locations, home_point_location_index_offset
1919
from .presets import crystal_project_options_presets
@@ -49,6 +49,11 @@ class CrystalProjectWorld(World):
4949
options: CrystalProjectOptions
5050
topology_present = True # show path to required location checks in spoiler
5151

52+
# Add the homepoints to the item_table so they don't require any special code after this
53+
home_points = get_home_points(-1, options)
54+
for home_point in home_points:
55+
item_table[home_point.name] = ItemData(HOME_POINT, home_point.code + home_point_item_index_offset, ItemClassification.progression)
56+
5257
item_name_to_id = {item: item_table[item].code for item in item_table}
5358
location_name_to_id = get_location_name_to_id()
5459

@@ -58,7 +63,6 @@ class CrystalProjectWorld(World):
5863

5964
mod_info = get_mod_info()
6065
modded_items = get_modded_items(mod_info)
61-
home_points = get_home_points(-1, options)
6266
modded_job_count: int = 0
6367

6468
for modded_item in modded_items:
@@ -71,11 +75,6 @@ class CrystalProjectWorld(World):
7175
else:
7276
item_name_groups.setdefault(MOD, set()).add(modded_item.name)
7377

74-
for home_point in home_points:
75-
item_name_to_id[home_point.name] = (home_point.code + home_point_item_index_offset)
76-
item_name_groups.setdefault(HOME_POINT, set()).add(home_point.name)
77-
location_name_to_id[home_point.name] = (home_point.code + home_point_location_index_offset)
78-
7978
modded_locations = get_modded_locations(mod_info)
8079

8180
for modded_location in modded_locations:
@@ -301,12 +300,8 @@ def create_item(self, name: str) -> Item:
301300
return Item(name, data.classification, data.code, self.player)
302301
else:
303302
matches_mod = [item for (index, item) in enumerate(self.modded_items) if item.name == name]
304-
matches_home_point = [item for (index, item) in enumerate(self.home_points) if item.name == name]
305303

306-
if len(matches_mod) > 0:
307-
return Item(matches_mod[0].name, matches_mod[0].classification, matches_mod[0].code, self.player)
308-
else:
309-
return Item(matches_home_point[0].name, ItemClassification.progression, (matches_home_point[0].code + home_point_item_index_offset), self.player)
304+
return Item(matches_mod[0].name, matches_mod[0].classification, matches_mod[0].code, self.player)
310305

311306
def create_items(self) -> None:
312307
pool = self.get_item_pool(self.get_excluded_items())

worlds/crystal_project/home_points.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from .locations import LocationData
77
from .options import CrystalProjectOptions
88
from .rules import CrystalProjectLogic
9+
910
#Remember if you update the AP Region a Home Point is in or its name, go change it in the Menu connections function in the region.py file
1011
def get_home_points(player: Optional[int], options: Optional[CrystalProjectOptions]) -> List[LocationData]:
1112
logic = CrystalProjectLogic(player, options)

worlds/crystal_project/locations.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,18 @@ class LocationData(NamedTuple):
2828
home_point_location_index_offset = 1000000000
2929

3030
def get_location_name_to_id() -> dict[str, int]:
31+
from .home_points import get_home_points
32+
3133
location_name_to_id = {location.name: location.code for location in get_treasure_and_npc_locations(-1, None)}
3234
crystal_name_to_id = {crystal.name: crystal.code for crystal in get_crystal_locations(-1, None)}
3335
boss_name_to_id = {boss.name: boss.code for boss in get_boss_locations(-1, None)}
3436
shop_name_to_id = {shop.name: shop.code for shop in get_shop_locations(-1, None)}
37+
homepoint_name_to_id = {homepoint.name: homepoint.code + home_point_location_index_offset for homepoint in get_home_points(-1, None)}
3538
region_completion_name_to_id = {region_completion.name: region_completion.code for region_completion in get_region_completion_locations(-1, None)}
3639
location_name_to_id.update(crystal_name_to_id)
3740
location_name_to_id.update(boss_name_to_id)
3841
location_name_to_id.update(shop_name_to_id)
42+
location_name_to_id.update(homepoint_name_to_id)
3943
location_name_to_id.update(region_completion_name_to_id)
4044

4145
return location_name_to_id
@@ -1993,6 +1997,8 @@ def get_region_completion_locations(player: int, options: CrystalProjectOptions)
19931997
def get_location_names_per_category() -> Dict[str, Set[str]]:
19941998
categories: Dict[str, Set[str]] = {}
19951999

2000+
from .home_points import get_home_points
2001+
19962002
for location in get_crystal_locations(-1, None):
19972003
categories.setdefault("Crystals", set()).add(location.name)
19982004

@@ -2002,6 +2008,9 @@ def get_location_names_per_category() -> Dict[str, Set[str]]:
20022008
for location in get_boss_locations(-1, None):
20032009
categories.setdefault("Bosses", set()).add(location.name)
20042010

2011+
for location in get_home_points(-1, None):
2012+
categories.setdefault("Homepoints", set()).add(location.name)
2013+
20052014
for location in get_region_completion_locations(-1, None):
20062015
categories.setdefault("Region Completions", set()).add(location.name)
20072016

worlds/crystal_project/regions.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ def fancy_add_exits(self, region: str, exits: List[str],
10071007
def connect_menu_region(world: "CrystalProjectWorld", options: CrystalProjectOptions) -> None:
10081008
logic = CrystalProjectLogic(world.player, options)
10091009

1010-
fancy_add_exits(world, MENU_AP_REGION, [SPAWNING_MEADOWS_AP_REGION, DELENDE_PLAINS_AP_REGION, DELENDE_HIGH_BRIDGES_AP_REGION, DELENDE_PEAK_AP_REGION, MERCURY_SHRINE_AP_REGION, THE_PALE_GROTTO_AP_REGION, SEASIDE_CLIFFS_AP_REGION, YAMAGAWA_MA_AP_REGION, PROVING_MEADOWS_AP_REGION, SKUMPARADISE_AP_REGION, CAPITAL_SEQUOIA_AP_REGION, CAPITAL_JAIL_AP_REGION, ROLLING_QUINTAR_FIELDS_AP_REGION, SANCTUM_ENTRANCE_AP_REGION, QUINTAR_SANCTUM_AP_REGION, BOOMER_SOCIETY_AP_REGION, OKIMOTO_NS_AP_REGION, SALMON_PASS_EAST_AP_REGION, SALMON_RIVER_AP_REGION, CASTLE_SEQUOIA_AP_REGION, TOWER_OF_ZOT_AP_REGION, POKO_POKO_DESERT_AP_REGION, SARA_SARA_BAZAAR_AP_REGION, IBEK_CAVE_MOUTH_AP_REGION, BEACH_BIRDS_NEST_AP_REGION, BEAURIOR_VOLCANO_AP_REGION, BEAURIOR_ROCK_AP_REGION, ANCIENT_RESERVOIR_AP_REGION, SHOUDU_PROVINCE_AP_REGION, GANYMEDE_SHRINE_AP_REGION, THE_UNDERCITY_AP_REGION, PIPELINE_NORTH_AP_REGION, PIPELINE_SOUTH_AP_REGION, SEQUOIA_ATHENAEUM_ENTRANCE_AP_REGION, LOWER_ICE_LAKES_AP_REGION, SOUVENIR_SHOP_AP_REGION, SLIP_GLIDE_RIDE_EXIT_AP_REGION, UPPER_ICE_LAKES_AP_REGION, TALL_TALL_SAVE_POINT_AP_REGION, PEAK_RAMPARTS_AP_REGION, SLIP_GLIDE_RIDE_ENTRANCE_AP_REGION, LANDS_END_AP_REGION, OWL_TREE_AP_REGION, QUINTAR_RESERVE_AP_REGION, EUROPA_SHRINE_AP_REGION, JIDAMBA_EACLANEYA_AP_REGION, LABYRINTH_CORE_AP_REGION, DIONE_SHRINE_AP_REGION, DIONE_ROOF_AP_REGION, THE_SEQUOIA_AP_REGION, THE_CHALICE_OF_TAR_AP_REGION, THE_OPEN_SEA_AP_REGION, CONTINENTAL_TRAM_AP_REGION, POSEIDON_SHRINE_ROOF_AP_REGION, NEPTUNE_SHRINE_AP_REGION, THE_OLD_WORLD_AP_REGION, THE_NEW_WORLD_AP_REGION, MODDED_ZONE_AP_REGION],
1010+
fancy_add_exits(world, MENU_AP_REGION, [SPAWNING_MEADOWS_AP_REGION, DELENDE_PLAINS_AP_REGION, DELENDE_HIGH_BRIDGES_AP_REGION, DELENDE_PEAK_AP_REGION, MERCURY_SHRINE_AP_REGION, THE_PALE_GROTTO_AP_REGION, SEASIDE_CLIFFS_AP_REGION, YAMAGAWA_MA_AP_REGION, PROVING_MEADOWS_AP_REGION, SKUMPARADISE_AP_REGION, CAPITAL_SEQUOIA_AP_REGION, CAPITAL_JAIL_AP_REGION, ROLLING_QUINTAR_FIELDS_AP_REGION, SANCTUM_ENTRANCE_AP_REGION, QUINTAR_SANCTUM_AP_REGION, BOOMER_SOCIETY_AP_REGION, OKIMOTO_NS_AP_REGION, SALMON_PASS_EAST_AP_REGION, SALMON_RIVER_AP_REGION, CASTLE_SEQUOIA_AP_REGION, TOWER_OF_ZOT_AP_REGION, POKO_POKO_DESERT_AP_REGION, SARA_SARA_BAZAAR_AP_REGION, IBEK_CAVE_MOUTH_AP_REGION, BEACH_BIRDS_NEST_AP_REGION, BEAURIOR_VOLCANO_AP_REGION, BEAURIOR_ROCK_AP_REGION, ANCIENT_RESERVOIR_AP_REGION, SHOUDU_PROVINCE_AP_REGION, GANYMEDE_SHRINE_AP_REGION, THE_UNDERCITY_AP_REGION, PIPELINE_NORTH_AP_REGION, PIPELINE_SOUTH_AP_REGION, SEQUOIA_ATHENAEUM_ENTRANCE_AP_REGION, LOWER_ICE_LAKES_AP_REGION, SOUVENIR_SHOP_AP_REGION, SLIP_GLIDE_RIDE_EXIT_AP_REGION, UPPER_ICE_LAKES_AP_REGION, TALL_TALL_SAVE_POINT_AP_REGION, PEAK_RAMPARTS_AP_REGION, SLIP_GLIDE_RIDE_ENTRANCE_AP_REGION, LANDS_END_AP_REGION, OWL_TREE_AP_REGION, QUINTAR_RESERVE_AP_REGION, EUROPA_SHRINE_AP_REGION, JIDAMBA_EACLANEYA_AP_REGION, LABYRINTH_CORE_AP_REGION, DIONE_SHRINE_AP_REGION, DIONE_ROOF_AP_REGION, THE_SEQUOIA_AP_REGION, THE_CHALICE_OF_TAR_AP_REGION, THE_OPEN_SEA_AP_REGION, CONTINENTAL_TRAM_AP_REGION, POSEIDON_SHRINE_ROOF_AP_REGION, NEPTUNE_SHRINE_AP_REGION, THE_OLD_WORLD_AP_REGION, THE_NEW_WORLD_AP_REGION, DISCIPLINE_HOLLOW_AP_REGION, MODDED_ZONE_AP_REGION],
10111011
{SPAWNING_MEADOWS_AP_REGION: lambda state: (options.regionsanity.value == options.regionsanity.option_disabled or state.has("HomePoint - AP Spawn Point", world.player) or state.has("HomePoint - Old Nan's Watering Hole", world.player)),
10121012
DELENDE_PLAINS_AP_REGION: lambda state: (state.has("HomePoint - The Pale Grotto Entrance", world.player) or state.has("HomePoint - Soiled Den", world.player) or state.has("HomePoint - Fish Hatchery", world.player)),
10131013
DELENDE_HIGH_BRIDGES_AP_REGION: lambda state: (state.has("HomePoint - Cabin On The Cliff", world.player) or state.has("HomePoint - Delende Falls", world.player)),
@@ -1064,5 +1064,7 @@ def connect_menu_region(world: "CrystalProjectWorld", options: CrystalProjectOpt
10641064
POSEIDON_SHRINE_ROOF_AP_REGION: lambda state: state.has(POSEIDON_STONE, world.player),
10651065
NEPTUNE_SHRINE_AP_REGION: lambda state: (state.has(NEPTUNE_STONE, world.player) or state.has("HomePoint - Neptune Shrine", world.player)),
10661066
THE_OLD_WORLD_AP_REGION: lambda state: logic.old_world_requirements(state),
1067-
THE_NEW_WORLD_AP_REGION: lambda state: (logic.new_world_requirements(state) or state.has("HomePoint - Astley's Shrine", world.player) or state.has("HomePoint - Astley's Keep", world.player) or state.has("HomePoint - Discipline Hollow", world.player))})
1067+
THE_NEW_WORLD_AP_REGION: lambda state: (logic.new_world_requirements(state) or state.has("HomePoint - Astley's Shrine", world.player) or state.has("HomePoint - Astley's Keep", world.player)),
1068+
DISCIPLINE_HOLLOW_AP_REGION: lambda state: state.has("HomePoint - Discipline Hollow", world.player),
1069+
}),
10681070
world.multiworld.register_indirect_condition(world.get_region(THE_DEPTHS_AP_REGION), world.get_entrance(MENU_AP_REGION + " -> " + THE_OLD_WORLD_AP_REGION))

0 commit comments

Comments
 (0)