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

A transformed card with a static copy ability does not work #11683

Open
DominionSpy opened this issue Jan 19, 2024 · 2 comments · May be fixed by #12055
Open

A transformed card with a static copy ability does not work #11683

DominionSpy opened this issue Jan 19, 2024 · 2 comments · May be fixed by #12055
Labels
bug Bugs and errors Developers Discussion Discussion about redesign or changes refactoring Developers topics about code and programming

Comments

@DominionSpy
Copy link
Contributor

DominionSpy commented Jan 19, 2024

While attempting to implement [[Paleontologist's Pick-Axe // Dinosaur Headdress]], I found that the third ability of the second side (Dinosaur Headdress), does not work (#11677).

The ability is:

Equipped creature is a copy of the last chosen card.

The "chosen card" is a reference to the previous ability:

As Dinosaur Headdress becomes attached to a creature, choose an exiled creature card used to craft Dinosaur Headdress.

Transform effects are currently implemented in the continuous layered effects logic.

TransformEffect

class TransformEffect extends ContinuousEffectImpl {

    TransformEffect() {
        super(Duration.WhileOnBattlefield, Layer.TransformEffects_1, SubLayer.CopyEffects_1a, Outcome.BecomeCreature);
        staticText = "";
    }

    private TransformEffect(final TransformEffect effect) {
        super(effect);
    }

    @Override
    public boolean apply(Game game, Ability source) {
        Permanent permanent = game.getPermanent(source.getSourceId());
        if (permanent == null) {
            return false;
        }

        // only for transformed permanents
        if (!permanent.isTransformed()) {
            return false;
        }

        return TransformAbility.transformPermanent(permanent, game, source);
    }
...

ContinuousEffects.apply()

public synchronized void apply(Game game) {
        removeInactiveEffects(game);
        List<ContinuousEffect> activeLayerEffects = getLayeredEffects(game); // main call

        List<ContinuousEffect> layer = filterLayeredEffects(activeLayerEffects, Layer.CopyEffects_1);
        for (ContinuousEffect effect : layer) {
            Set<Ability> abilities = layeredEffects.getAbility(effect.getId());
            for (Ability ability : abilities) {
                effect.apply(Layer.CopyEffects_1, SubLayer.CopyEffects_1a, ability, game);
            }
        }
        for (ContinuousEffect effect : layer) {
            Set<Ability> abilities = layeredEffects.getAbility(effect.getId());
            for (Ability ability : abilities) {
                effect.apply(Layer.CopyEffects_1, SubLayer.FaceDownEffects_1b, ability, game);
            }
        }
        //Reload layerEffect if copy effects were applied
        if (!layer.isEmpty()) {
            activeLayerEffects = getLayeredEffects(game, "layer_1");
        }
...

When the layer 1 effects are processed, the transform effects are processed at the same time. When the apply method is called, it results in this:

TransformAbility.transformPermanent()

public static boolean transformPermanent(Permanent permanent, Game game, Ability source) {
    
...

    for (Ability ability : sourceCard.getAbilities()) {
        // source == null -- call from init card (e.g. own abilities)
        // source != null -- from apply effect
        permanent.addAbility(ability, source == null ? permanent.getId() : source.getSourceId(), game, true);
    }

...

}

The abilities (and therefore effects) of the second side are added to the game.
When copy effects are processed, these effects from the transformed card are not yet present, and so they are not applied.

Before layer 2 is processed, the layered effects are recalculated and so any effects from transform or copy abilities are correctly applied at higher layers.

Prior to Dinosaur Headdress, there was no transform card that had a copy ability, so this implementation detail did not affect the correct working of cards.

According to the rules for the layer system (613) and for transform (701.28), transform is not a continuous ability, it is merely a different state of a card. The current implementation is a work-around that allows transform to be treated as a kind of copy effect.

There are two ways to address this:

  • Continue with the current implementation of transform, but find a way to apply the effects before copy effects are processed.
  • Re-write transform so that it aligns more closely with the rules. This could be a fairly extensive change.
Copy link

Paleontologist's Pick-Axe // Dinosaur Headdress - (Gatherer) (Scryfall) (EDHREC)

{2}
Artifact — Equipment
Whenever equipped creature attacks, draw a card, then discard a card.
Equip {1}
Craft with one or more creatures {5} ({5}, Exile this artifact, Exile one or more creatures you control and/or creature cards from your graveyard: Return this card transformed under its owner's control. Craft only as a sorcery.)
🔄
Artifact — Equipment
When Dinosaur Headdress enters the battlefield, attach it to target creature you control.
As Dinosaur Headdress becomes attached to a creature, choose an exiled creature card used to craft Dinosaur Headdress.
Equipped creature is a copy of the last chosen card.
Equip {2}

@xenohedron
Copy link
Contributor

I think I am okay with changing TransformAbility to apply on a new Layer.TransformCharacteristics_0 before standard continuous effects.

@theelk801 @JayDi85 thoughts?

@xenohedron xenohedron added bug Bugs and errors refactoring Developers topics about code and programming Developers Discussion Discussion about redesign or changes labels Jan 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs and errors Developers Discussion Discussion about redesign or changes refactoring Developers topics about code and programming
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants