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

Fix EntersBattlefieldOneOrMoreTriggeredAbility for ZONE_CHANGE_GROUP events making tokens controlled by different players #12592

Conversation

jimga150
Copy link
Contributor

@jimga150 jimga150 commented Jul 19, 2024

Fixes #12588
Will need the be reviewed when #11895 is implemented

@xenohedron
Copy link
Contributor

So, uh, why can't you rewrite EntersBattlefieldOneOrMoreTriggeredAbility to use the new ZONE_CHANGE_BATCH event instead?

@jimga150
Copy link
Contributor Author

Thought the effort was being contained to that issue. Rewritten.

return false;
}
break;
return enteringPermanents.anyMatch(permanent -> controller.hasOpponent(this.controllerId, game));
Copy link
Contributor

Choose a reason for hiding this comment

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

this line looks wrong, it should be checking permanent.getControllerId(). Looks like no ability currently uses TargetController.OPPONENT though.

also, should add a default case to the switch that throws an error (you can imagine a dev trying to use TargetController.ANY and it will silently never trigger)

return false;
}

ZoneChangeBatchEvent zEvent = (ZoneChangeBatchEvent) event;
Stream<Permanent> enteringPermanents = zEvent.getEvents().stream()
Copy link
Member

Choose a reason for hiding this comment

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

Do not use stream fields/params due code style. Use filter with all conditions inside.

return false;
}
break;
return enteringPermanents.anyMatch(permanent -> permanent.getControllerId().equals(this.controllerId));
Copy link
Member

Choose a reason for hiding this comment

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

Use getControllerId() and getTargetController() instead direct access due good code style.

Copy link
Contributor

Choose a reason for hiding this comment

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

targetController is fine to access directly, it's internal to this class. Still need to update to getControllerId() though

.filter(z -> z.getToZone() == Zone.BATTLEFIELD)
.filter(z -> filterPermanent.match(z.getTarget(), this.controllerId, this, game))
.anyMatch(z -> {
UUID enteringPermanantControllerID = z.getTarget().getControllerId();
Copy link
Contributor

Choose a reason for hiding this comment

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

spelling: "Permanent"

@xenohedron xenohedron merged commit c73cfeb into magefree:master Jul 30, 2024
2 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.

Marneus Calgar missing draws
3 participants