From ceda5d3f87c898a472067c681b491386d854bb77 Mon Sep 17 00:00:00 2001 From: Christopher Wells Date: Tue, 17 Oct 2023 21:48:39 -0700 Subject: [PATCH] Parse more info for tape upgrades --- cbpickaxe/monster_form.py | 30 +++++++++++++++++++++--------- pyproject.toml | 2 +- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/cbpickaxe/monster_form.py b/cbpickaxe/monster_form.py index fbfe9ff..fbb1cad 100644 --- a/cbpickaxe/monster_form.py +++ b/cbpickaxe/monster_form.py @@ -15,21 +15,30 @@ class TapeUpgrade: An activity that occurs when a monster tape reaches a specific grade level. """ - name: str - add_slot: bool + name: str #: Internal name of the upgrade. + add_slot: bool #: If True, then the monster gets one additional sticker slot during this upgrade. + sticker: str #: res:// path to the sticker ht eplayer gets when this upgrade occurs. @staticmethod - def from_sub_resource(sub_resource: gp.GDSubResourceSection) -> "TapeUpgrade": + def from_sub_resource( + scene: gp.GDFile, sub_resource: gp.GDSubResourceSection + ) -> "TapeUpgrade": """ Parses the given sub resource into a TapeUpgrade. """ name = sub_resource["resource_name"] add_slot = sub_resource.get("add_slot", default=False) + sticker_resource = sub_resource["sticker"] + + ext_resource = scene.find_ext_resource(id=sticker_resource.id) + assert ext_resource is not None + sticker = ext_resource.path assert isinstance(name, str) assert isinstance(add_slot, bool) + assert isinstance(sticker, str) - return TapeUpgrade(name=name, add_slot=add_slot) + return TapeUpgrade(name=name, add_slot=add_slot, sticker=sticker) @dataclass @@ -248,13 +257,16 @@ def __parse_tape_upgrades( tape_upgrade_ids = section["tape_upgrades"] tape_upgrades: List[Union[TapeUpgrade, str]] = [] for upgrade in tape_upgrade_ids: - sub_resource = scene.find_sub_resource(id=upgrade.id) - if sub_resource is not None: - tape_upgrades.append(TapeUpgrade.from_sub_resource(sub_resource)) + if isinstance(upgrade, gp.SubResource): + sub_resource = scene.find_sub_resource(id=upgrade.id) + assert sub_resource is not None + + tape_upgrades.append(TapeUpgrade.from_sub_resource(scene, sub_resource)) continue + elif isinstance(upgrade, gp.ExtResource): + ext_resource = scene.find_ext_resource(id=upgrade.id) + assert ext_resource is not None - ext_resource = scene.find_ext_resource(id=upgrade.id) - if ext_resource is not None: tape_upgrades.append(ext_resource.path) continue diff --git a/pyproject.toml b/pyproject.toml index 3e66752..09acff5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,4 +7,4 @@ warn_return_any = true warn_unused_ignores = true [tool.pylint] -disable = ["C0301", "R0914", "I1101", "R1705", "R0915", "R0902", "W1203", "R0801", "R0911", "R0912", "R0913"] \ No newline at end of file +disable = ["C0301", "R0914", "I1101", "R1705", "R0915", "R0902", "W1203", "R0801", "R0911", "R0912", "R0913", "R1724"] \ No newline at end of file