foul-magics/Mage.Sets/src/mage/cards/p/Pteramander.java
Oleg Agafonov bae3089abb Reworked cost adjuster logic for better support of X and cost modification effects:
Improves:
* refactor: split CostAdjuster logic in multiple parts - prepare X, prepare cost, increase cost, reduce cost;
* refactor: improved VariableManaCost to support min/max values, playable and AI calculations, test framework;
* refactor: improved EarlyTargetCost to support mana costs too (related to #13023);
* refactor: migrated some cards with CostAdjuster and X to EarlyTargetCost (Knollspine Invocation, etc - related to #13023);
* refactor: added shared code for "As an additional cost to cast this spell, discard X creature cards";
* refactor: added shared code for "X is the converted mana cost of the exiled card";
* tests: added dozens tests with cost adjusters;

Bug fixes:
* game: fixed that some cards with CostAdjuster ignore min/max limits for X (allow to choose any X, example: Scorched Earth, Open The Way);
* game: fixed that some cards ask to announce already defined X values (example: Bargaining Table);
* game: fixed that some cards with CostAdjuster do not support combo with other cost modification effects;
* game, gui: fixed missing game logs about predefined X values;
* game, gui: fixed wrong X icon for predefined X values;

Test framework:
* test framework: added X min/max check for wrong values;
* test framework: added X min/max info in miss X value announce;
* test framework: added check to find duplicated effect bugs (see assertNoDuplicatedEffects);

Cards:
* Open The Way - fixed that it allow to choose any X without limits (close #12810);
* Unbound Flourishing - improved combo support for activated abilities with predefined X mana costs like Bargaining Table;
2025-04-08 22:39:10 +04:00

77 lines
2.4 KiB
Java

package mage.cards.p;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.CostAdjuster;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.CardsInControllerGraveyardCount;
import mage.abilities.effects.keyword.AdaptEffect;
import mage.abilities.hint.Hint;
import mage.abilities.hint.ValueHint;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.util.CardUtil;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class Pteramander extends CardImpl {
public Pteramander(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{U}");
this.subtype.add(SubType.SALAMANDER);
this.subtype.add(SubType.DRAKE);
this.power = new MageInt(1);
this.toughness = new MageInt(1);
// Flying
this.addAbility(FlyingAbility.getInstance());
// {7}{U}: Adapt 4. This ability costs {1} less to activate for each instant and sorcery card in your graveyard.
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.setCostAdjuster(PteramanderAdjuster.instance);
this.addAbility(ability.addHint(PteramanderAdjuster.getHint()));
}
private Pteramander(final Pteramander card) {
super(card);
}
@Override
public Pteramander copy() {
return new Pteramander(this);
}
}
enum PteramanderAdjuster implements CostAdjuster {
instance;
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);
static Hint getHint() {
return hint;
}
@Override
public void reduceCost(Ability ability, Game game) {
int count = cardsCount.calculate(game, ability, null);
CardUtil.reduceCost(ability, count);
}
}