* Fixed Sightless Brawler cannot attack with other creatures attacking (fixes #2133).

This commit is contained in:
LevelX2 2016-08-06 12:30:52 +02:00
parent 14c02bc756
commit 286dc55396
5 changed files with 77 additions and 23 deletions

View file

@ -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);

View file

@ -374,7 +374,7 @@ public class BestowTest extends CardTestPlayerBase {
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);
@ -389,12 +389,12 @@ 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);
@ -414,7 +414,7 @@ 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);
@ -438,7 +438,7 @@ 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);

View file

@ -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;
}
}

View file

@ -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

View file

@ -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) {