mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
Merge pull request #3662 from spjspj/master
Implement Memory Crystal (EXO)
This commit is contained in:
commit
b9f4adaf44
1 changed files with 11 additions and 8 deletions
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue