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

support until your next turn delayed trigger as shared class with proper Duration #12233

Merged
merged 5 commits into from
May 16, 2024

Conversation

Susucre
Copy link
Contributor

@Susucre Susucre commented May 7, 2024

This makes DelayedTriggeredAbility with Duration.UntilYourNextTurn function as expected. (Before they would never expire).

A new shared class UntilYourNextTurnDelayedTriggeredAbility has been added to make it easy to set up in cards' code. Similarly to ConditionalInterveningIfTriggeredAbility, it is a meta-trigger class that contains an inner trigger (hence the many Overriden methods).

Once this is merged, cards in this search could be rewritten using the new class.

Related to #2078 (Tamiyo still need to be reworked, but wanted to mention it)
Close #11634

@Susucre Susucre marked this pull request as draft May 7, 2024 11:31
@Susucre Susucre marked this pull request as ready for review May 7, 2024 11:37
@@ -539,6 +539,7 @@ public Counters getCounters() {
public void beginTurn(Game game) {
resetLandsPlayed();
updateRange(game);
game.getState().removeTurnStartEffect(game);
Copy link
Contributor Author

@Susucre Susucre May 7, 2024

Choose a reason for hiding this comment

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

When exactly this should be called in Turn::play can be slightly changed if anyone got a stronger opinion.
It should be after the turn's skipping logic is done, but before the first Phase start. In beginTurn seemed like a reasonable choice.

image

Copy link
Member

@JayDi85 JayDi85 May 17, 2024

Choose a reason for hiding this comment

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

It's fine to call it here. But make sure it will support leaving players too:

800.4m. When a player leaves the game, any continuous effects with durations that last until that player's next turn or until a specific point in that turn will last until that turn would have begun. They neither expire immediately nor last indefinitely.

Looks like current code will be never called for leaved player and will keep trigger forever in game state. If it's true then player.hasReachedNextTurnAfterLeaving() will help with it:
shot_240517_095638

Copy link
Contributor Author

@Susucre Susucre May 17, 2024

Choose a reason for hiding this comment

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

Thanks I did miss that.
I'll make test for it, and fix it asap.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So after testing, the DelayedTriggers get cleared once the player leave/concede.
Which is incorrect, but less annoying, as the trigger expires just not at the right time.

By the way, If there are delayed triggers of a left player to stack, who decides stacking order? I need to read more on that in the CR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

800.4d. If an object that would be owned by a player who has left the game would be created in any zone, it isn't created. If a triggered ability that would be controlled by a player who has left the game would be put onto the stack, it isn't put on the stack.

So triggers (which delayed triggers are) for leaving player don't trigger. So current no trigger after player left is correct behavior. I'll add proper cleanup though to not keep DelayedTriggerAbility the whole game.

@Susucre Susucre force-pushed the support-until-your-next-turn branch from eb9e91f to dff6f30 Compare May 16, 2024 11:21
@Susucre Susucre merged commit 3abce2f into magefree:master May 16, 2024
2 checks passed
@JayDi85
Copy link
Member

JayDi85 commented May 17, 2024

Looks like it was unfinished -- you miss effect duration migrate to new logic too, not delayed only:

shot_240517_091625
shot_240517_091223

@Susucre
Copy link
Contributor Author

Susucre commented May 17, 2024

Looks like it was unfinished -- you miss effect duration migrate to new logic too, not delayed only:

This is a way bigger scope, and need careful consideration to apply continuous effects during new turn logic to reapply continuous effects after the removal of the UntilYourNextTurn ones.

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.

Duration.UntilYourNextTurn is not checked for in DelayedTriggeredAbility
2 participants