Skip to content

Commit 579a356

Browse files
committed
bug fix for generation with mods needing to mark items as progression
1 parent 426a444 commit 579a356

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

worlds/crystal_project/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from .options import CrystalProjectOptions, IncludedRegions, create_option_groups
1818
from .rules import CrystalProjectLogic
1919
from .mod_helper import ModLocationData, get_mod_titles, get_modded_items, get_modded_locations, \
20-
get_modded_shopsanity_locations, build_condition_rule
20+
get_modded_shopsanity_locations, build_condition_rule, update_item_classification
2121
from typing import List, Set, Dict, Any
2222
from worlds.AutoWorld import World, WebWorld
2323
from BaseClasses import Item, Tutorial, MultiWorld, CollectionState
@@ -398,6 +398,9 @@ def get_item_pool(self, excluded_items: Set[str]) -> List[Item]:
398398

399399
if self.options.useMods:
400400
for modded_item in self.modded_items:
401+
combined_locations: List[ModLocationData] = list(self.modded_locations.values())
402+
combined_locations.extend(list(self.modded_shops.values()))
403+
update_item_classification(modded_item, [location.rule_condition for location in combined_locations], self)
401404
item = self.create_item(modded_item.name)
402405
pool.append(item)
403406

worlds/crystal_project/mod_helper.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def get_modded_items() -> List[Item]:
9696
name = 'Item - ' + item['Name'] + ' - ' + str(item_id)
9797

9898
if not item_in_pool and not excluded:
99-
mod_item = Item(name, ItemClassification.progression, item_id, empty_player_value)
99+
mod_item = Item(name, ItemClassification.filler, item_id, empty_player_value)
100100

101101
if length_hint([item for (index, item) in enumerate(items) if item.code == mod_item.code]) == 0:
102102
items.append(mod_item)
@@ -120,6 +120,30 @@ def get_modded_items() -> List[Item]:
120120

121121
return items
122122

123+
def update_item_classification(item: Item, rule_condition, world: "CrystalProjectWorld") -> None:
124+
for condition in rule_condition:
125+
if condition is not None:
126+
loot_type = condition['Data']['LootType']
127+
loot_id = condition['Data']['LootValue']
128+
else:
129+
continue
130+
131+
if loot_type == 1:
132+
archipelago_loot_id = loot_id + item_index_offset
133+
elif loot_type == 2:
134+
archipelago_loot_id = loot_id + equipment_index_offset
135+
else:
136+
continue
137+
138+
if archipelago_loot_id in world.item_id_to_name:
139+
item_name = world.item_id_to_name[archipelago_loot_id]
140+
if item.name == item_name:
141+
item.classification = ItemClassification.progression
142+
else:
143+
continue
144+
145+
return None
146+
123147
def get_modded_locations() -> Dict[str, ModLocationData]:
124148
locations: Dict[str, ModLocationData] = {}
125149
location_codes: List[int] = []

0 commit comments

Comments
 (0)