Added miss code and comments for alternative code (additional to b6a3f7edc1)

This commit is contained in:
Oleg Agafonov 2021-08-06 18:55:43 +04:00
parent b073ff8617
commit 3406ef6b4e
2 changed files with 12 additions and 4 deletions

View file

@ -4,11 +4,11 @@ package mage.abilities.costs;
import mage.game.Game;
/**
* Virtual alternative cost, it must be tranformed to simple cost on activate in your
* custom ability (see askToActivateAlternativeCosts). Example: DashAbility
*
* @author LevelX2
*/
public interface AlternativeCost2 extends Cost {
String getName();

View file

@ -3303,6 +3303,7 @@ public abstract class PlayerImpl implements Player, Serializable {
if (alternateSourceCostsAbility.getCosts().canPay(ability, ability, playerId, game)) {
ManaCostsImpl manaCosts = new ManaCostsImpl();
for (Cost cost : alternateSourceCostsAbility.getCosts()) {
// AlternativeCost2 replaced by real cost on activate, so getPlayable need to extract that costs here
if (cost instanceof AlternativeCost2) {
if (((AlternativeCost2) cost).getCost() instanceof ManaCost) {
manaCosts.add((ManaCost) ((AlternativeCost2) cost).getCost());
@ -3351,8 +3352,15 @@ public abstract class PlayerImpl implements Player, Serializable {
if (((Ability) alternateSourceCosts).getCosts().canPay(ability, ability, playerId, game)) {
ManaCostsImpl manaCosts = new ManaCostsImpl();
for (Cost cost : ((Ability) alternateSourceCosts).getCosts()) {
if (cost instanceof ManaCost) {
manaCosts.add((ManaCost) cost);
// AlternativeCost2 replaced by real cost on activate, so getPlayable need to extract that costs here
if (cost instanceof AlternativeCost2) {
if (((AlternativeCost2) cost).getCost() instanceof ManaCost) {
manaCosts.add((ManaCost) ((AlternativeCost2) cost).getCost());
}
} else {
if (cost instanceof ManaCost) {
manaCosts.add((ManaCost) cost);
}
}
}