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.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);
|
||||
|
|
|
@ -374,7 +374,7 @@ public class BestowTest extends CardTestPlayerBase {
|
|||
addCard(Zone.BATTLEFIELD, playerA, "Sightless Brawler");
|
||||
|
||||
attack(1, playerA, "Sightless Brawler");
|
||||
setStopAt(1,PhaseStep.END_COMBAT);
|
||||
setStopAt(1, PhaseStep.END_COMBAT);
|
||||
execute();
|
||||
|
||||
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.)
|
||||
// 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);
|
||||
|
@ -414,7 +414,7 @@ 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);
|
||||
|
@ -438,7 +438,7 @@ 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);
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
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
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue