Skip to content

Commit

Permalink
Typing and linting fixes for #527
Browse files Browse the repository at this point in the history
  • Loading branch information
theCapypara committed Jul 28, 2024
1 parent ae811c9 commit 0548205
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
10 changes: 8 additions & 2 deletions skytemple_files/common/sprite_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import math

from range_typed_integers import u8

from skytemple_files.common.types.file_types import FileType
from skytemple_files.container.bin_pack.model import BinPack
from skytemple_files.data.md.protocol import MdEntryProtocol
Expand All @@ -37,7 +39,7 @@ def check_and_correct_monster_sprite_size(
monster_bin: BinPack,
sprite_size_table: list[MonsterSpriteDataTableEntry],
is_expand_poke_list_patch_applied: bool = False,
) -> bool:
) -> list[tuple[str, u8, u8]]:
"""
Check that the data in the Pokémon sprite-size metadata
table matches the currently selected sprite of the Pokémon.
Expand All @@ -51,7 +53,11 @@ def check_and_correct_monster_sprite_size(
- sprite_size_table: Sprite size metadata table
- is_expand_poke_list_patch_applied: Whether ExpandPokeList is applied.
Returns True if a change was performed.
Returns a list of changes if a change was performed. Each element contains a tuple:
- Change description (localized)
- Old value
- New value
If changes were performed the data in the following input parameters may be modified and should
be written back to ROM:
Expand Down
3 changes: 0 additions & 3 deletions skytemple_files/patch/handler/expand_poke_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,6 @@ def apply(self, apply: Callable[[], None], rom: NintendoDSRom, config: Pmd2Data)
table_mf = JP_TABLE_MF
table_sp = JP_TABLE_SP
if not self.is_applied(rom, config):
bincfg = config.bin_sections.arm9
binary = bytearray(get_binary_from_rom(rom, bincfg))

# Apply the patch
for filename in get_files_from_rom_with_extension(rom, "str"):
bin_before = rom.getFileByName(filename)
Expand Down
15 changes: 6 additions & 9 deletions skytemple_files/patch/handler/sprite_size.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@
GAME_VERSION_EOS,
Pmd2Data,
)
from skytemple_files.common.types.file_types import FileType
from skytemple_files.common.util import get_binary_from_rom, read_u32
from skytemple_files.data.md.handler import MdHandler
from skytemple_files.patch.category import PatchCategory
from skytemple_files.patch.handler.abstract import AbstractPatchHandler, DependantPatch
from skytemple_files.patch.handler.abstract import AbstractPatchHandler

PATCH_CHECK_ADDR_APPLIED_US = 0x527E4
PATCH_CHECK_ADDR_APPLIED_EU = 0x52B1C
Expand All @@ -47,9 +46,7 @@ def name(self) -> str:

@property
def description(self) -> str:
return _(
"""Changes Sprite Size and Sprite File Size values to be in each Pokémon's data."""
)
return _("""Changes Sprite Size and Sprite File Size values to be in each Pokémon's data.""")

@property
def author(self) -> str:
Expand All @@ -62,7 +59,7 @@ def version(self) -> str:
@property
def category(self) -> PatchCategory:
return PatchCategory.IMPROVEMENT_TWEAK

def is_applied(self, rom: NintendoDSRom, config: Pmd2Data) -> bool:
if config.game_version == GAME_VERSION_EOS:
if config.game_region == GAME_REGION_US:
Expand All @@ -77,7 +74,7 @@ def apply(self, apply: Callable[[], None], rom: NintendoDSRom, config: Pmd2Data)
if not self.is_applied(rom, config):
bincfg = config.bin_sections.arm9
binary = bytearray(get_binary_from_rom(rom, bincfg))

md_bin = rom.getFileByName("BALANCE/monster.md")
md_model = MdHandler.deserialize(md_bin)
block2 = bincfg.data.MONSTER_SPRITE_DATA
Expand All @@ -86,8 +83,8 @@ def apply(self, apply: Callable[[], None], rom: NintendoDSRom, config: Pmd2Data)
+ binary[block2.address : block2.address + block2.length]
)
for i, e in enumerate(md_model.entries):
e.unk17 = data[i*2]
e.unk18 = data[i*2 + 1]
e.unk17 = data[i * 2]
e.unk18 = data[i * 2 + 1]
rom.setFileByName("BALANCE/monster.md", MdHandler.serialize(md_model))
try:
apply()
Expand Down

0 comments on commit 0548205

Please sign in to comment.