Skip to content

Commit c596ca3

Browse files
committed
removed home points
1 parent a79b38e commit c596ca3

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

worlds/crystal_project/__init__.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from .options import CrystalProjectOptions, create_option_groups
2424
from .rules import CrystalProjectLogic
2525
from .mod_helper import ModLocationData, get_modded_items, get_modded_locations, get_modded_home_points, \
26-
get_modded_shopsanity_locations, get_modded_bosses, build_condition_rule, update_item_classification, get_mod_info, get_removed_locations
26+
get_modded_shopsanity_locations, get_modded_bosses, build_condition_rule, update_item_classification, get_mod_info, get_removed_locations, get_removed_home_points
2727
from typing import List, Set, Dict, Any
2828
from worlds.AutoWorld import World, WebWorld
2929
from BaseClasses import Item, Tutorial, MultiWorld, CollectionState, ItemClassification
@@ -104,6 +104,7 @@ class CrystalProjectWorld(World):
104104
item_name_groups.setdefault(MOD, set()).add(modded_home_point.name)
105105

106106
removed_locations = get_removed_locations(mod_info)
107+
removed_home_points = get_removed_home_points(mod_info)
107108

108109
web = CrystalProjectWeb()
109110

@@ -229,11 +230,16 @@ def create_regions(self) -> None:
229230

230231
if self.options.home_point_hustle.value != self.options.home_point_hustle.option_disabled:
231232
home_points = get_home_points()
233+
removed_code_list = [home_point.code for home_point in self.removed_home_points]
232234

233-
# todo removed home points
234235
for home_point in home_points:
235-
home_point_location = LocationData(home_point.ap_region, home_point.name, (home_point.code + home_point_location_index_offset), home_point.rule)
236-
locations.append(home_point_location)
236+
should_add = True
237+
if self.options.use_mods.value == self.options.use_mods.option_true:
238+
should_add = home_point.code not in removed_code_list
239+
240+
if should_add:
241+
home_point_location = LocationData(home_point.ap_region, home_point.name, (home_point.code + home_point_location_index_offset), home_point.rule)
242+
locations.append(home_point_location)
237243

238244
if self.options.use_mods.value == self.options.use_mods.option_true:
239245
for modded_home_point in self.modded_home_points:
@@ -787,6 +793,10 @@ def fill_slot_data(self) -> Dict[str, Any]:
787793
slot_data_removed_locations.append({"Id": location.code,
788794
"APRegion": location.ap_region})
789795

796+
for home_point in self.removed_home_points:
797+
slot_data_removed_home_points.append({"Id": home_point.code,
798+
"APRegion": location.ap_region})
799+
790800
#TODO removed home points
791801

792802
# look into replacing this big chonky return block with self.options.as_dict() and then just adding the extras to the dict after
@@ -829,6 +839,7 @@ def fill_slot_data(self) -> Dict[str, Any]:
829839
"moddedLocations": slot_data_locations,
830840
"moddedHomePoints": slot_data_home_points,
831841
"removedLocations": slot_data_removed_locations,
842+
"removedHomePoints": slot_data_removed_home_points,
832843
# "moddedLocationsForUT": self.modded_locations,
833844
# "moddedShopsForUT": self.modded_shops,
834845
"prefillMap": bool(self.options.fill_full_map.value),

worlds/crystal_project/mod_helper.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,31 @@ def get_removed_locations(mod_info: List[ModInfoModel]) -> List[LocationData]:
413413

414414
return removed_locations
415415

416+
def get_removed_home_points(mod_info: List[ModInfoModel]) -> List[LocationData]:
417+
removed_locations: List[LocationData] = []
418+
vanilla_home_points = get_home_points()
419+
420+
for mod in mod_info:
421+
for location in mod.data_model.Entities:
422+
location_id = location['ID']
423+
has_no_npc_info = location['NpcData'] is None or not location['NpcData']['Pages']
424+
entity_type = location['EntityType']
425+
should_be_removed_because_no_npc_info: bool = False
426+
427+
if has_no_npc_info and location['SignData'] is None and location['SparkData'] is None and location[
428+
'DoorData'] is None and location['HomePointData'] is None and location['TreasureData'] is None and \
429+
location['CrystalData'] is None and location['MarkerData'] is None:
430+
should_be_removed_because_no_npc_info = True
431+
432+
for home_point in vanilla_home_points:
433+
if (home_point.code == location_id and (should_be_removed_because_no_npc_info
434+
# If the item's entity type is definitely not a home point, then remove the vanilla location, because it's type was changed by the mod
435+
or entity_type != HOME_POINT_ENTITY_TYPE)):
436+
removed_locations.append(LocationData(home_point.ap_region, home_point.name, location_id))
437+
break
438+
439+
return removed_locations
440+
416441
def get_mod_directory() -> str:
417442
current_directory = getcwd()
418443
mod_directory = join(current_directory, 'crystal_project_mods')

0 commit comments

Comments
 (0)