[IKO] added test for Zirda, the Dawnwaker

This commit is contained in:
Evan Kranzler 2021-03-14 11:40:08 -04:00
parent e0336d4d65
commit 13ac8f2c01
2 changed files with 86 additions and 13 deletions

View file

@ -2,8 +2,8 @@ package mage.cards.z;
import mage.MageInt; import mage.MageInt;
import mage.MageObject; import mage.MageObject;
import mage.Mana;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.ActivatedAbility;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
@ -20,6 +20,7 @@ import mage.game.Game;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import mage.util.CardUtil; import mage.util.CardUtil;
import java.util.Collection;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -40,7 +41,7 @@ public final class ZirdaTheDawnwaker extends CardImpl {
// Companion Each permanent card in your starting deck has an activated ability. // Companion Each permanent card in your starting deck has an activated ability.
this.addAbility(new CompanionAbility(ZirdaTheDawnwakerCompanionCondition.instance)); this.addAbility(new CompanionAbility(ZirdaTheDawnwakerCompanionCondition.instance));
// Abilities you activate that aren't mana abilities cost {2} less to activate. // Abilities you activate that aren't mana abilities cost {2} less to activate.
// This effect can't reduce the mana in that cost to less than one mana. // This effect can't reduce the mana in that cost to less than one mana.
this.addAbility(new SimpleStaticAbility(new ZirdaTheDawnwakerEffect())); this.addAbility(new SimpleStaticAbility(new ZirdaTheDawnwakerEffect()));
@ -76,13 +77,9 @@ enum ZirdaTheDawnwakerCompanionCondition implements CompanionCondition {
return deck return deck
.stream() .stream()
.filter(MageObject::isPermanent) .filter(MageObject::isPermanent)
.allMatch(card -> card .map(MageObject::getAbilities)
.getAbilities() .flatMap(Collection::stream)
.stream() .anyMatch(ActivatedAbility.class::isInstance);
.map(Ability::getAbilityType)
.anyMatch(abilityType -> abilityType == AbilityType.ACTIVATED
|| abilityType == AbilityType.MANA)
);
} }
} }
@ -100,8 +97,10 @@ class ZirdaTheDawnwakerEffect extends CostModificationEffectImpl {
@Override @Override
public boolean apply(Game game, Ability source, Ability abilityToModify) { public boolean apply(Game game, Ability source, Ability abilityToModify) {
int reduceMax = CardUtil.calculateActualPossibleGenericManaReduction(abilityToModify.getManaCostsToPay().getMana(), 2, 1); int reduceMax = CardUtil.calculateActualPossibleGenericManaReduction(
if (reduceMax <= 0) { abilityToModify.getManaCostsToPay().getMana(), 2, 1
);
if (reduceMax < 1) {
return true; return true;
} }
CardUtil.reduceCost(abilityToModify, reduceMax); CardUtil.reduceCost(abilityToModify, reduceMax);
@ -112,8 +111,7 @@ class ZirdaTheDawnwakerEffect extends CostModificationEffectImpl {
@Override @Override
public boolean applies(Ability abilityToModify, Ability source, Game game) { public boolean applies(Ability abilityToModify, Ability source, Game game) {
return abilityToModify.getAbilityType() == AbilityType.ACTIVATED return abilityToModify.getAbilityType() == AbilityType.ACTIVATED
&& abilityToModify.isControlledBy(source.getControllerId()) && abilityToModify.isControlledBy(source.getControllerId());
&& abilityToModify.getAbilityType() != AbilityType.MANA; // no mana abilities
} }
@Override @Override

View file

@ -0,0 +1,75 @@
package org.mage.test.cards.single.iko;
import mage.abilities.keyword.TrampleAbility;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author TheElk801
*/
public class ZirdaTheDawnwakerTest extends CardTestPlayerBase {
private static final String zirda = "Zirda, the Dawnwaker";
private static final String golem = "Igneous Golem";
private static final String mauler = "Barkhide Mauler";
private static final String geth = "Geth, Lord of the Vault";
private static final String lion = "Silvercoat Lion";
@Test
public void testReduceToOne() {
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1);
addCard(Zone.BATTLEFIELD, playerA, zirda);
addCard(Zone.BATTLEFIELD, playerA, golem);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{2}");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertTapped("Swamp", true);
assertAbility(playerA, golem, TrampleAbility.getInstance(), true);
}
@Test
public void testCycling() {
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1);
addCard(Zone.BATTLEFIELD, playerA, zirda);
addCard(Zone.HAND, playerA, mauler);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cycling");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertTapped("Swamp", true);
assertGraveyardCount(playerA, mauler, 1);
}
@Test
public void testWithGeth() {
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1);
addCard(Zone.BATTLEFIELD, playerA, zirda);
addCard(Zone.BATTLEFIELD, playerA, geth);
addCard(Zone.GRAVEYARD, playerB, lion);
setChoice(playerA, "X=2");
addTarget(playerA, lion);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{X}{B}");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, lion, 1);
assertTapped(lion, true);
assertGraveyardCount(playerB, 2);
assertGraveyardCount(playerB, lion, 0);
}
}