mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
updated cost adjustment for Pteramander, added test
This commit is contained in:
parent
c61f8bcd01
commit
4daaaddbb0
2 changed files with 59 additions and 35 deletions
|
@ -3,17 +3,18 @@ package mage.cards.p;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.costs.CostAdjuster;
|
||||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
import mage.abilities.dynamicvalue.DynamicValue;
|
import mage.abilities.dynamicvalue.DynamicValue;
|
||||||
import mage.abilities.dynamicvalue.common.CardsInControllerGraveyardCount;
|
import mage.abilities.dynamicvalue.common.CardsInControllerGraveyardCount;
|
||||||
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
|
|
||||||
import mage.abilities.effects.keyword.AdaptEffect;
|
import mage.abilities.effects.keyword.AdaptEffect;
|
||||||
|
import mage.abilities.hint.Hint;
|
||||||
import mage.abilities.hint.ValueHint;
|
import mage.abilities.hint.ValueHint;
|
||||||
import mage.abilities.keyword.FlyingAbility;
|
import mage.abilities.keyword.FlyingAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.*;
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.SubType;
|
||||||
import mage.filter.StaticFilters;
|
import mage.filter.StaticFilters;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
@ -26,8 +27,6 @@ import java.util.UUID;
|
||||||
*/
|
*/
|
||||||
public final class Pteramander extends CardImpl {
|
public final class Pteramander extends CardImpl {
|
||||||
|
|
||||||
static final DynamicValue cardsCount = new CardsInControllerGraveyardCount(StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY);
|
|
||||||
|
|
||||||
public Pteramander(UUID ownerId, CardSetInfo setInfo) {
|
public Pteramander(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{U}");
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{U}");
|
||||||
|
|
||||||
|
@ -40,11 +39,9 @@ public final class Pteramander extends CardImpl {
|
||||||
this.addAbility(FlyingAbility.getInstance());
|
this.addAbility(FlyingAbility.getInstance());
|
||||||
|
|
||||||
// {7}{U}: Adapt 4. This ability costs {1} less to activate for each instant and sorcery card in your graveyard.
|
// {7}{U}: Adapt 4. This ability costs {1} less to activate for each instant and sorcery card in your graveyard.
|
||||||
// TODO: Make ability properly copiable
|
|
||||||
Ability ability = new SimpleActivatedAbility(new AdaptEffect(4).setText("Adapt 4. This ability costs {1} less to activate for each instant and sorcery card in your graveyard."), new ManaCostsImpl("{7}{U}"));
|
Ability ability = new SimpleActivatedAbility(new AdaptEffect(4).setText("Adapt 4. This ability costs {1} less to activate for each instant and sorcery card in your graveyard."), new ManaCostsImpl("{7}{U}"));
|
||||||
this.addAbility(ability);
|
ability.setCostAdjuster(PteramanderAdjuster.instance);
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.ALL, new PteramanderCostIncreasingEffect(ability.getOriginalId()))
|
this.addAbility(ability.addHint(PteramanderAdjuster.getHint()));
|
||||||
.addHint(new ValueHint("Instant and sorcery cards in your graveyard", cardsCount)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Pteramander(final Pteramander card) {
|
private Pteramander(final Pteramander card) {
|
||||||
|
@ -57,38 +54,24 @@ public final class Pteramander extends CardImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PteramanderCostIncreasingEffect extends CostModificationEffectImpl {
|
enum PteramanderAdjuster implements CostAdjuster {
|
||||||
|
instance;
|
||||||
|
|
||||||
private final UUID originalId;
|
private static final DynamicValue cardsCount = new CardsInControllerGraveyardCount(
|
||||||
|
StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY
|
||||||
|
);
|
||||||
|
private static final Hint hint = new ValueHint("Instant and sorcery cards in your graveyard", cardsCount);
|
||||||
|
|
||||||
PteramanderCostIncreasingEffect(UUID originalId) {
|
static Hint getHint() {
|
||||||
super(Duration.EndOfGame, Outcome.Benefit, CostModificationType.REDUCE_COST);
|
return hint;
|
||||||
this.originalId = originalId;
|
|
||||||
}
|
|
||||||
|
|
||||||
private PteramanderCostIncreasingEffect(final PteramanderCostIncreasingEffect effect) {
|
|
||||||
super(effect);
|
|
||||||
this.originalId = effect.originalId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
public void adjustCosts(Ability ability, Game game) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(ability.getControllerId());
|
||||||
if (controller != null) {
|
if (controller != null) {
|
||||||
int count = Pteramander.cardsCount.calculate(game, source, this);
|
int count = cardsCount.calculate(game, ability, null);
|
||||||
CardUtil.reduceCost(abilityToModify, count);
|
CardUtil.reduceCost(ability, count);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
|
||||||
return abilityToModify.getOriginalId().equals(originalId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PteramanderCostIncreasingEffect copy() {
|
|
||||||
return new PteramanderCostIncreasingEffect(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
package org.mage.test.cards.single.rna;
|
||||||
|
|
||||||
|
import mage.constants.PhaseStep;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author TheElk801
|
||||||
|
*/
|
||||||
|
public class PteramanderTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNoReduction() {
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Island", 8);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Pteramander");
|
||||||
|
|
||||||
|
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{7}");
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.END_TURN);
|
||||||
|
execute();
|
||||||
|
assertAllCommandsUsed();
|
||||||
|
|
||||||
|
assertPowerToughness(playerA, "Pteramander", 5, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReduction() {
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Island", 1);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Pteramander");
|
||||||
|
addCard(Zone.GRAVEYARD, playerA, "Ancestral Recall", 7);
|
||||||
|
|
||||||
|
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{7}");
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.END_TURN);
|
||||||
|
execute();
|
||||||
|
assertAllCommandsUsed();
|
||||||
|
|
||||||
|
assertPowerToughness(playerA, "Pteramander", 5, 5);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue