Skip to content

Commit 16490bb

Browse files
authored
Merge pull request #41 from apple1417/master
more loot rando compat
2 parents 69b64f9 + 9ddd990 commit 16490bb

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

src/legacy_compat/meta_path_finder.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def get_importing_file() -> Path:
9898
raise RuntimeError
9999

100100
@classmethod
101-
def find_spec( # noqa: D102
101+
def find_spec( # noqa: D102, C901
102102
cls,
103103
fullname: str,
104104
path: Sequence[str] | None = None,
@@ -213,5 +213,36 @@ def find_spec( # noqa: D102
213213
),
214214
)
215215

216+
case ("Mod", "Mods.LootRandomizer.Mod.locations"):
217+
return spec_with_replacements(
218+
fullname,
219+
path,
220+
target,
221+
# This one's a break just due to upgrading python. Hints were trying to be a
222+
# string enum before StrEnum was introduced, stringifying them now returns the
223+
# name, not the value.
224+
(
225+
rb"hint_text = self\.item\.hint\.formatter\(self\.item\.hint\)",
226+
b"hint_text = self.item.hint.formatter(self.item.hint.value)",
227+
),
228+
)
229+
230+
case ("Mod", "Mods.LootRandomizer.Mod.hints"):
231+
return spec_with_replacements(
232+
fullname,
233+
path,
234+
target,
235+
# This is a bit of a weird one. Best we can tell, in legacy sdk if you didn't
236+
# specify a struct field, it just left it alone, so this kept whatever the old
237+
# grades data was.
238+
# In new sdk setting an entire struct zero-inits missing fields instead - so add
239+
# back in what we actually want it to be set to.
240+
(
241+
rb"inventory_template.Manufacturers = \(\(manufacturer\),\)",
242+
b"inventory_template.Manufacturers = [(manufacturer[0], "
243+
b"[((1, None), (1, 100), (0.5, None, None, 1), (1, None, None, 1))])]",
244+
),
245+
)
246+
216247
case _, _:
217248
return None

src/mods_base

0 commit comments

Comments
 (0)