* Fixed that not all Equip abilities were correctly identified for abilities that changed Equip timig (e.g. Leonin Shikari - fixes #6907).

This commit is contained in:
LevelX2 2020-07-29 16:16:47 +02:00
parent ffa837ae95
commit 7cfe39ae21
9 changed files with 87 additions and 51 deletions

View file

@ -11,7 +11,6 @@ import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.common.continuous.BoostEquippedEffect;
import mage.abilities.keyword.EquipAbility;
import mage.abilities.keyword.EquipFilterAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
@ -19,6 +18,7 @@ import mage.filter.StaticFilters;
import mage.filter.common.FilterControlledCreaturePermanent;
import java.util.UUID;
import mage.target.common.TargetControlledCreaturePermanent;
/**
* @author Rystan
@ -43,7 +43,7 @@ public final class BlackbladeReforged extends CardImpl {
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(count, count)));
// Equip legendary creature (3)
this.addAbility(new EquipFilterAbility(filter, new GenericManaCost(3)));
this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(3), new TargetControlledCreaturePermanent(filter)));
// Equip {7}
this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(7)));

View file

@ -31,6 +31,8 @@ public final class GolemSkinGauntlets extends CardImpl {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{1}");
this.subtype.add(SubType.EQUIPMENT);
// Equipped creature gets +1/+0 for each Equipment attached to it.
// Equip 2 (2: Attach to target creature you control. Equip only as a sorcery. This card enters the battlefield unattached and stays on the battlefield if the creature leaves.)
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(new GolemSkinGauntletsAttachedCount(), StaticValue.get(0), Duration.WhileOnBattlefield)));
this.addAbility(new EquipAbility(Outcome.BoostCreature, new GenericManaCost(2)));
}

View file

@ -4,7 +4,6 @@ import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.common.continuous.BoostEquippedEffect;
import mage.abilities.keyword.EquipAbility;
import mage.abilities.keyword.EquipFilterAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
@ -13,6 +12,7 @@ import mage.constants.SubType;
import mage.filter.common.FilterControlledCreaturePermanent;
import java.util.UUID;
import mage.target.common.TargetControlledCreaturePermanent;
/**
* @author TheElk801
@ -31,7 +31,7 @@ public final class SteelclawLance extends CardImpl {
this.addAbility(new SimpleStaticAbility(new BoostEquippedEffect(2, 2)));
// Equip Knight {1}
this.addAbility(new EquipFilterAbility(filter, new GenericManaCost(1)));
this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(1), new TargetControlledCreaturePermanent(filter)));
// Equip {3}
this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(3)));

View file

@ -8,7 +8,6 @@ import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
import mage.abilities.keyword.EquipFilterAbility;
import mage.abilities.keyword.MenaceAbility;
import mage.abilities.keyword.VigilanceAbility;
import mage.cards.CardImpl;
@ -23,6 +22,9 @@ import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.permanent.EquippedPredicate;
import java.util.UUID;
import mage.abilities.keyword.EquipAbility;
import mage.constants.Outcome;
import mage.target.common.TargetControlledCreaturePermanent;
/**
* @author TheElk801
@ -64,7 +66,8 @@ public final class SyrGwynHeroOfAshvale extends CardImpl {
// Equipment you control have equip Knight {0}.
this.addAbility(new SimpleStaticAbility(new GainAbilityControlledEffect(
new EquipFilterAbility(filter3, new GenericManaCost(0)), Duration.WhileOnBattlefield, filter2
new EquipAbility(Outcome.AddAbility, new GenericManaCost(0), new TargetControlledCreaturePermanent(filter3)),
Duration.WhileOnBattlefield, filter2
)));
}

View file

@ -19,6 +19,9 @@ public class GolemSkinGauntletsTest extends CardTestPlayerBase {
@Test
public void testBoostOnEquip() {
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 6);
// Equipped creature doesn't untap during its controller's untap step.
// Equipped creature has "{T}: This creature deals 2 damage to any target."
// Equip {4)
addCard(Zone.BATTLEFIELD, playerA, "Heavy Arbalest");
addCard(Zone.BATTLEFIELD, playerA, "Golem-Skin Gauntlets");
addCard(Zone.BATTLEFIELD, playerA, "Elite Vanguard");

View file

@ -0,0 +1,62 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.mage.test.cards.single.eld;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author LevelX2
*/
public class SyrGwynHeroOfAshvaleTest extends CardTestPlayerBase {
@Test
public void equipKnightTest() {
// Equipped creature gets +2/+2 and has trample and lifelink.
addCard(Zone.BATTLEFIELD, playerA, "Behemoth Sledge"); // Artifact - Equipment {1}{G}{W}
// Vigilance, menace
// Whenever an equipped creature you control attacks, you draw a card and you lose 1 life.
// Equipment you control have equip Knight {0}.
addCard(Zone.BATTLEFIELD, playerA, "Syr Gwyn, Hero of Ashvale"); // Legendary Creature {3}{R}{W}{B} 5/5 Human Knight
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Equip Knight", "Syr Gwyn, Hero of Ashvale");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertPowerToughness(playerA, "Syr Gwyn, Hero of Ashvale", 7, 7);
}
@Test
public void equipKnightTestInstantSpeed() {
// Equipped creature gets +2/+2 and has trample and lifelink.
addCard(Zone.BATTLEFIELD, playerA, "Behemoth Sledge"); // Artifact - Equipment {1}{G}{W}
// You may activate equip abilities any time you could cast an instant.
addCard(Zone.BATTLEFIELD, playerA, "Leonin Shikari", 2); // Creature 2/2
// Vigilance, menace
// Whenever an equipped creature you control attacks, you draw a card and you lose 1 life.
// Equipment you control have equip Knight {0}.
addCard(Zone.BATTLEFIELD, playerA, "Syr Gwyn, Hero of Ashvale"); // Legendary Creature {3}{R}{W}{B} 5/5 Human Knight
activateAbility(1, PhaseStep.DECLARE_ATTACKERS, playerA, "Equip Knight", "Syr Gwyn, Hero of Ashvale");
setStopAt(1, PhaseStep.END_COMBAT);
execute();
assertPowerToughness(playerA, "Syr Gwyn, Hero of Ashvale", 7, 7);
}
}

View file

@ -19,7 +19,7 @@ import mage.game.Game;
*/
public class ActivateAbilitiesAnyTimeYouCouldCastInstantEffect extends AsThoughEffectImpl {
private Class activatedAbility;
private final Class activatedAbility;
public ActivateAbilitiesAnyTimeYouCouldCastInstantEffect(Class activatedAbility, String activatedAbilityName) {
super(AsThoughEffectType.ACTIVATE_AS_INSTANT, Duration.EndOfGame, Outcome.Benefit);
@ -45,7 +45,7 @@ public class ActivateAbilitiesAnyTimeYouCouldCastInstantEffect extends AsThoughE
@Override
public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game, UUID playerId) {
return affectedAbility.isControlledBy(source.getControllerId())
&& activatedAbility.isInstance(affectedAbility);
&& activatedAbility.isAssignableFrom(affectedAbility.getClass());
}
@Override

View file

@ -40,7 +40,13 @@ public class EquipAbility extends ActivatedAbilityImpl {
@Override
public String getRule() {
return "Equip " + costs.getText() + manaCosts.getText() + " <i>(" + manaCosts.getText() + ": Attach to target creature you control. Equip only as a sorcery.)</i>";
String targetText = getTargets().get(0) != null ? getTargets().get(0).getFilter().getMessage() : "creature";
return "Equip "
+ (targetText.equals("creature you control") ? "" : targetText + " ")
+ costs.getText()
+ manaCosts.getText()
+ " <i>(" + manaCosts.getText() + ": Attach to target " + targetText + " you control. Equip only as a sorcery. This card enters the battlefield unattached and stays on the battlefield if the creature leaves.)</i>";
}
}

View file

@ -1,40 +0,0 @@
package mage.abilities.keyword;
import mage.abilities.ActivatedAbilityImpl;
import mage.abilities.costs.Cost;
import mage.abilities.effects.common.AttachEffect;
import mage.constants.Outcome;
import mage.constants.TimingRule;
import mage.constants.Zone;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.target.common.TargetControlledCreaturePermanent;
/**
* @author TheElk801
*/
public class EquipFilterAbility extends ActivatedAbilityImpl {
private final FilterControlledCreaturePermanent filter;
public EquipFilterAbility(FilterControlledCreaturePermanent filter, Cost cost) {
super(Zone.BATTLEFIELD, new AttachEffect(Outcome.AddAbility, "Equip"), cost);
this.addTarget(new TargetControlledCreaturePermanent(filter));
this.filter = filter;
this.timing = TimingRule.SORCERY;
}
private EquipFilterAbility(final EquipFilterAbility ability) {
super(ability);
this.filter = ability.filter;
}
@Override
public EquipFilterAbility copy() {
return new EquipFilterAbility(this);
}
@Override
public String getRule() {
return "Equip " + filter.getMessage() + costs.getText() + manaCosts.getText();
}
}