mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 19:11:59 -08:00
Test and fix for UnblockableAbility not working
This commit is contained in:
parent
be06cb7790
commit
d6f1e8be48
2 changed files with 69 additions and 41 deletions
|
|
@ -2,6 +2,7 @@ package org.mage.test.combat;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
import mage.Constants;
|
import mage.Constants;
|
||||||
|
import mage.counters.CounterType;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
|
@ -203,4 +204,26 @@ public class AttackBlockRestrictionsTest extends CardTestPlayerBase {
|
||||||
assertLife(playerA, 17);
|
assertLife(playerA, 17);
|
||||||
assertLife(playerB, 20);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@
|
||||||
|
|
||||||
package mage.abilities.keyword;
|
package mage.abilities.keyword;
|
||||||
|
|
||||||
import java.io.ObjectStreamException;
|
|
||||||
import mage.Constants.Duration;
|
import mage.Constants.Duration;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.EvasionAbility;
|
import mage.abilities.EvasionAbility;
|
||||||
|
|
@ -36,64 +35,70 @@ import mage.abilities.effects.RestrictionEffect;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
|
import java.io.ObjectStreamException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class UnblockableAbility extends EvasionAbility<UnblockableAbility> {
|
public class UnblockableAbility extends EvasionAbility<UnblockableAbility> {
|
||||||
|
|
||||||
private static final UnblockableAbility fINSTANCE = new UnblockableAbility();
|
private static final UnblockableAbility fINSTANCE = new UnblockableAbility();
|
||||||
|
|
||||||
private Object readResolve() throws ObjectStreamException {
|
private Object readResolve() throws ObjectStreamException {
|
||||||
return fINSTANCE;
|
return fINSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UnblockableAbility getInstance() {
|
public static UnblockableAbility getInstance() {
|
||||||
return fINSTANCE;
|
return fINSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private UnblockableAbility() {
|
private UnblockableAbility() {
|
||||||
this.addEffect(new UnblockableEffect());
|
this.addEffect(new UnblockableEffect());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRule() {
|
public String getRule() {
|
||||||
return "Unblockable";
|
return "Unblockable";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UnblockableAbility copy() {
|
public UnblockableAbility copy() {
|
||||||
return fINSTANCE;
|
return fINSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class UnblockableEffect extends RestrictionEffect<UnblockableEffect> {
|
class UnblockableEffect extends RestrictionEffect<UnblockableEffect> {
|
||||||
|
|
||||||
public UnblockableEffect() {
|
public UnblockableEffect() {
|
||||||
super(Duration.WhileOnBattlefield);
|
super(Duration.EndOfGame);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UnblockableEffect(final UnblockableEffect effect) {
|
public UnblockableEffect(final UnblockableEffect effect) {
|
||||||
super(effect);
|
super(effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
public void newId() {
|
||||||
if (permanent.getId().equals(source.getSourceId())) {
|
// do nothing
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
|
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||||
return false;
|
if (permanent.getAbilities().containsKey(UnblockableAbility.getInstance().getId())) {
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UnblockableEffect copy() {
|
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
|
||||||
return new UnblockableEffect(this);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UnblockableEffect copy() {
|
||||||
|
return new UnblockableEffect(this);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue