[don’t merge] Consider tokens copied from non-stack zone cards also copies#14548
Open
matoro wants to merge 1 commit into
Open
[don’t merge] Consider tokens copied from non-stack zone cards also copies#14548matoro wants to merge 1 commit into
matoro wants to merge 1 commit into
Conversation
The problem here is kind of hard to follow, but currently a `PermanentToken` that is a copy of a card in a zone other than the stack returns `false` for `isCopy()`. However, it will point to the thing it was copied from in `getMainCard()`, and the result of `getMainCard()` is used when deciding what object to move between zones. So when blinking that token, after the first move if the copy source still existed, it would move even after the token stopped existing. I believe `getMainCard()` is really meant to refer to the overall card for split, double-faced, etc cards, which a token still has. Instead, any behavior that specifically needs to refer to the source that the token was copied from, e.g. to get information about it, should go through `token.getCopySourceCard()`. I've exposed that via `getCopyFrom()`, so that callers don't need to explicitly check if a permanent is a token. So far Room cards do that, to get information about what room were unlocked when copying. Fixes magefree#14409
JayDi85
reviewed
Feb 24, 2026
| // Get the parent card to access the lastCastHalf variable | ||
| if (permanent instanceof PermanentToken) { | ||
| Card mainCard = permanent.getMainCard(); | ||
| Card mainCard = game.getCard((permanent.isCopy() ? permanent.getCopyFrom() : permanent).getId()); |
Member
There was a problem hiding this comment.
that’s getCopyFrom smells bad and used in 2 places: room and one copy effect only matoro@d13a0e6
Need research of original usage and possible remove at all. Maybe I’ll look later.
P.S. rooms code is bad too… it’s modify non-modifiable field and can break game on rollback or AI sims in theory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


The problem here is kind of hard to follow, but currently a
PermanentTokenthat is a copy of a card in a zone other than the stack returnsfalseforisCopy(). However, it will point to the thing it was copied from ingetMainCard(), and the result ofgetMainCard()is used when deciding what object to move between zones. So when blinking that token, after the first move if the copy source still existed, it would move even after the token stopped existing.I believe
getMainCard()is really meant to refer to the overall card for split, double-faced, etc cards, which a token still has. Instead, any behavior that specifically needs to refer to the source that the token was copied from, e.g. to get information about it, should go throughtoken.getCopySourceCard(). I've exposed that viagetCopyFrom(), so that callers don't need to explicitly check if a permanent is a token. So far Room cards do that, to get information about what room were unlocked when copying.Fixes #14409