Fixed activated ability
package mage.cards.w;
import mage.MageInt;
+import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
-import mage.abilities.effects.common.continuous.BecomesCreatureSourceEffect;
+import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.keyword.DefenderAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
-import mage.game.permanent.token.TokenImpl;
+import mage.game.Game;
+import mage.game.permanent.Permanent;
import java.util.UUID;
@@ -30,8 +32,7 @@ public final class WishfulMerfolk extends CardImpl {
this.addAbility(DefenderAbility.getInstance());
// {1}{U}: Wishful Merfolk loses defender and becomes a Human until end of turn.
- //this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new WishfulMerfolkEffect(), new ManaCostsImpl("{1}{U}")));
- this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesCreatureSourceEffect(new WishfulMerfolkToken(), "", Duration.EndOfTurn), new ManaCostsImpl("{1}{U}")));
+ this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new WishfulMerfolkEffect(), new ManaCostsImpl("{1}{U}")));
}
public WishfulMerfolk(final WishfulMerfolk card) {
@@ -44,22 +45,52 @@ public final class WishfulMerfolk extends CardImpl {
}
}
-class WishfulMerfolkToken extends TokenImpl {
+class WishfulMerfolkEffect extends ContinuousEffectImpl {
- public WishfulMerfolkToken() {
- super("Wishful Merfolk", "");
- this.cardType.add(CardType.CREATURE);
- this.subtype.add(SubType.HUMAN);
- this.color.setBlue(true);
- this.power = new MageInt(3);
- this.toughness = new MageInt(2);
+ public WishfulMerfolkEffect() {
+ super(Duration.EndOfTurn, Outcome.AddAbility);
+ staticText = "{this} loses defender and becomes a Human until end of turn";
+ }
+
+ public WishfulMerfolkEffect(final WishfulMerfolkEffect effect) {
+ super(effect);
+ }
+
+ @Override
+ public WishfulMerfolkEffect copy() {
+ return new WishfulMerfolkEffect(this);
+ }
+
+ @Override
+ public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
+ Permanent permanent = game.getPermanent(source.getSourceId());
+ if (permanent != null) {
+ switch (layer) {
+ case AbilityAddingRemovingEffects_6:
+ if (sublayer == SubLayer.NA) {
+ permanent.getAbilities().removeIf(entry -> entry.getId().equals(DefenderAbility.getInstance().getId()));
+ }
+ break;
+ case TypeChangingEffects_4:
+ if (permanent.getSubtype(game).contains(SubType.MERFOLK)) {
+ permanent.getSubtype(game).clear();
+ permanent.getSubtype(game).add(SubType.HUMAN);
+ }
+ break;
+ }
+ return true;
+ }
+ return false;
}
- public WishfulMerfolkToken(final WishfulMerfolkToken token) {
- super(token);
+ @Override
+ public boolean apply(Game game, Ability source) {
+ return false;
}
- public WishfulMerfolkToken copy() {
- return new WishfulMerfolkToken(this);
+ @Override
+ public boolean hasLayer(Layer layer) {
+ return layer == Layer.AbilityAddingRemovingEffects_6
+ || layer == Layer.TypeChangingEffects_4;
}
}
