diff --git a/Mage.Tests/src/test/java/org/mage/test/combat/AttackBlockRestrictionsTest.java b/Mage.Tests/src/test/java/org/mage/test/combat/AttackBlockRestrictionsTest.java index 607fac9fe61..8aeda607db1 100644 --- a/Mage.Tests/src/test/java/org/mage/test/combat/AttackBlockRestrictionsTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/combat/AttackBlockRestrictionsTest.java @@ -2,6 +2,7 @@ package org.mage.test.combat; import junit.framework.Assert; import mage.Constants; +import mage.counters.CounterType; import mage.game.permanent.Permanent; import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; @@ -203,4 +204,26 @@ public class AttackBlockRestrictionsTest extends CardTestPlayerBase { assertLife(playerA, 17); assertLife(playerB, 20); } + + /** + * Tests Unblockable + */ + @Test + public void testUnblockable() { + addCard(Constants.Zone.BATTLEFIELD, playerB, "Blighted Agent"); + + addCard(Constants.Zone.BATTLEFIELD, playerA, "Blighted Agent"); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Llanowar Elves"); + addCard(Constants.Zone.BATTLEFIELD, playerA, "Birds of Paradise"); + + attack(2, playerB, "Blighted Agent"); + block(2, playerA, "Blighted Agent", "Blighted Agent"); + block(2, playerA, "Llanowar Elves", "Blighted Agent"); + block(2, playerA, "Birds of Paradise", "Blighted Agent"); + + setStopAt(2, Constants.PhaseStep.END_TURN); + execute(); + + assertCounterCount(playerA, CounterType.POISON, 1); + } } diff --git a/Mage/src/mage/abilities/keyword/UnblockableAbility.java b/Mage/src/mage/abilities/keyword/UnblockableAbility.java index 32166087e24..f981a334478 100644 --- a/Mage/src/mage/abilities/keyword/UnblockableAbility.java +++ b/Mage/src/mage/abilities/keyword/UnblockableAbility.java @@ -28,7 +28,6 @@ package mage.abilities.keyword; -import java.io.ObjectStreamException; import mage.Constants.Duration; import mage.abilities.Ability; import mage.abilities.EvasionAbility; @@ -36,64 +35,70 @@ import mage.abilities.effects.RestrictionEffect; import mage.game.Game; import mage.game.permanent.Permanent; +import java.io.ObjectStreamException; + /** - * * @author BetaSteward_at_googlemail.com */ public class UnblockableAbility extends EvasionAbility { - private static final UnblockableAbility fINSTANCE = new UnblockableAbility(); + private static final UnblockableAbility fINSTANCE = new UnblockableAbility(); - private Object readResolve() throws ObjectStreamException { - return fINSTANCE; - } + private Object readResolve() throws ObjectStreamException { + return fINSTANCE; + } - public static UnblockableAbility getInstance() { - return fINSTANCE; - } + public static UnblockableAbility getInstance() { + return fINSTANCE; + } - private UnblockableAbility() { - this.addEffect(new UnblockableEffect()); - } + private UnblockableAbility() { + this.addEffect(new UnblockableEffect()); + } - @Override - public String getRule() { - return "Unblockable"; - } + @Override + public String getRule() { + return "Unblockable"; + } - @Override - public UnblockableAbility copy() { - return fINSTANCE; - } + @Override + public UnblockableAbility copy() { + return fINSTANCE; + } } class UnblockableEffect extends RestrictionEffect { - public UnblockableEffect() { - super(Duration.WhileOnBattlefield); - } + public UnblockableEffect() { + super(Duration.EndOfGame); + } - public UnblockableEffect(final UnblockableEffect effect) { - super(effect); - } + public UnblockableEffect(final UnblockableEffect effect) { + super(effect); + } - @Override - public boolean applies(Permanent permanent, Ability source, Game game) { - if (permanent.getId().equals(source.getSourceId())) { - return true; - } - return false; - } + @Override + public void newId() { + // do nothing + } - @Override - public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) { - return false; - } + @Override + public boolean applies(Permanent permanent, Ability source, Game game) { + if (permanent.getAbilities().containsKey(UnblockableAbility.getInstance().getId())) { + return true; + } + return false; + } - @Override - public UnblockableEffect copy() { - return new UnblockableEffect(this); - } + @Override + public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) { + return false; + } + + @Override + public UnblockableEffect copy() { + return new UnblockableEffect(this); + } } \ No newline at end of file