Merge pull request #3662 from spjspj/master

Implement Memory Crystal (EXO)
This commit is contained in:
spjspj 2017-07-12 12:41:31 +10:00 committed by GitHub
commit b9f4adaf44

View file

@ -28,7 +28,6 @@
package mage.abilities.keyword;
import java.util.Iterator;
import java.util.List;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.StaticAbility;
@ -38,7 +37,6 @@ import mage.abilities.costs.OptionalAdditionalCost;
import mage.abilities.costs.OptionalAdditionalCostImpl;
import mage.abilities.costs.OptionalAdditionalSourceCosts;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.mana.ManaCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.Card;
@ -107,12 +105,14 @@ public class BuybackAbility extends StaticAbility implements OptionalAdditionalS
// Called by Memory Crystal to reduce mana costs.
public int reduceCost(int genericManaToReduce) {
int amountToReduce = genericManaToReduce;
boolean foundCostToReduce = false;
if (buybackCost != null) {
for (Object cost : ((Costs) buybackCost)) {
if (cost instanceof ManaCostsImpl) {
for (Object c : (ManaCostsImpl) cost) {
if (c instanceof GenericManaCost) {
int newCostCMC = ((GenericManaCost) c).convertedManaCost() - amountToReduceBy - genericManaToReduce;
foundCostToReduce = true;
if (newCostCMC > 0) {
amountToReduceBy += genericManaToReduce;
} else {
@ -124,8 +124,11 @@ public class BuybackAbility extends StaticAbility implements OptionalAdditionalS
}
}
}
if (foundCostToReduce) {
return amountToReduce;
}
return 0;
}
@Override
public boolean isActivated() {