Friday, September 25, 2020

XMage, Adding MutateAbility (1)

 Got gp66 forked repo to work on. Trying to test Gemrazer to implement

1. target controlled permanent non-human

@@ -2,36 +2,48 @@ package;
 import mage.MageInt;
 import mage.abilities.Ability;
 import mage.abilities.common.MutatesSourceTriggeredAbility;
 import mage.abilities.effects.common.DestroyTargetEffect;
+import mage.abilities.effects.common.AttachEffect;
 import mage.constants.CardType;
+import mage.constants.Outcome;
 import mage.constants.SubType;
 import mage.constants.TargetController;
 import mage.filter.FilterPermanent;
 import mage.filter.common.FilterArtifactOrEnchantmentPermanent;
+import mage.filter.common.FilterControlledCreaturePermanent;
+import mage.constants.SubType;
+import mage.filter.predicate.Predicates;

public final class Gemrazer extends CardImpl {
-    private static final FilterPermanent filter
+	private static final FilterPermanent filter
             = new FilterArtifactOrEnchantmentPermanent("artifact or enchantment an opponent controls");
     static {
+    private static final FilterPermanent filterCreatureNonHuman
+            = new FilterControlledCreaturePermanent("non-human creature you control");
+    static {
+    	filterCreatureNonHuman.add(Predicates.not(SubType.HUMAN.getPredicate()));
+    }

@@ -43,10 +55,15 @@ public final class Gemrazer extends CardImpl {
         // Reach
         // Trample
+        // Whenever this creature mutates, attach to a controlled non-human creature
+        Ability abilityAttach = new MutatesSourceTriggeredAbility(new AttachEffect(Outcome.Mutate));
+        abilityAttach.addTarget(new TargetPermanent(filterCreatureNonHuman));
+        this.addAbility(abilityAttach);
         // Whenever this creature mutates, destroy target artifact or enchantment an opponent controls.
         Ability ability = new MutatesSourceTriggeredAbility(new DestroyTargetEffect());
         ability.addTarget(new TargetPermanent(filter));

2. Test the ability of mutated creature

    public void testCastMutate() {
        addCard(Zone.BATTLEFIELD, playerA, "Forest", 2);
        addCard(Zone.BATTLEFIELD, playerA, "Plains", 1);
        addCard(Zone.BATTLEFIELD, playerA, "Flourishing Fox",1);
        addCard(Zone.HAND, playerA, "Gemrazer",1);

        castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Gemrazer using mutate");
        // But why no addTarget to flourishing fox ??
        setStopAt(1, PhaseStep.BEGIN_COMBAT);

        assertAbility(playerA, "Gemrazer", new CyclingAbility(new ManaCostsImpl("{1}")), true);
        assertHandCount(playerA, 0);

The test result so far so good


Ask for the mutation on top or bottom of the targeted non-human creature.

No comments: