Skip to content

[don’t merge] Consider tokens copied from non-stack zone cards also copies#14548

Open
matoro wants to merge 1 commit into
magefree:masterfrom
matoro:anikthea
Open

[don’t merge] Consider tokens copied from non-stack zone cards also copies#14548
matoro wants to merge 1 commit into
magefree:masterfrom
matoro:anikthea

Conversation

@matoro
Copy link
Copy Markdown
Contributor

@matoro matoro commented Feb 24, 2026

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 #14409

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 JayDi85 changed the title Consider tokens copied from non-stack zone cards also copies [don’t merge] Consider tokens copied from non-stack zone cards also copies Feb 24, 2026
@JayDi85 JayDi85 self-assigned this 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());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Image

Image

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.

Aniktheas Enchantment Tokens that transform return the original from the Exile instead of fizzling

2 participants