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

Refactor BRFLD #217

Merged
merged 34 commits into from
Oct 17, 2024
Merged

Refactor BRFLD #217

merged 34 commits into from
Oct 17, 2024

Conversation

MayberryZoom
Copy link
Contributor

  • Renames layer arguments to sublayer
  • Adds argument to select layer
  • Renames some methods to reflect this
  • Makes argument naming convention consistent

Copy link

codecov bot commented Aug 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.33%. Comparing base (b4e1076) to head (7f3b6f7).
Report is 35 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #217      +/-   ##
==========================================
+ Coverage   75.54%   76.33%   +0.79%     
==========================================
  Files          78       78              
  Lines        3766     3782      +16     
==========================================
+ Hits         2845     2887      +42     
+ Misses        921      895      -26     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@duncathan duncathan left a comment

Choose a reason for hiding this comment

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

some immediate thoughts: there should be an enum for layer, since it's always exactly the same three options. also, maybe the layer name should be kwarg-only? as-is the order of the args is kinda confusing. could also just swap em and break all the signatures I suppose

src/mercury_engine_data_structures/formats/brfld.py Outdated Show resolved Hide resolved
@MayberryZoom
Copy link
Contributor Author

also, maybe the layer name should be kwarg-only? as-is the order of the args is kinda confusing. could also just swap em and break all the signatures I suppose

I'm not sure about this. In my head it makes the most logical sense to have the actor layer argument first, but most of the time you're going to be working with the entities layer specifically, so you'll only be using sublayer. If sublayer is positional and actor layer is keyword, is there really a point in making it keyword only? Or did you mean make both sublayer and actor layer kwarg only?

I honestly think it's fine as is. It's a bit funky but it should make sense when you're actually using the functions. And in practice it'll be easiest to work with, with the bonus of not breaking all the signatures.

@MayberryZoom MayberryZoom requested a review from duncathan October 7, 2024 20:04
Copy link
Contributor

@steven11sjf steven11sjf left a comment

Choose a reason for hiding this comment

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

Also update tests/formats/test_brfld.py to fix the codecov stuff

src/mercury_engine_data_structures/formats/brfld.py Outdated Show resolved Hide resolved
src/mercury_engine_data_structures/formats/brfld.py Outdated Show resolved Hide resolved
src/mercury_engine_data_structures/formats/brfld.py Outdated Show resolved Hide resolved
Copy link
Member

@henriquegemignani henriquegemignani left a comment

Choose a reason for hiding this comment

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

I'll second the tests request

@MayberryZoom
Copy link
Contributor Author

I added a new method for adding an actor to actor groups that doesn't assume the prefix eg_, since other actor layers use a different prefix (ssg_ for rSoundsLayer and lg_ for rLightsLayer). For now I made the existing add_actor_to_entity_groups use the old signature and had it just call the new add_actor_to_actor_groups with the prefix added, but if we're okay with breaking things, I'd rather have only the new method, personally.

Copy link
Member

@henriquegemignani henriquegemignani left a comment

Choose a reason for hiding this comment

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

Seems fine overall, but I'll leave for @duncathan to do a final say.

Things that would be neat, especially since we're polishing this up:

  • docstrings for the changed methods
  • tests for the other methods as well, such as remove_actor_from_group

@henriquegemignani
Copy link
Member

Ah except for the part where the tests are failing.

@MayberryZoom
Copy link
Contributor Author

Yeah, I just saw that there's a test failing. I'll fix it soon and see if I can get on some of those other improvements.

@steven11sjf
Copy link
Contributor

I added a new method for adding an actor to actor groups that doesn't assume the prefix eg_, since other actor layers use a different prefix (ssg_ for rSoundsLayer and lg_ for rLightsLayer). For now I made the existing add_actor_to_entity_groups use the old signature and had it just call the new add_actor_to_actor_groups with the prefix added, but if we're okay with breaking things, I'd rather have only the new method, personally.

You could add a value to the enum for cc_prefix (make the value ENTITIES = "rEntitiesLayer", "eg_", and override with this in ActorLayer:

@classmethod
def __new__(cls, value: str, prefix: str):
    member = super.__new__(cls, value)
    member.cc_prefix = prefix
    return member

(might wanna cc @henriquegemignani / @duncathan to check if that should be new or init, i'm not sure if it's "pythonic" or whatever lmao)

@MayberryZoom
Copy link
Contributor Author

I added a new method for adding an actor to actor groups that doesn't assume the prefix eg_, since other actor layers use a different prefix (ssg_ for rSoundsLayer and lg_ for rLightsLayer). For now I made the existing add_actor_to_entity_groups use the old signature and had it just call the new add_actor_to_actor_groups with the prefix added, but if we're okay with breaking things, I'd rather have only the new method, personally.

You could add a value to the enum for cc_prefix (make the value ENTITIES = "rEntitiesLayer", "eg_", and override with this in ActorLayer

Honestly, you should probably just be using the prefix when you call the method anyways. Assuming it is really only marginally more readable, while removing some of the library's power. If those 3-4 characters are really too much for someone utilizing this library, they should just subclass or write their own function to do it IMO.

src/mercury_engine_data_structures/formats/brfld.py Outdated Show resolved Hide resolved
tests/formats/test_brfld.py Outdated Show resolved Hide resolved
src/mercury_engine_data_structures/formats/brfld.py Outdated Show resolved Hide resolved
tests/formats/test_brfld.py Outdated Show resolved Hide resolved
tests/formats/test_brfld.py Outdated Show resolved Hide resolved
@duncathan duncathan added this pull request to the merge queue Oct 17, 2024
Merged via the queue into randovania:main with commit 4ccad3f Oct 17, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants