diff --git a/Mage.Sets/src/mage/sets/journeyintonyx/SightlessBrawler.java b/Mage.Sets/src/mage/sets/journeyintonyx/SightlessBrawler.java index f75112f483..e5487ea40a 100644 --- a/Mage.Sets/src/mage/sets/journeyintonyx/SightlessBrawler.java +++ b/Mage.Sets/src/mage/sets/journeyintonyx/SightlessBrawler.java @@ -32,11 +32,12 @@ import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.Effect; -import mage.abilities.effects.common.combat.CanAttackOnlyAloneEffect; +import mage.abilities.effects.common.combat.CantAttackAloneAttachedEffect; import mage.abilities.effects.common.continuous.BoostEnchantedEffect; import mage.abilities.keyword.BestowAbility; import mage.abilities.keyword.CantAttackAloneAbility; import mage.cards.CardImpl; +import mage.constants.AttachmentType; import mage.constants.CardType; import mage.constants.Duration; import mage.constants.Rarity; @@ -65,7 +66,7 @@ public class SightlessBrawler extends CardImpl { Effect effect = new BoostEnchantedEffect(3, 2, Duration.WhileOnBattlefield); effect.setText("Enchanted creature gets +3/+2"); Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, effect); - effect = new CanAttackOnlyAloneEffect(); + effect = new CantAttackAloneAttachedEffect(AttachmentType.AURA); effect.setText("and can't attack alone"); ability.addEffect(effect); this.addAbility(ability); diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/BestowTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/BestowTest.java index 3674f10ff2..7d0cc9d104 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/BestowTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/BestowTest.java @@ -362,7 +362,7 @@ public class BestowTest extends CardTestPlayerBase { Assert.assertEquals("Nighthowler has to be a creature", true, nighthowler.getCardType().contains(CardType.CREATURE)); } - + @Test public void testSightlessBrawlerCantAttackAloneEnforced() { addCard(Zone.BATTLEFIELD, playerA, "Plains", 5); @@ -373,14 +373,14 @@ public class BestowTest extends CardTestPlayerBase { // Enchanted creature gets +3/+2 and can't attack alone. addCard(Zone.BATTLEFIELD, playerA, "Sightless Brawler"); - attack(1, playerA, "Sightless Brawler"); - setStopAt(1,PhaseStep.END_COMBAT); + attack(1, playerA, "Sightless Brawler"); + setStopAt(1, PhaseStep.END_COMBAT); execute(); - + assertLife(playerB, 20); assertTapped("Sightless Brawler", false); } - + @Test public void testSightlessBrawlerAttacksWithOthers() { addCard(Zone.BATTLEFIELD, playerA, "Plains", 5); @@ -389,18 +389,18 @@ public class BestowTest extends CardTestPlayerBase { // Bestow 4W (If you cast this card for its bestow cost, it's an Aura spell with enchant creature. It becomes a creature again if it's not attached to a creature.) // Sightless Brawler can't attack alone. // Enchanted creature gets +3/+2 and can't attack alone. - addCard(Zone.BATTLEFIELD, playerA, "Sightless Brawler"); + addCard(Zone.BATTLEFIELD, playerA, "Sightless Brawler"); // 3/2 addCard(Zone.BATTLEFIELD, playerA, "Elite Vanguard"); // {W} 2/1 creature attack(1, playerA, "Sightless Brawler"); attack(1, playerA, "Elite Vanguard"); - setStopAt(1,PhaseStep.END_COMBAT); + setStopAt(1, PhaseStep.END_COMBAT); execute(); - + assertLife(playerB, 15); assertTapped("Sightless Brawler", true); } - + @Test public void testSightlessBrawlerBestowedCantAttackAloneEnforced() { addCard(Zone.BATTLEFIELD, playerA, "Plains", 5); @@ -414,15 +414,15 @@ public class BestowTest extends CardTestPlayerBase { castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Sightless Brawler using bestow", "Elite Vanguard"); attack(1, playerA, "Elite Vanguard"); - setStopAt(1,PhaseStep.END_COMBAT); + setStopAt(1, PhaseStep.END_COMBAT); execute(); - + assertHandCount(playerA, "Sightless Brawler", 0); assertLife(playerB, 20); assertTapped("Elite Vanguard", false); assertPowerToughness(playerA, "Elite Vanguard", 5, 3); // 2/1 + 3/2 = 5/3 } - + @Test public void testSightlessBrawlerBestowedAttacksWithOthers() { addCard(Zone.BATTLEFIELD, playerA, "Plains", 5); @@ -438,9 +438,9 @@ public class BestowTest extends CardTestPlayerBase { castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Sightless Brawler using bestow", "Elite Vanguard"); attack(1, playerA, "Elite Vanguard"); attack(1, playerA, "Memnite"); - setStopAt(1,PhaseStep.END_COMBAT); + setStopAt(1, PhaseStep.END_COMBAT); execute(); - + assertHandCount(playerA, "Sightless Brawler", 0); assertLife(playerB, 14); assertTapped("Elite Vanguard", true); diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackAloneAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackAloneAttachedEffect.java new file mode 100644 index 0000000000..79a28e2703 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackAloneAttachedEffect.java @@ -0,0 +1,53 @@ +/* + * 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 mage.abilities.effects.common.combat; + +import mage.abilities.Ability; +import mage.abilities.effects.RestrictionEffect; +import mage.constants.AttachmentType; +import mage.constants.Duration; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * + * @author LevelX2 + */ +public class CantAttackAloneAttachedEffect extends RestrictionEffect { + + public CantAttackAloneAttachedEffect(AttachmentType attachmentType) { + super(Duration.WhileOnBattlefield); + if (attachmentType.equals(AttachmentType.AURA)) { + this.staticText = "Enchanted creature can't attack alone"; + } else { + this.staticText = "Equipped creature can't attack alone"; + } + } + + public CantAttackAloneAttachedEffect(final CantAttackAloneAttachedEffect effect) { + super(effect); + } + + @Override + public CantAttackAloneAttachedEffect copy() { + return new CantAttackAloneAttachedEffect(this); + } + + @Override + public boolean canAttackCheckAfter(int numberOfAttackers, Ability source, Game game) { + return numberOfAttackers > 1; + } + + @Override + public boolean applies(Permanent permanent, Ability source, Game game) { + Permanent attachment = game.getPermanent(source.getSourceId()); + if (attachment != null && attachment.getAttachedTo() != null + && permanent.getId().equals(attachment.getAttachedTo())) { + return true; + } + return false; + } +} diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackAloneEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackAloneSourceEffect.java similarity index 75% rename from Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackAloneEffect.java rename to Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackAloneSourceEffect.java index 4c306d5fbc..5aa33b59e3 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackAloneEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackAloneSourceEffect.java @@ -15,20 +15,20 @@ import mage.game.permanent.Permanent; * * @author LevelX2 */ -public class CantAttackAloneEffect extends RestrictionEffect { +public class CantAttackAloneSourceEffect extends RestrictionEffect { - public CantAttackAloneEffect() { + public CantAttackAloneSourceEffect() { super(Duration.WhileOnBattlefield); staticText = "{this} can't attack alone"; } - public CantAttackAloneEffect(final CantAttackAloneEffect effect) { + public CantAttackAloneSourceEffect(final CantAttackAloneSourceEffect effect) { super(effect); } @Override - public CantAttackAloneEffect copy() { - return new CantAttackAloneEffect(this); + public CantAttackAloneSourceEffect copy() { + return new CantAttackAloneSourceEffect(this); } @Override diff --git a/Mage/src/main/java/mage/abilities/keyword/CantAttackAloneAbility.java b/Mage/src/main/java/mage/abilities/keyword/CantAttackAloneAbility.java index fecbd9dcdd..7ce38ab2a4 100644 --- a/Mage/src/main/java/mage/abilities/keyword/CantAttackAloneAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/CantAttackAloneAbility.java @@ -28,7 +28,7 @@ package mage.abilities.keyword; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.common.combat.CantAttackAloneEffect; +import mage.abilities.effects.common.combat.CantAttackAloneSourceEffect; import mage.constants.Zone; /** @@ -37,7 +37,7 @@ import mage.constants.Zone; public class CantAttackAloneAbility extends SimpleStaticAbility { public CantAttackAloneAbility() { - super(Zone.BATTLEFIELD, new CantAttackAloneEffect()); + super(Zone.BATTLEFIELD, new CantAttackAloneSourceEffect()); } private CantAttackAloneAbility(CantAttackAloneAbility ability) {