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

[don’t merge] Fix and test Rain of Riches #12127

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

Conversation

Susucre
Copy link
Contributor

@Susucre Susucre commented Apr 14, 2024

Fix [[Rain of Riches]] using Predicate logic.

We need to ensure continuous effects are recomputed between the Mana Payment from spell.activate and SPELL_CAST event for this card to work properly. Hence the added game.getState().processAction(game); (if you remove it, 2 of the added tests fail)

Fix #12125
Fix #10347
Fix #9669

@Susucre
Copy link
Contributor Author

Susucre commented Apr 14, 2024

Just to give a little detail on the added processAction(game):

The activate call in PlayerImpl is for Spell::activate, which call for multiple ActivatedImpl::activate.

There you have a call to game.applyEffects at the beginning:
image

But after payment, there is no reprocess for the effects, hence the watchers/triggers reacting to SPELL_CAST not seeing up to date information.

@magefree magefree deleted a comment from github-actions bot Apr 14, 2024
@alexander-novo
Copy link
Contributor

This is the same fix I used in #9785.

According to Jaydi, there is a problem with adding processAction here.

@Susucre
Copy link
Contributor Author

Susucre commented Apr 14, 2024

Well I have provided an actual reason for the change: the current applyEffect is before any MANA_PAID events are fired, and we need ContinuousEffect to be recomputed after those events and before SPELL_CAST is fired. It could actually be done at the end of one of the activate method instead.

If that is still wrong to do, I'd need an actual situation and a reasoning where it could go wrong.

@alexander-novo
Copy link
Contributor

alexander-novo commented Apr 14, 2024

Yeah that was the same reasoning I provided e.g. here. So you can ask jaydi what's wrong with it, which is something I've been trying to do for a while now.

@JayDi85
Copy link
Member

JayDi85 commented Apr 14, 2024

It could actually be done at the end of one of the activate method instead

Adding ApplyEffects to fix something is popular hack and the biggest bad smell. It’s not a real fix in most use cases.

@JayDi85 JayDi85 self-assigned this Apr 14, 2024
@JayDi85 JayDi85 changed the title Fix and test Rain of Riches [don’t Fix and test Rain of Riches Apr 14, 2024
@JayDi85 JayDi85 changed the title [don’t Fix and test Rain of Riches [don’t merge] Fix and test Rain of Riches Apr 14, 2024
@Susucre
Copy link
Contributor Author

Susucre commented Apr 14, 2024

But it is not an hack here. You have to reapply the continuous effect inbetween mana being paid for casting the spell (since you can not know a Treasure is used before), and the spell being moved to the stack and SPELL_CAST triggers.

The current engine does not have proper game info on Spell Cast firing.

@JayDi85
Copy link
Member

JayDi85 commented Apr 14, 2024

I’ll look to it later.

@JayDi85
Copy link
Member

JayDi85 commented Apr 14, 2024

You have to reapply the continuous effect inbetween mana being paid for casting the spell

It’s not about reapply single effect. A real game can have hundreds effects. It’s about whole game “reset”: another effects, events, triggers, etc. That’s why it’s a dangerous command.

@Susucre
Copy link
Contributor Author

Susucre commented Apr 14, 2024

There is a call to processAction before each mana being paid on casting spells.
Are you really telling me that the one after the last mana being paid is dangerous (arrow on the one added here)?
image

@Susucre
Copy link
Contributor Author

Susucre commented Apr 14, 2024

Haven't investigated that one yet, but I hugely suspect #12089 to be the same issue of not processing the last payment properly on activating abilities:
image

@xenohedron
Copy link
Contributor

I support merging this change.

While indiscriminate usage of game.getState().processAction(game) in the engine is indeed a concern, I think it's pretty clear that it is necessary here in order to support mtg rules. As Susucr points out, it is already being called many times in the sequence of actions to reproduce the bug that would occur without this additional call. I do not see an issue with it. This fix has been waiting for over a year.

@Susucre
Copy link
Contributor Author

Susucre commented Apr 26, 2024

I’ll look to it later.

@JayDi85 so how it's looking?

@JayDi85
Copy link
Member

JayDi85 commented Apr 26, 2024

In todo

@xenohedron xenohedron changed the title [don’t merge] Fix and test Rain of Riches Fix and test Rain of Riches May 22, 2024
Copy link
Contributor

@xenohedron xenohedron left a comment

Choose a reason for hiding this comment

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

Without any actionable feedback there is no point in delaying this further. There can always be followup improvements.

@JayDi85 JayDi85 changed the title Fix and test Rain of Riches [don’t merge] Fix and test Rain of Riches May 22, 2024
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.

Rain of Riches - No Cascade BUG / Rain of Riches does not work Rain of Riches does not cascade
4 participants