* 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.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);

View file

@ -389,7 +389,7 @@ 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");

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
*/
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

View file

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