Skip to content

Commit a2b66dd

Browse files
committed
let dev just provide the classification directly
1 parent 3896093 commit a2b66dd

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/__init__.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,16 @@ def create_items(self):
140140
elif type(configs) is dict:
141141
for cat, count in configs.items():
142142
total_created += count
143-
try:
144-
if cat.startswith('0b'):
145-
true_class = ItemClassification(int(cat, base=0))
146-
else:
147-
true_class = ItemClassification[cat]
148-
except Exception as ex:
149-
raise Exception(f"Item override '{cat}' for {name} improperly defined\n\n{type(ex).__name__}:{ex}")
143+
if isinstance(cat, ItemClassification):
144+
true_class = cat
145+
else:
146+
try:
147+
if cat.startswith('0b'):
148+
true_class = ItemClassification(int(cat, base=0))
149+
else:
150+
true_class = ItemClassification[cat]
151+
except Exception as ex:
152+
raise Exception(f"Item override '{cat}' for {name} improperly defined\n\n{type(ex).__name__}:{ex}")
150153

151154
for _ in range(count):
152155
new_item = self.create_item(name, true_class)

src/hooks/World.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def after_create_regions(world: World, multiworld: MultiWorld, player: int):
6262
# {"Item Name": {"progression": 2, "useful": 1}} <- This will create 3 items, with 2 classified as progression and 1 as useful
6363
# {"Item Name": {0b0110: 5}} <- If you know the special flag for the item classes, you can also define non-standard options. This setup
6464
# will create 5 items that are the "useful trap" class
65+
# {"Item Name": {ItemClassification.useful: 5}} <- You can also use the classification directly
6566
def before_create_items_all(item_config: dict[str: int|dict], world: World, multiworld: MultiWorld, player: int) -> dict[str: int|dict]:
6667
return item_config
6768

0 commit comments

Comments
 (0)