Improved and fixed X mana cost and pays, mana pool:

* Pay X abilities - fixed that it spends all available mana pool instead only needed;
 * Pay X abilities - added support of interactions with other X effects like Rosheen Meanderer's mana usage for "pay X to prevent";
 * Rosheen Meanderer - fixed that it can't use mana for "you may pay X" like Flameblast Dragon's effect (#5206);
 * Devs: added support to use VariableManaCost to pay X in code (without generic's workaround, use ManaUtil.createManaCost to generate cost to pay);
This commit is contained in:
Oleg Agafonov 2019-06-20 21:18:01 +04:00
parent 500fc935e4
commit 437861ec20
20 changed files with 675 additions and 192 deletions

View file

@ -1,7 +1,5 @@
package mage.cards.f;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.AttacksTriggeredAbility;
@ -13,20 +11,22 @@ import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetAnyTarget;
import java.util.UUID;
/**
* @author Loki
*/
public final class FlameblastDragon extends CardImpl {
public FlameblastDragon(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{4}{R}{R}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{R}{R}");
this.subtype.add(SubType.DRAGON);
this.power = new MageInt(5);
@ -34,6 +34,7 @@ public final class FlameblastDragon extends CardImpl {
// Flying
this.addAbility(FlyingAbility.getInstance());
// Whenever Flameblast Dragon attacks, you may pay {X}{R}. If you do, Flameblast Dragon deals X damage to any target.
Ability ability = new AttacksTriggeredAbility(new FlameblastDragonEffect(), false);
ability.addTarget(new TargetAnyTarget());

View file

@ -4,9 +4,12 @@ import mage.ConditionalMana;
import mage.MageInt;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.costs.mana.VariableManaCost;
import mage.abilities.effects.mana.BasicManaEffect;
import mage.abilities.mana.BasicManaAbility;
import mage.abilities.mana.conditional.ManaCondition;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
@ -70,7 +73,7 @@ class RosheenMeandererConditionalMana extends ConditionalMana {
}
}
class RosheenMeandererManaCondition implements Condition {
class RosheenMeandererManaCondition extends ManaCondition {
/*
A cost that contains {X} may be a spells total cost, an activated abilitys cost, a suspend cost, or a cost youre
@ -81,7 +84,11 @@ class RosheenMeandererManaCondition implements Condition {
*/
@Override
public boolean apply(Game game, Ability source) {
return source.getManaCostsToPay().containsX();
public boolean apply(Game game, Ability source, UUID originalId, Cost costToPay) {
if (costToPay instanceof ManaCosts) {
return !((ManaCosts) costToPay).getVariableCosts().isEmpty();
} else {
return costToPay instanceof VariableManaCost;
}
}
}