Skip to content

Commit

Permalink
Parse more info for tape upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
ExcaliburZero committed Oct 18, 2023
1 parent b948067 commit ceda5d3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
30 changes: 21 additions & 9 deletions cbpickaxe/monster_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
disable = ["C0301", "R0914", "I1101", "R1705", "R0915", "R0902", "W1203", "R0801", "R0911", "R0912", "R0913", "R1724"]

0 comments on commit ceda5d3

Please sign in to comment.