magefree / mage

Magic Another Game Engine
http://xmage.today
MIT License
1.8k stars 749 forks source link

Blood Moon tapped lands interaction #8362

Closed Barrots closed 2 years ago

Barrots commented 2 years ago

One of the oldest bug i could find is the interaction with tapped lands and Blood Moon or similar effect (blood sun etc.). The gatherer quote: "If a nonbasic land has an ability that causes it to enter the battlefield tapped, it will lose that ability before it can apply. The same is also true of any other abilities that modify how a land enters the battlefield or apply “as” a land enters the battlefield, such as the first ability of Cavern of Souls."

So in case we place a shockland it should always enter untapped without prompting to pay the 2 damage; and most important when playing a tapped land it should enter untapped without abilities.

Now this interaction shuts down a new modern deck that wants to use blood sun, play lotus field untapped and cast spells right away. I'm afraid that even if it's difficult to fix it's really important.

Thank you for your consideration

Blood Moon: https://gatherer.wizards.com/pages/card/Details.aspx?multiverseid=83008 Blood Sun: https://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=439749

jeffwadsworth commented 2 years ago

There is a better chance of me quantum-tunneling my body through a 10 meter lead door than this getting fixed. It would take a miracle.

4202

Barrots commented 2 years ago

Because there's no feature that check the static effects BEFORE the ETB?

theelk801 commented 2 years ago

it's complicated, making it work correctly isn't easy to do and requires a lot of work

JayDi85 commented 2 years ago

Main problem: current game effects looking for battlefield's permanents and ignores a permanents that entering the battlefield. No effects -- no boosts/changes. There are workaround for counter effects, but it doesn't work with other type of effects. Possible solution: game simulation on ETB to find a real permanent's characteristics (to apply it on permanent).

theelk801 commented 2 years ago

Yeah, I'm thinking something where continuous effects have a method like applyToPermanent and the game uses that when applying the effect normally and also while creatures enter. It just requires a lot of refactoring and I haven't been up to it lately.

Barrots commented 2 years ago

Ok could be a workaround, what if you check how should it enter in the same time you ask if it should enter tapped or not (like for shocklands for example) that check is before entering... Maybe it's too heavy to check all permanents every time?

JayDi85 commented 2 years ago

BTW I had another idea a 2 years ago (until came to the simulation) -- change getBattlefield and related requests to return ETB permanents too. 80% tests / use cases for blood moon rules worked fine, but there were some broken cards, so it require to make additional changes/checks (example: strict mode for getBattlefield to return real objects only).

JayDi85 commented 2 years ago

The main reason for game simulation -- simulation are stable now, you don't need to change anything in the cards like other solutions does, you don't need bugged AI. Just run game simulation, put card on battlefield, apply effects, collect permanent characteristics and apply it to real permanent. You even don't need to resolve anything or choose in the simulation -- just apply current effects.

JayDi85 commented 2 years ago

BUT I didn't test simulation solution, so it can fail somewhere. Only getBattlefield solution had test version with workable proof of concept.

emerald000 commented 2 years ago

The problem with the battlefield fix is that replacement effects only look at what is already on the battlefield and the permanent entering. It doesn't look at other permanents that would be entering at the same time.

JayDi85 commented 2 years ago

It doesn't look at other permanents that would be entering at the same time.

In getBattlefield fix all permanents (battlefield and etb) returns in one list. So effects saw etb permanents as it already entered and apply changes correctly in most use cases.

P.S. I've got what you are talking about -- applying effects must see only one ETB permanent, not all.

awjackson commented 2 years ago

Closing as duplicate