mirror of
https://github.com/correl/mage.git
synced 2024-11-29 03:00:12 +00:00
[LGN] Fixed Ward Sliver not properly giving protection. Closes #9418
This commit is contained in:
parent
ebd7d3ef15
commit
4368bae50c
2 changed files with 131 additions and 2 deletions
|
@ -3,6 +3,7 @@ package mage.cards.w;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
|
import mage.MageObject;
|
||||||
import mage.ObjectColor;
|
import mage.ObjectColor;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.AsEntersBattlefieldAbility;
|
import mage.abilities.common.AsEntersBattlefieldAbility;
|
||||||
|
@ -13,6 +14,7 @@ import mage.abilities.keyword.ProtectionAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.*;
|
import mage.constants.*;
|
||||||
|
import mage.filter.FilterObject;
|
||||||
import mage.filter.FilterPermanent;
|
import mage.filter.FilterPermanent;
|
||||||
import mage.filter.StaticFilters;
|
import mage.filter.StaticFilters;
|
||||||
import mage.filter.common.FilterCreaturePermanent;
|
import mage.filter.common.FilterCreaturePermanent;
|
||||||
|
@ -57,7 +59,7 @@ public final class WardSliver extends CardImpl {
|
||||||
|
|
||||||
class WardSliverGainAbilityControlledEffect extends ContinuousEffectImpl {
|
class WardSliverGainAbilityControlledEffect extends ContinuousEffectImpl {
|
||||||
|
|
||||||
protected FilterPermanent protectionFilter;
|
protected FilterObject<MageObject> protectionFilter;
|
||||||
|
|
||||||
public WardSliverGainAbilityControlledEffect() {
|
public WardSliverGainAbilityControlledEffect() {
|
||||||
super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
|
super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
|
||||||
|
@ -81,7 +83,7 @@ class WardSliverGainAbilityControlledEffect extends ContinuousEffectImpl {
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
ObjectColor color = (ObjectColor) game.getState().getValue(permanent.getId() + "_color");
|
ObjectColor color = (ObjectColor) game.getState().getValue(permanent.getId() + "_color");
|
||||||
if (color != null) {
|
if (color != null) {
|
||||||
protectionFilter = new FilterPermanent(color.getDescription());
|
protectionFilter = new FilterObject<>(color.getDescription());
|
||||||
protectionFilter.add(new ColorPredicate(color));
|
protectionFilter.add(new ColorPredicate(color));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,127 @@
|
||||||
|
package org.mage.test.cards.single.lgn;
|
||||||
|
|
||||||
|
import mage.ObjectColor;
|
||||||
|
import mage.abilities.keyword.ProtectionAbility;
|
||||||
|
import mage.constants.PhaseStep;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import mage.filter.FilterPermanent;
|
||||||
|
import mage.filter.predicate.mageobject.ColorPredicate;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link mage.cards.w.WardSliver Ward Sliver}
|
||||||
|
* {4}{W}
|
||||||
|
*
|
||||||
|
* As Ward Sliver enters the battlefield, choose a color.
|
||||||
|
* All Slivers have protection from the chosen color.
|
||||||
|
*
|
||||||
|
* @author Alex-Vasile
|
||||||
|
*/
|
||||||
|
public class WardSliverTest extends CardTestPlayerBase {
|
||||||
|
private static final String wardSliver = "Ward Sliver";
|
||||||
|
// {W}
|
||||||
|
// Exile target creature
|
||||||
|
String pathToExile = "Path to Exile";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that it gives protection to itself.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void givesItselfProtection() {
|
||||||
|
addCard(Zone.HAND, playerA, wardSliver);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Plains", 5);
|
||||||
|
|
||||||
|
addCard(Zone.HAND, playerB, pathToExile);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Plains");
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, wardSliver);
|
||||||
|
setChoice(playerA, "White");
|
||||||
|
|
||||||
|
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
FilterPermanent filter = new FilterPermanent(ObjectColor.WHITE.getDescription());
|
||||||
|
filter.add(new ColorPredicate(ObjectColor.WHITE));
|
||||||
|
assertAbility(playerA, wardSliver, new ProtectionAbility(filter), true);
|
||||||
|
|
||||||
|
checkPlayableAbility("Can't exile", 1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Cast " + pathToExile, false);
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
|
||||||
|
execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that it gives protection to another sliver.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void givesOtherSliversProtection() {
|
||||||
|
// {1}
|
||||||
|
String metalicSliver = "Metallic Sliver";
|
||||||
|
|
||||||
|
addCard(Zone.HAND, playerA, wardSliver);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, metalicSliver);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Plains", 5);
|
||||||
|
|
||||||
|
addCard(Zone.HAND, playerB, pathToExile);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Plains");
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, wardSliver);
|
||||||
|
setChoice(playerA, "White");
|
||||||
|
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
FilterPermanent filter = new FilterPermanent(ObjectColor.WHITE.getDescription());
|
||||||
|
filter.add(new ColorPredicate(ObjectColor.WHITE));
|
||||||
|
assertAbility(playerA, metalicSliver, new ProtectionAbility(filter), true);
|
||||||
|
|
||||||
|
checkPlayableAbility("Can't exile", 1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Cast " + pathToExile, false);
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
|
||||||
|
execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reported bug: https://github.com/magefree/mage/issues/9418
|
||||||
|
* Player casts Ward Sliver and chooses white.
|
||||||
|
* Same player has a Morophon on the board.
|
||||||
|
* Another player was able to target Morophon with Path to Exile, even though it should have gotten protection from white.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void givesProtectionToChangeling() {
|
||||||
|
// {7}
|
||||||
|
// As Morophon, the Boundless enters the battlefield, choose a creature type.
|
||||||
|
String morophon = "Morophon, the Boundless";
|
||||||
|
|
||||||
|
addCard(Zone.HAND, playerA, wardSliver);
|
||||||
|
addCard(Zone.HAND, playerA, morophon);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Plains", 12);
|
||||||
|
|
||||||
|
addCard(Zone.HAND, playerB, pathToExile);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Plains");
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, morophon);
|
||||||
|
setChoice(playerA, "Dragon");
|
||||||
|
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, wardSliver);
|
||||||
|
setChoice(playerA, "White");
|
||||||
|
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
FilterPermanent filter = new FilterPermanent(ObjectColor.WHITE.getDescription());
|
||||||
|
filter.add(new ColorPredicate(ObjectColor.WHITE));
|
||||||
|
assertAbility(playerA, morophon, new ProtectionAbility(filter), true);
|
||||||
|
|
||||||
|
checkPlayableAbility("Can't exile", 1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Cast " + pathToExile, false);
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
|
||||||
|
execute();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue