mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
* Affinity abilities - added support of other cost modification effects like combo with commander tax (#5856);
* Affinity abilities - added artifact/land count hints to card;
This commit is contained in:
parent
6157187f07
commit
6e5ba7a446
7 changed files with 181 additions and 21 deletions
|
@ -6,7 +6,6 @@ import org.junit.Test;
|
||||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author noxx
|
* @author noxx
|
||||||
*/
|
*/
|
||||||
public class AffinityForArtifactsTest extends CardTestPlayerBase {
|
public class AffinityForArtifactsTest extends CardTestPlayerBase {
|
||||||
|
@ -22,7 +21,10 @@ public class AffinityForArtifactsTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Myr Enforcer");
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Myr Enforcer");
|
||||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||||
|
|
||||||
|
setStrictChooseMode(true);
|
||||||
execute();
|
execute();
|
||||||
|
assertAllCommandsUsed();
|
||||||
|
|
||||||
assertPermanentCount(playerA, "Myr Enforcer", 4);
|
assertPermanentCount(playerA, "Myr Enforcer", 4);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
package org.mage.test.commander.duel;
|
||||||
|
|
||||||
|
import mage.constants.PhaseStep;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mage.test.serverside.base.CardTestCommanderDuelBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author JayDi85
|
||||||
|
*/
|
||||||
|
public class CommanderAffinityTest extends CardTestCommanderDuelBase {
|
||||||
|
|
||||||
|
/*
|
||||||
|
Blinkmoth Infusion {12}{U}{U}
|
||||||
|
Affinity for artifacts (This spell costs {1} less to cast for each artifact you control.)
|
||||||
|
Untap all artifacts.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_AffinityNormal() {
|
||||||
|
addCard(Zone.HAND, playerA, "Blinkmoth Infusion", 1);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Abzan Banner", 12);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Island", 2);
|
||||||
|
|
||||||
|
checkHandCardCount("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Blinkmoth Infusion", 1);
|
||||||
|
|
||||||
|
// cast for UU (12 must be reduced)
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Blinkmoth Infusion");
|
||||||
|
checkHandCardCount("after", 1, PhaseStep.BEGIN_COMBAT, playerA, "Blinkmoth Infusion", 0);
|
||||||
|
|
||||||
|
setStrictChooseMode(true);
|
||||||
|
setStopAt(1, PhaseStep.END_TURN);
|
||||||
|
execute();
|
||||||
|
assertAllCommandsUsed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_AffinityCommanderNormalReduction() {
|
||||||
|
addCard(Zone.COMMAND, playerA, "Blinkmoth Infusion", 1);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Abzan Banner", 12);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Island", 2 + 2 * 2);
|
||||||
|
|
||||||
|
checkCommandCardCount("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Blinkmoth Infusion", 1);
|
||||||
|
|
||||||
|
// first cast for 12UU (-12 by abzan, -UU by islands)
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Blinkmoth Infusion");
|
||||||
|
setChoice(playerA, "Yes"); // keep commander
|
||||||
|
checkCommandCardCount("after 1", 1, PhaseStep.BEGIN_COMBAT, playerA, "Blinkmoth Infusion", 1);
|
||||||
|
|
||||||
|
// second cast for 12UU + 2 (-12 by abzan, -UU by islands, -2 by islands)
|
||||||
|
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Blinkmoth Infusion");
|
||||||
|
setChoice(playerA, "No"); // remove commander to grave
|
||||||
|
checkCommandCardCount("after 2", 1, PhaseStep.END_TURN, playerA, "Blinkmoth Infusion", 0);
|
||||||
|
|
||||||
|
setStrictChooseMode(true);
|
||||||
|
setStopAt(1, PhaseStep.END_TURN);
|
||||||
|
execute();
|
||||||
|
assertAllCommandsUsed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_AffinityCommanderAdditionalReduction() {
|
||||||
|
addCard(Zone.COMMAND, playerA, "Blinkmoth Infusion", 1);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Abzan Banner", 20);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Island", 2 + 2);
|
||||||
|
|
||||||
|
checkCommandCardCount("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Blinkmoth Infusion", 1);
|
||||||
|
|
||||||
|
// first cast for 12UU (-12 by abzan, -UU by islands)
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Blinkmoth Infusion");
|
||||||
|
setChoice(playerA, "Yes"); // keep commander
|
||||||
|
checkCommandCardCount("after 1", 1, PhaseStep.BEGIN_COMBAT, playerA, "Blinkmoth Infusion", 1);
|
||||||
|
|
||||||
|
// second cast for 12UU + 2 (-12 by abzan, -UU by islands, -2 by abzan)
|
||||||
|
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Blinkmoth Infusion");
|
||||||
|
setChoice(playerA, "No"); // remove commander to grave
|
||||||
|
checkCommandCardCount("after 2", 1, PhaseStep.END_TURN, playerA, "Blinkmoth Infusion", 0);
|
||||||
|
|
||||||
|
setStrictChooseMode(true);
|
||||||
|
setStopAt(1, PhaseStep.END_TURN);
|
||||||
|
execute();
|
||||||
|
assertAllCommandsUsed();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -683,6 +683,13 @@ public class TestPlayer implements Player {
|
||||||
wasProccessed = true;
|
wasProccessed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check command card count: card name, count
|
||||||
|
if (params[0].equals(CHECK_COMMAND_COMMAND_CARD_COUNT) && params.length == 3) {
|
||||||
|
assertCommandCardCount(action, game, computerPlayer, params[1], Integer.parseInt(params[2]));
|
||||||
|
actions.remove(action);
|
||||||
|
wasProccessed = true;
|
||||||
|
}
|
||||||
|
|
||||||
// check color: card name, colors, must have
|
// check color: card name, colors, must have
|
||||||
if (params[0].equals(CHECK_COMMAND_COLOR) && params.length == 4) {
|
if (params[0].equals(CHECK_COMMAND_COLOR) && params.length == 4) {
|
||||||
assertColor(action, game, computerPlayer, params[1], params[2], Boolean.parseBoolean(params[3]));
|
assertColor(action, game, computerPlayer, params[1], params[2], Boolean.parseBoolean(params[3]));
|
||||||
|
@ -1038,6 +1045,18 @@ public class TestPlayer implements Player {
|
||||||
Assert.assertEquals(action.getActionName() + " - hand must contain " + count + " cards of " + cardName, count, realCount);
|
Assert.assertEquals(action.getActionName() + " - hand must contain " + count + " cards of " + cardName, count, realCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void assertCommandCardCount(PlayerAction action, Game game, Player player, String cardName, int count) {
|
||||||
|
int realCount = 0;
|
||||||
|
for (UUID cardId : game.getCommandersIds(player)) {
|
||||||
|
Card card = game.getCard(cardId);
|
||||||
|
if (card != null && card.getName().equals(cardName) && Zone.COMMAND.equals(game.getState().getZone(cardId))) {
|
||||||
|
realCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.assertEquals(action.getActionName() + " - command zone must contain " + count + " cards of " + cardName, count, realCount);
|
||||||
|
}
|
||||||
|
|
||||||
private void assertColor(PlayerAction action, Game game, Player player, String permanentName, String colors, boolean mustHave) {
|
private void assertColor(PlayerAction action, Game game, Player player, String permanentName, String colors, boolean mustHave) {
|
||||||
Assert.assertNotEquals(action.getActionName() + " - must setup colors", "", colors);
|
Assert.assertNotEquals(action.getActionName() + " - must setup colors", "", colors);
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
||||||
public static final String CHECK_COMMAND_EXILE_COUNT = "EXILE_COUNT";
|
public static final String CHECK_COMMAND_EXILE_COUNT = "EXILE_COUNT";
|
||||||
public static final String CHECK_COMMAND_HAND_COUNT = "HAND_COUNT";
|
public static final String CHECK_COMMAND_HAND_COUNT = "HAND_COUNT";
|
||||||
public static final String CHECK_COMMAND_HAND_CARD_COUNT = "HAND_CARD_COUNT";
|
public static final String CHECK_COMMAND_HAND_CARD_COUNT = "HAND_CARD_COUNT";
|
||||||
|
public static final String CHECK_COMMAND_COMMAND_CARD_COUNT = "COMMAND_CARD_COUNT";
|
||||||
public static final String CHECK_COMMAND_COLOR = "COLOR";
|
public static final String CHECK_COMMAND_COLOR = "COLOR";
|
||||||
public static final String CHECK_COMMAND_TYPE = "TYPE";
|
public static final String CHECK_COMMAND_TYPE = "TYPE";
|
||||||
public static final String CHECK_COMMAND_SUBTYPE = "SUBTYPE";
|
public static final String CHECK_COMMAND_SUBTYPE = "SUBTYPE";
|
||||||
|
@ -345,6 +346,11 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
||||||
check(checkName, turnNum, step, player, CHECK_COMMAND_HAND_CARD_COUNT, cardName, count.toString());
|
check(checkName, turnNum, step, player, CHECK_COMMAND_HAND_CARD_COUNT, cardName, count.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkCommandCardCount(String checkName, int turnNum, PhaseStep step, TestPlayer player, String cardName, Integer count) {
|
||||||
|
//Assert.assertNotEquals("", cardName);
|
||||||
|
check(checkName, turnNum, step, player, CHECK_COMMAND_COMMAND_CARD_COUNT, cardName, count.toString());
|
||||||
|
}
|
||||||
|
|
||||||
public void checkColor(String checkName, int turnNum, PhaseStep step, TestPlayer player, String permanentName, String colors, Boolean mustHave) {
|
public void checkColor(String checkName, int turnNum, PhaseStep step, TestPlayer player, String permanentName, String colors, Boolean mustHave) {
|
||||||
//Assert.assertNotEquals("", permanentName);
|
//Assert.assertNotEquals("", permanentName);
|
||||||
check(checkName, turnNum, step, player, CHECK_COMMAND_COLOR, permanentName, colors, mustHave.toString());
|
check(checkName, turnNum, step, player, CHECK_COMMAND_COLOR, permanentName, colors, mustHave.toString());
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
package mage.abilities.dynamicvalue.common;
|
||||||
|
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.dynamicvalue.DynamicValue;
|
||||||
|
import mage.abilities.effects.Effect;
|
||||||
|
import mage.filter.StaticFilters;
|
||||||
|
import mage.game.Game;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author JayDi85
|
||||||
|
*/
|
||||||
|
public enum ArtifactsYouControlCount implements DynamicValue {
|
||||||
|
|
||||||
|
instance;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||||
|
return game.getBattlefield().count(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArtifactsYouControlCount copy() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "X";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMessage() {
|
||||||
|
return "artifacts you control";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package mage.abilities.hint.common;
|
||||||
|
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.dynamicvalue.common.ArtifactsYouControlCount;
|
||||||
|
import mage.abilities.hint.Hint;
|
||||||
|
import mage.abilities.hint.ValueHint;
|
||||||
|
import mage.game.Game;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author JayDi85
|
||||||
|
*/
|
||||||
|
public enum ArtifactsYouControlHint implements Hint {
|
||||||
|
|
||||||
|
instance;
|
||||||
|
private static final Hint hint = new ValueHint("Artifacts you control", ArtifactsYouControlCount.instance);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getText(Game game, Ability ability) {
|
||||||
|
return hint.getText(game, ability);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Hint copy() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,24 +1,19 @@
|
||||||
|
|
||||||
package mage.abilities.keyword;
|
package mage.abilities.keyword;
|
||||||
|
|
||||||
import mage.abilities.Ability;
|
|
||||||
import mage.abilities.SpellAbility;
|
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.costs.AdjustingSourceCosts;
|
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
|
||||||
import mage.abilities.effects.common.AffinityEffect;
|
import mage.abilities.effects.common.AffinityEffect;
|
||||||
|
import mage.abilities.hint.ValueHint;
|
||||||
import mage.constants.SubType;
|
import mage.constants.SubType;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.filter.common.FilterControlledPermanent;
|
import mage.filter.common.FilterControlledPermanent;
|
||||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||||
import mage.game.Game;
|
|
||||||
import mage.util.CardUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class AffinityForLandTypeAbility extends SimpleStaticAbility implements AdjustingSourceCosts {
|
public class AffinityForLandTypeAbility extends SimpleStaticAbility {
|
||||||
|
|
||||||
private final FilterControlledPermanent filter;
|
private final FilterControlledPermanent filter;
|
||||||
|
|
||||||
|
@ -26,11 +21,13 @@ public class AffinityForLandTypeAbility extends SimpleStaticAbility implements A
|
||||||
SubType landType;
|
SubType landType;
|
||||||
|
|
||||||
public AffinityForLandTypeAbility(SubType landType, String text) {
|
public AffinityForLandTypeAbility(SubType landType, String text) {
|
||||||
super(Zone.OUTSIDE, new AffinityEffect(getFilter(landType)));
|
super(Zone.ALL, new AffinityEffect(getFilter(landType)));
|
||||||
this.filter = getFilter(landType);
|
this.filter = getFilter(landType);
|
||||||
setRuleAtTheTop(true);
|
setRuleAtTheTop(true);
|
||||||
this.text = text;
|
this.text = text;
|
||||||
this.landType = landType;
|
this.landType = landType;
|
||||||
|
|
||||||
|
this.addHint(new ValueHint(landType + " you control", new PermanentsOnBattlefieldCount(filter)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static FilterControlledPermanent getFilter(SubType landType) {
|
private static FilterControlledPermanent getFilter(SubType landType) {
|
||||||
|
@ -55,14 +52,4 @@ public class AffinityForLandTypeAbility extends SimpleStaticAbility implements A
|
||||||
public String getRule() {
|
public String getRule() {
|
||||||
return "Affinity for " + text + " <i>(This spell costs 1 less to cast for each " + landType + " you control.)</i>";
|
return "Affinity for " + text + " <i>(This spell costs 1 less to cast for each " + landType + " you control.)</i>";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void adjustCosts(Ability ability, Game game) {
|
|
||||||
if (ability instanceof SpellAbility) {
|
|
||||||
int count = game.getBattlefield().getAllActivePermanents(filter, ability.getControllerId(), game).size();
|
|
||||||
if (count > 0) {
|
|
||||||
CardUtil.adjustCost((SpellAbility)ability, count);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue