Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BMSEV #205

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Construct type definitions for Mercury Engine
| BMSCU | ✗ | ✗ | ✓ | ✓ |
| BMSEM | ✓ | ✓ | Missing | Missing |
| BMSES | ✓ | ✓ | Missing | Missing |
| BMSEV | ✗ | ✗ | Missing | Missing |
| BMSEV | ✓ | ✓ | Missing | Missing |
| BMSLD | ✓ | ✓ | Missing | Missing |
| BMSLGROUP | Missing | Missing | ✓ | ✓ |
| BMSLINK | Missing | Missing | ✓ | ✓ |
Expand Down
2 changes: 2 additions & 0 deletions src/mercury_engine_data_structures/formats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from mercury_engine_data_structures.formats.bmscu import Bmscu
from mercury_engine_data_structures.formats.bmsem import Bmsem
from mercury_engine_data_structures.formats.bmses import Bmses
from mercury_engine_data_structures.formats.bmsev import Bmsev
from mercury_engine_data_structures.formats.bmsld import Bmsld
from mercury_engine_data_structures.formats.bmslgroup import Bmslgroup
from mercury_engine_data_structures.formats.bmslink import Bmslink
Expand Down Expand Up @@ -70,6 +71,7 @@
"BMSAS": Bmsas,
"BMSAT": Bmsat,
"BMSES": Bmses,
"BMSEV": Bmsev,
"BMTUN": Bmtun,
"BRFLD": Brfld,
"BMDEFS": Bmdefs,
Expand Down
30 changes: 30 additions & 0 deletions src/mercury_engine_data_structures/formats/bmsev.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import functools

from construct import (
Array,
Const,
Construct,
Float32l,
Struct,
Terminated,
)

from mercury_engine_data_structures.common_types import StrId, VersionAdapter, make_vector
from mercury_engine_data_structures.formats.base_resource import BaseResource
from mercury_engine_data_structures.game_check import Game

BMSEV = Struct(
"magic" / Const(b"MSEV"),
"version" / VersionAdapter(),
"elements" / make_vector(Struct(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can probably use make_dict() instead

"name" / StrId,
"unknown_floats" / Array(59, Float32l),
)),
Terminated,
).compile()

class Bmsev(BaseResource):
@classmethod
@functools.lru_cache
def construct_class(cls, target_game: Game) -> Construct:
return BMSEV
25 changes: 25 additions & 0 deletions tests/formats/test_bmsev.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import pytest
from tests.test_lib import parse_build_compare_editor

from mercury_engine_data_structures import samus_returns_data
from mercury_engine_data_structures.formats.bmsev import Bmsev

sr_missing = [
"maps/levels/c10_samus/s901_alpha/s901_alpha.bmsev",
"maps/levels/c10_samus/s902_gamma/s902_gamma.bmsev",
"maps/levels/c10_samus/s903_zeta/s903_zeta.bmsev",
"maps/levels/c10_samus/s904_omega/s904_omega.bmsev",
"maps/levels/c10_samus/s905_arachnus/s905_arachnus.bmsev",
"maps/levels/c10_samus/s905_queen/s905_queen.bmsev",
"maps/levels/c10_samus/s906_metroid/s906_metroid.bmsev",
"maps/levels/c10_samus/s907_manicminerbot/s907_manicminerbot.bmsev",
"maps/levels/c10_samus/s908_manicminerbotrun/s908_manicminerbotrun.bmsev",
"maps/levels/c10_samus/s909_ridley/s909_ridley.bmsev",
"maps/levels/c10_samus/s910_gym/s910_gym.bmsev",
"maps/levels/c10_samus/s911_swarmgym/s911_swarmgym.bmsev",
"maps/levels/c10_samus/s920_traininggallery/s920_traininggallery.bmsev",
]

@pytest.mark.parametrize("bmsev_path", samus_returns_data.all_files_ending_with(".bmsev", sr_missing))
def test_bmsev(samus_returns_tree, bmsev_path):
parse_build_compare_editor(Bmsev, samus_returns_tree, bmsev_path)