mirror of
https://github.com/magefree/mage.git
synced 2026-01-23 11:49:56 -08:00
* Disrupting Shoal - Fixed that the target spell was not countered if the spell was cast with the regular mana costs.
This commit is contained in:
parent
3441b9d216
commit
285cff0b33
3 changed files with 68 additions and 35 deletions
|
|
@ -32,10 +32,12 @@ import mage.ObjectColor;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.costs.AlternativeCostSourceAbility;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.common.ExileFromHandCost;
|
||||
import mage.abilities.dynamicvalue.common.ExileFromHandCostCardConvertedMana;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.SplitCard;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
|
|
@ -99,12 +101,34 @@ class DisruptingShoalCounterTargetEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source));
|
||||
if (spell != null && new ExileFromHandCostCardConvertedMana().isConvertedManaCostEqual(game, source, this, spell.getConvertedManaCost())) {
|
||||
if (spell != null && isConvertedManaCostEqual(source, spell.getConvertedManaCost())) {
|
||||
return game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isConvertedManaCostEqual(Ability sourceAbility, int amount) {
|
||||
for (Cost cost : sourceAbility.getCosts()) {
|
||||
if (cost.isPaid() && cost instanceof ExileFromHandCost) {
|
||||
for (Card card : ((ExileFromHandCost) cost).getCards()) {
|
||||
if (card instanceof SplitCard) {
|
||||
if (((SplitCard) card).getLeftHalfCard().getManaCost().convertedManaCost() == amount) {
|
||||
return true;
|
||||
}
|
||||
if (((SplitCard) card).getRightHalfCard().getManaCost().convertedManaCost() == amount) {
|
||||
return true;
|
||||
}
|
||||
} else if (card.getManaCost().convertedManaCost() == amount) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// No alternate costs payed so compare to X value
|
||||
return sourceAbility.getManaCostsToPay().getX() == amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
return "Counter target spell if its converted mana cost is X";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue