mirror of
https://github.com/correl/mage.git
synced 2025-04-02 03:18:09 -09:00
Fixed that discard cost of Wolf of Devil's Breach was not handled correctly (fixes #1668).
This commit is contained in:
parent
8780a6101a
commit
b80166664f
3 changed files with 74 additions and 20 deletions
Mage.Sets/src/mage/sets/shadowsoverinnistrad
Mage.Tests/src/test/java/org/mage/test/cards/single/soi
Mage/src/main/java/mage/abilities/effects/common
|
@ -31,14 +31,20 @@ import java.util.UUID;
|
|||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AttacksTriggeredAbility;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.Costs;
|
||||
import mage.abilities.costs.CostsImpl;
|
||||
import mage.abilities.costs.common.DiscardCardCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.dynamicvalue.common.DiscardCostCardConvertedMana;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.abilities.effects.common.DoIfCostPaid;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.game.Game;
|
||||
import mage.target.common.TargetCreatureOrPlaneswalker;
|
||||
|
||||
/**
|
||||
|
@ -55,12 +61,15 @@ public class WolfOfDevilsBreach extends CardImpl {
|
|||
this.power = new MageInt(5);
|
||||
this.toughness = new MageInt(5);
|
||||
|
||||
// Whenever Wolf of Devil's Breach attacks, you may pay {1}{R} and discard a card. If you do, Wolf of Devil's Breach deals
|
||||
// Whenever Wolf of Devil's Breach attacks, you may pay {1}{R} and discard a card. If you do, Wolf of Devil's Breach deals
|
||||
// damage to target creature or planeswalker equal to the discarded card's converted mana cost.
|
||||
Ability ability = new AttacksTriggeredAbility(new DoIfCostPaid(new DamageTargetEffect(new DiscardCostCardConvertedMana()), new ManaCostsImpl("{1}{R}")), true,
|
||||
Costs toPay = new CostsImpl<>();
|
||||
toPay.add(new ManaCostsImpl<>("{1}{R}"));
|
||||
toPay.add(new DiscardCardCost());
|
||||
Ability ability = new AttacksTriggeredAbility(new DoIfCostPaid(new DamageTargetEffect(new WolfOfDevilsBreachDiscardCostCardConvertedMana()), toPay,
|
||||
"Pay {1}{R} and discard a card to let {this} do damage to target creature or planeswalker equal to the discarded card's converted mana cost?", true), false,
|
||||
"Whenever {this} attacks you may pay {1}{R} and discard a card. If you do, {this} deals damage to target creature or planeswalker "
|
||||
+ "equal to the discarded card's converted mana cost.");
|
||||
ability.addCost(new DiscardCardCost());
|
||||
+ "equal to the discarded card's converted mana cost.");
|
||||
ability.addTarget(new TargetCreatureOrPlaneswalker());
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
@ -74,3 +83,44 @@ public class WolfOfDevilsBreach extends CardImpl {
|
|||
return new WolfOfDevilsBreach(this);
|
||||
}
|
||||
}
|
||||
|
||||
class WolfOfDevilsBreachDiscardCostCardConvertedMana implements DynamicValue {
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
for (Effect sourceEffect : sourceAbility.getEffects()) {
|
||||
if (sourceEffect instanceof DoIfCostPaid) {
|
||||
Cost doCosts = ((DoIfCostPaid) sourceEffect).getCost();
|
||||
if (doCosts instanceof Costs) {
|
||||
Costs costs = (Costs) doCosts;
|
||||
for (Object cost : costs) {
|
||||
if (cost instanceof DiscardCardCost) {
|
||||
DiscardCardCost discardCost = (DiscardCardCost) cost;
|
||||
int cmc = 0;
|
||||
for (Card card : discardCost.getCards()) {
|
||||
cmc += card.getManaCost().convertedManaCost();
|
||||
}
|
||||
return cmc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WolfOfDevilsBreachDiscardCostCardConvertedMana copy() {
|
||||
return new WolfOfDevilsBreachDiscardCostCardConvertedMana();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "the discarded card's converted mana cost";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,54 +6,54 @@ import org.junit.Test;
|
|||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
* 3RR
|
||||
Creature - Elemental Wolf
|
||||
*Whenever Wolf of Devil's Breach attacks, you may pay 1R and discard a card.
|
||||
* If you do, Wolf of Devil's Breach deals damage to target creature or planeswalker equal to the discarded card's converted mana cost.
|
||||
* 3RR Creature - Elemental Wolf Whenever Wolf of Devil's Breach attacks, you
|
||||
* may pay 1R and discard a card. If you do, Wolf of Devil's Breach deals damage
|
||||
* to target creature or planeswalker equal to the discarded card's converted
|
||||
* mana cost.
|
||||
*
|
||||
* @author escplan9 (Derek Monturo - dmontur1 at gmail dot com)
|
||||
*/
|
||||
public class WolfOfDevilsBreachTest extends CardTestPlayerBase {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void attackChooseToPay() {
|
||||
|
||||
// Whenever Wolf of Devil's Breach attacks, you may pay {1}{R} and discard a card. If you do, Wolf of Devil's Breach deals
|
||||
// damage to target creature or planeswalker equal to the discarded card's converted mana cost.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Wolf of Devil's Breach", 1);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
|
||||
addCard(Zone.HAND, playerA, "Bronze Sable", 1); // (2) 2/1
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Grizzly Bears", 1); // 2/2
|
||||
|
||||
|
||||
attack(1, playerA, "Wolf of Devil's Breach");
|
||||
setChoice(playerA, "Yes");
|
||||
setChoice(playerA, "Bronze Sable");
|
||||
addTarget(playerA, "Grizzly Bears");
|
||||
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
|
||||
assertGraveyardCount(playerA, "Bronze Sable", 1);
|
||||
assertGraveyardCount(playerB, "Grizzly Bears", 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void attackDoNotPay() {
|
||||
|
||||
// Whenever Wolf of Devil's Breach attacks, you may pay {1}{R} and discard a card. If you do, Wolf of Devil's Breach deals
|
||||
// damage to target creature or planeswalker equal to the discarded card's converted mana cost.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Wolf of Devil's Breach", 1);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
|
||||
addCard(Zone.HAND, playerA, "Bronze Sable", 1); // (2) 2/1
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Grizzly Bears", 1); // 2/2
|
||||
|
||||
|
||||
attack(1, playerA, "Wolf of Devil's Breach");
|
||||
setChoice(playerA, "No");
|
||||
setChoice(playerA, "Bronze Sable");
|
||||
addTarget(playerA, "Grizzly Bears");
|
||||
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
|
||||
assertHandCount(playerA, "Bronze Sable", 1); // never discarded
|
||||
assertGraveyardCount(playerA, "Bronze Sable", 0);
|
||||
assertGraveyardCount(playerB, "Grizzly Bears", 0);
|
||||
|
|
|
@ -90,6 +90,10 @@ public class DoIfCostPaid extends OneShotEffect {
|
|||
return game.getPlayer(source.getControllerId());
|
||||
}
|
||||
|
||||
public Cost getCost() {
|
||||
return cost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (!staticText.isEmpty()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue