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 batch events #11995

Merged
merged 13 commits into from
Mar 29, 2024
Merged

Refactor batch events #11995

merged 13 commits into from
Mar 29, 2024

Conversation

xenohedron
Copy link
Contributor

@xenohedron xenohedron commented Mar 24, 2024

Closes #11985.

The only changed functionality is the new DAMAGED_BATCH_FOR_ALL event, used in five places, to address existing bugs and TODOs that were directly in scope of the refactor. Closes #10773 .

There's good test coverage on these batch events which is nice.

@jimga150
Copy link
Contributor

This all makes sense to me, big fan of how much code was removed with this. looks good

Copy link
Member

@JayDi85 JayDi85 left a comment

Choose a reason for hiding this comment

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

Refactor and code are fine, but some fixes may be missed -- replacement from getPlayerId to getTargetId. See comment with example.

@@ -81,7 +81,7 @@ public boolean checkTrigger(GameEvent event, Game game) {
if (!super.checkTrigger(event, game)) {
return false;
}
Player opponent = game.getPlayer(event.getPlayerId());
Player opponent = game.getPlayer(event.getTargetId());
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 hard to find such replacements from playerId to targetId due multi-classes inheritance. If you manually checked and replaced all related usages then all fine. If you fix it by failed tests then it's bad.

Fast usages search showing a missing fix like:
DAMAGED_BATCH_FOR_ONE_PLAYER -> OneOrMoreDealDamageTriggeredAbility -> DealCombatDamageControlledTriggeredAbility -> FelineSovereignTriggeredAbility:

shot_240326_080958

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good find, I thought I got them all manually but apparently missed that one. multi inheritance certainly complicates that, fortunately since this batch event was recently introduced and not used that many places, it wasn't too bad

# Conflicts:
#	Mage/src/main/java/mage/game/events/LifeLostBatchEvent.java
#	Mage/src/main/java/mage/game/events/LifeLostEvent.java
@xenohedron xenohedron merged commit cb28fb5 into magefree:master Mar 29, 2024
2 checks passed
@xenohedron xenohedron deleted the batchevent branch March 29, 2024 03:19
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.

Rework BatchGameEvent and subclasses to deduplicate code and logic Need a DAMAGED_COMBAT_ALL_BATCH event
3 participants