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

Tests: fix choice on notTarget wrongly not checking Filter #12350

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Susucre
Copy link
Contributor

@Susucre Susucre commented May 31, 2024

Fix an issue with setChoice of non-target choices not validating that the choice matched the target's Filter (also was not using the one with a 4-argument Filter::match).

Of note, we don't have a way to check that is choice is invalid through the checkXXX methods. It would be nice to add at some point. The try/catch way is the current workaround.

@github-actions github-actions bot added the tests label May 31, 2024
@@ -4143,7 +4143,7 @@ public boolean choose(Outcome outcome, Cards cards, TargetCard target, Ability s
continue;
}
if (hasObjectTargetNameOrAlias(card, targetName)) {
if (target.isNotTarget() || target.canTarget(card.getId(), source, game)) {
if (target.canTarget(getId(), card.getId(), source, game)) {
Copy link
Member

Choose a reason for hiding this comment

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

There are three places with such code, not one.

I think it can be used to setup invalid targets for some reasons? If true then that's wrong usage and must be fixed in broken tests.

shot_240531_140410

Copy link
Member

Choose a reason for hiding this comment

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

It's looks like a complex "problem" -- isNotTarget || canTarget used all around xmage:

shot_240531_141532

Copy link
Contributor Author

@Susucre Susucre May 31, 2024

Choose a reason for hiding this comment

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

I don't think there is an issue for real gameplay (we have choices using target code with the notTarget set to true, and that's important to be allowed to sacrifice a shroud creature for instance).

The thing with the test is that we were wrongly accepting some invalid choices. I'm running all the tests with the others 2 instances in TestPlayer without the call to isNotTarget(). I do believe this was wrong usage there and skipped filter validation.

Copy link
Member

Choose a reason for hiding this comment

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

Game engine code is fine -- it's used for checking replacement effects (only real target 🙃 can be restricted by effects):
shot_240531_142206

I think TestPlayer must search targets same way. Example:

shot_240531_142743

Copy link
Member

Choose a reason for hiding this comment

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

That's protection effects can be broken in current test framework (it allow to add restricted target):

shot_240531_144057

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants