mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
Fix issues with Clone and Metallic Mimic (#5160)
Fix bugs with Metallic Mimic and Adaptive Automaton and clone effects. Metallic Mimic and Adaptive Automaton were both using the technically correct EnterEventType specifier for their as enters the battlefield abilities. Despite it being technically correct this meant that their ability didn't trigger if they were cloned. Additionally EnterAttributeAddChosenSubtypeEffect changed the subtype of the base object which meant that clones entered in with the chosen subtype of the original.
This commit is contained in:
parent
3875f42bac
commit
a164dad83f
5 changed files with 75 additions and 40 deletions
|
|
@ -0,0 +1,37 @@
|
|||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.common.ChooseCreatureTypeEffect;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
public class AddChosenSubtypeEffect extends ContinuousEffectImpl {
|
||||
|
||||
public AddChosenSubtypeEffect() {
|
||||
super(Duration.WhileOnBattlefield, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Benefit);
|
||||
staticText = "{this} is the chosen type in addition to its other types";
|
||||
}
|
||||
|
||||
public AddChosenSubtypeEffect(final AddChosenSubtypeEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(permanent.getId(), game);
|
||||
if (subType != null && !permanent.hasSubtype(subType, game)) {
|
||||
permanent.getSubtype(game).add(subType);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddChosenSubtypeEffect copy() {
|
||||
return new AddChosenSubtypeEffect(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -11,6 +11,8 @@ import mage.game.permanent.Permanent;
|
|||
|
||||
/**
|
||||
*
|
||||
* IMPORTANT: This only adds the chosen subtype while the source permanent is entering the battlefield.
|
||||
* You should also use @link{mage.abilities.effects.common.continuous.AddChosenSubtypeEffect} to make the subtype persist.
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class EnterAttributeAddChosenSubtypeEffect extends OneShotEffect {
|
||||
|
|
@ -34,12 +36,8 @@ public class EnterAttributeAddChosenSubtypeEffect extends OneShotEffect {
|
|||
Permanent permanent = game.getPermanentEntering(source.getSourceId());
|
||||
SubType subtype = (SubType) game.getState().getValue(source.getSourceId() + "_type");
|
||||
if (permanent != null && subtype != null) {
|
||||
MageObject mageObject = permanent.getBasicMageObject(game);
|
||||
if (!mageObject.getSubtype(null).contains(subtype)) {
|
||||
mageObject.getSubtype(null).add(subtype);
|
||||
}
|
||||
if (!permanent.getSubtype(null).contains(subtype)) {
|
||||
permanent.getSubtype(null).add(subtype);
|
||||
if (!permanent.getSubtype(game).contains(subtype)) {
|
||||
permanent.getSubtype(game).add(subtype);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue