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.
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:
The "chosen card" is a reference to the previous ability:
Transform effects are currently implemented in the continuous layered effects logic.
TransformEffect
ContinuousEffects.apply()
When the layer 1 effects are processed, the transform effects are processed at the same time. When the
applymethod is called, it results in this:TransformAbility.transformPermanent()
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: