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

The Messenger, LADX: use collect and remove as intended #2093

Merged
merged 12 commits into from
Nov 25, 2023

Conversation

alwaysintreble
Copy link
Collaborator

What is this fixing or adding?

Was pointed out to me that I shouldn't be modifying state in collect_item so this fixes that behavior. LADX does nearly the same thing but was failing #2062 so I just copied over the same behavior while I was at it to fix that.

How was this tested?

Unit tests and debug break points to confirm the changes to state were correct.

If this makes graphical changes, please attach screenshots.

@el-u
Copy link
Collaborator

el-u commented Aug 8, 2023

I'll review this later.

Copy link
Collaborator

@el-u el-u left a comment

Choose a reason for hiding this comment

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

Alternative implementation suggestion that should be in line with Berserker's proposal, doing everything that is needed as simply as possible in collect and remove, without any indirection through collect_item.

worlds/messenger/__init__.py Outdated Show resolved Hide resolved
worlds/messenger/__init__.py Outdated Show resolved Hide resolved
worlds/ladx/__init__.py Outdated Show resolved Hide resolved
worlds/ladx/__init__.py Outdated Show resolved Hide resolved
worlds/ladx/__init__.py Outdated Show resolved Hide resolved
worlds/ladx/test/testShop.py Show resolved Hide resolved
worlds/ladx/test/testShop.py Outdated Show resolved Hide resolved
worlds/ladx/test/testShop.py Show resolved Hide resolved
def test_planned(self):
"""Tests plandoing swords in the shop."""
self.multiworld.plando_items[1] = self.options["plando_items"]
distribute_planned(self.multiworld)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems jank.
Set up in this way, distribute_planned is never called when running the default tests in this class, making them effectively useless.
Also, this ends up running distribute_planned after pre_fill, while it is usually the other way round in Main.py.
Ideally, you would find a way to do this with a custom setup that lays everything out properly.
But if that can't be done, try disabling the default tests here at least.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

overrode the world_setup so that the steps are actually called correctly and added that the locations shouldn't be reachable with starting state. I left the default tests to run because that'll also test the locations are reachable with all_state though I guess I could explicit do that and remove the others.

Copy link
Collaborator

@el-u el-u Aug 10, 2023

Choose a reason for hiding this comment

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

Running the default tests is good if they test something that is useful (e.g., that the locations become reachable) and in a scenario that is related to what is being tested in the class (i.e., actually using plando here), which seems to have been achieved now.

[This was written as an answer into the existing review of that test; not sure why GitHub turned it into a separate conversation as well.]

worlds/ladx/test/testShop.py Outdated Show resolved Hide resolved
@el-u
Copy link
Collaborator

el-u commented Aug 8, 2023

It might be worth mentioning explicitly that this PR is supposed to supersede #2064.

def test_planned(self):
"""Tests plandoing swords in the shop."""
self.multiworld.plando_items[1] = self.options["plando_items"]
distribute_planned(self.multiworld)
Copy link
Collaborator

@el-u el-u Aug 10, 2023

Choose a reason for hiding this comment

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

Running the default tests is good if they test something that is useful (e.g., that the locations become reachable) and in a scenario that is related to what is being tested in the class (i.e., actually using plando here), which seems to have been achieved now.

[This was written as an answer into the existing review of that test; not sure why GitHub turned it into a separate conversation as well.]

@el-u
Copy link
Collaborator

el-u commented Aug 10, 2023

How does the updated implementation perform in #2062 now? Does it still suffer from behavior differences between Python versions? (because Counter treated equality comparisons differently before 3.10)

@alwaysintreble
Copy link
Collaborator Author

How does the updated implementation perform in #2062 now? Does it still suffer from behavior differences between Python versions? (because Counter treated equality comparisons differently before 3.10)

I merged that branch locally and ran it on 3.8 and it passes now.

@ThePhar
Copy link
Member

ThePhar commented Aug 16, 2023

Needs review from @zig-for for touched LADX code.

@ThePhar ThePhar added the is: refactor/cleanup Improvements to code/output readability or organizization. label Aug 16, 2023
@zig-for
Copy link
Collaborator

zig-for commented Aug 18, 2023

Can't find the button to approve, but I approve

Copy link
Collaborator

@el-u el-u left a comment

Choose a reason for hiding this comment

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

Can't find the button to approve, but I approve

For future reviews: Go to the "Files changed" tab of the PR. There, at the top right, will be a button to "Review changes". Click that and tick "Approve" in the popup.

@ThePhar
Copy link
Member

ThePhar commented Nov 22, 2023

@alwaysintreble can you resolve these conflicts (maybe merge in main too so newest tests can run) and ping me once it's good? Otherwise, looks fine to me.

image

@alwaysintreble
Copy link
Collaborator Author

@ThePhar

@ThePhar ThePhar merged commit cfe357e into ArchipelagoMW:main Nov 25, 2023
12 checks passed
Jouramie pushed a commit to Jouramie/Archipelago that referenced this pull request Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
is: refactor/cleanup Improvements to code/output readability or organizization.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants