mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
* Fixed Sightless Brawler cannot attack with other creatures attacking (fixes #2133).
This commit is contained in:
parent
14c02bc756
commit
286dc55396
5 changed files with 77 additions and 23 deletions
|
@ -32,11 +32,12 @@ import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.Effect;
|
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.effects.common.continuous.BoostEnchantedEffect;
|
||||||
import mage.abilities.keyword.BestowAbility;
|
import mage.abilities.keyword.BestowAbility;
|
||||||
import mage.abilities.keyword.CantAttackAloneAbility;
|
import mage.abilities.keyword.CantAttackAloneAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
import mage.constants.AttachmentType;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
|
@ -65,7 +66,7 @@ public class SightlessBrawler extends CardImpl {
|
||||||
Effect effect = new BoostEnchantedEffect(3, 2, Duration.WhileOnBattlefield);
|
Effect effect = new BoostEnchantedEffect(3, 2, Duration.WhileOnBattlefield);
|
||||||
effect.setText("Enchanted creature gets +3/+2");
|
effect.setText("Enchanted creature gets +3/+2");
|
||||||
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, effect);
|
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, effect);
|
||||||
effect = new CanAttackOnlyAloneEffect();
|
effect = new CantAttackAloneAttachedEffect(AttachmentType.AURA);
|
||||||
effect.setText("and can't attack alone");
|
effect.setText("and can't attack alone");
|
||||||
ability.addEffect(effect);
|
ability.addEffect(effect);
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
|
|
|
@ -362,7 +362,7 @@ public class BestowTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
Assert.assertEquals("Nighthowler has to be a creature", true, nighthowler.getCardType().contains(CardType.CREATURE));
|
Assert.assertEquals("Nighthowler has to be a creature", true, nighthowler.getCardType().contains(CardType.CREATURE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSightlessBrawlerCantAttackAloneEnforced() {
|
public void testSightlessBrawlerCantAttackAloneEnforced() {
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 5);
|
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.
|
// Enchanted creature gets +3/+2 and can't attack alone.
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Sightless Brawler");
|
addCard(Zone.BATTLEFIELD, playerA, "Sightless Brawler");
|
||||||
|
|
||||||
attack(1, playerA, "Sightless Brawler");
|
attack(1, playerA, "Sightless Brawler");
|
||||||
setStopAt(1,PhaseStep.END_COMBAT);
|
setStopAt(1, PhaseStep.END_COMBAT);
|
||||||
execute();
|
execute();
|
||||||
|
|
||||||
assertLife(playerB, 20);
|
assertLife(playerB, 20);
|
||||||
assertTapped("Sightless Brawler", false);
|
assertTapped("Sightless Brawler", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSightlessBrawlerAttacksWithOthers() {
|
public void testSightlessBrawlerAttacksWithOthers() {
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 5);
|
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.)
|
// 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.
|
// Sightless Brawler can't attack alone.
|
||||||
// Enchanted creature gets +3/+2 and 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
|
addCard(Zone.BATTLEFIELD, playerA, "Elite Vanguard"); // {W} 2/1 creature
|
||||||
|
|
||||||
attack(1, playerA, "Sightless Brawler");
|
attack(1, playerA, "Sightless Brawler");
|
||||||
attack(1, playerA, "Elite Vanguard");
|
attack(1, playerA, "Elite Vanguard");
|
||||||
setStopAt(1,PhaseStep.END_COMBAT);
|
setStopAt(1, PhaseStep.END_COMBAT);
|
||||||
execute();
|
execute();
|
||||||
|
|
||||||
assertLife(playerB, 15);
|
assertLife(playerB, 15);
|
||||||
assertTapped("Sightless Brawler", true);
|
assertTapped("Sightless Brawler", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSightlessBrawlerBestowedCantAttackAloneEnforced() {
|
public void testSightlessBrawlerBestowedCantAttackAloneEnforced() {
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 5);
|
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");
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Sightless Brawler using bestow", "Elite Vanguard");
|
||||||
attack(1, playerA, "Elite Vanguard");
|
attack(1, playerA, "Elite Vanguard");
|
||||||
setStopAt(1,PhaseStep.END_COMBAT);
|
setStopAt(1, PhaseStep.END_COMBAT);
|
||||||
execute();
|
execute();
|
||||||
|
|
||||||
assertHandCount(playerA, "Sightless Brawler", 0);
|
assertHandCount(playerA, "Sightless Brawler", 0);
|
||||||
assertLife(playerB, 20);
|
assertLife(playerB, 20);
|
||||||
assertTapped("Elite Vanguard", false);
|
assertTapped("Elite Vanguard", false);
|
||||||
assertPowerToughness(playerA, "Elite Vanguard", 5, 3); // 2/1 + 3/2 = 5/3
|
assertPowerToughness(playerA, "Elite Vanguard", 5, 3); // 2/1 + 3/2 = 5/3
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSightlessBrawlerBestowedAttacksWithOthers() {
|
public void testSightlessBrawlerBestowedAttacksWithOthers() {
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 5);
|
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");
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Sightless Brawler using bestow", "Elite Vanguard");
|
||||||
attack(1, playerA, "Elite Vanguard");
|
attack(1, playerA, "Elite Vanguard");
|
||||||
attack(1, playerA, "Memnite");
|
attack(1, playerA, "Memnite");
|
||||||
setStopAt(1,PhaseStep.END_COMBAT);
|
setStopAt(1, PhaseStep.END_COMBAT);
|
||||||
execute();
|
execute();
|
||||||
|
|
||||||
assertHandCount(playerA, "Sightless Brawler", 0);
|
assertHandCount(playerA, "Sightless Brawler", 0);
|
||||||
assertLife(playerB, 14);
|
assertLife(playerB, 14);
|
||||||
assertTapped("Elite Vanguard", true);
|
assertTapped("Elite Vanguard", true);
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,20 +15,20 @@ import mage.game.permanent.Permanent;
|
||||||
*
|
*
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public class CantAttackAloneEffect extends RestrictionEffect {
|
public class CantAttackAloneSourceEffect extends RestrictionEffect {
|
||||||
|
|
||||||
public CantAttackAloneEffect() {
|
public CantAttackAloneSourceEffect() {
|
||||||
super(Duration.WhileOnBattlefield);
|
super(Duration.WhileOnBattlefield);
|
||||||
staticText = "{this} can't attack alone";
|
staticText = "{this} can't attack alone";
|
||||||
}
|
}
|
||||||
|
|
||||||
public CantAttackAloneEffect(final CantAttackAloneEffect effect) {
|
public CantAttackAloneSourceEffect(final CantAttackAloneSourceEffect effect) {
|
||||||
super(effect);
|
super(effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CantAttackAloneEffect copy() {
|
public CantAttackAloneSourceEffect copy() {
|
||||||
return new CantAttackAloneEffect(this);
|
return new CantAttackAloneSourceEffect(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
|
@ -28,7 +28,7 @@
|
||||||
package mage.abilities.keyword;
|
package mage.abilities.keyword;
|
||||||
|
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.common.combat.CantAttackAloneEffect;
|
import mage.abilities.effects.common.combat.CantAttackAloneSourceEffect;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,7 +37,7 @@ import mage.constants.Zone;
|
||||||
public class CantAttackAloneAbility extends SimpleStaticAbility {
|
public class CantAttackAloneAbility extends SimpleStaticAbility {
|
||||||
|
|
||||||
public CantAttackAloneAbility() {
|
public CantAttackAloneAbility() {
|
||||||
super(Zone.BATTLEFIELD, new CantAttackAloneEffect());
|
super(Zone.BATTLEFIELD, new CantAttackAloneSourceEffect());
|
||||||
}
|
}
|
||||||
|
|
||||||
private CantAttackAloneAbility(CantAttackAloneAbility ability) {
|
private CantAttackAloneAbility(CantAttackAloneAbility ability) {
|
||||||
|
|
Loading…
Reference in a new issue