* Fixed a bug that mana source restrictins got lost with mana cost madification (e.g. cast Myr Superion while Etherium Sculptor in play).

This commit is contained in:
LevelX2 2014-08-16 13:03:13 +02:00
parent fcc28ac0f3
commit f84d624f1f
4 changed files with 58 additions and 6 deletions

View file

@ -422,7 +422,12 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
@Override
public Filter getSourceFilter() {
throw new UnsupportedOperationException("Not supported yet.");
for (T cost : this) {
if (cost.getSourceFilter() != null) {
return cost.getSourceFilter();
}
}
return null;
}
@Override

View file

@ -102,7 +102,7 @@ public class SpellsCostReductionControllerEffect extends CostModificationEffectI
if (spell != null) {
return this.filter.match(spell, game);
} else {
// used at least for flashback ability because Flashback ability doesn't use stack
// used at least for flashback ability because Flashback ability doesn't use stack or for getPlayables where spell is not cast yet
Card sourceCard = game.getCard(abilityToModify.getSourceId());
return sourceCard != null && this.filter.match(sourceCard, game);
}

View file

@ -195,7 +195,7 @@ public class CardUtil {
private static ManaCosts<ManaCost> adjustCost(ManaCosts<ManaCost> manaCosts, int reduceCount) {
int restToReduce = reduceCount;
ManaCosts<ManaCost> adjustedCost = new ManaCostsImpl<>();
ManaCosts<ManaCost> adjustedCost = new ManaCostsImpl<>();
boolean updated = false;
for (ManaCost manaCost : manaCosts) {
Mana mana = manaCost.getOptions().get(0);
@ -217,7 +217,7 @@ public class CardUtil {
if (!updated && reduceCount < 0) {
adjustedCost.add(new GenericManaCost(-reduceCount));
}
adjustedCost.setSourceFilter(manaCosts.getSourceFilter());
return adjustedCost;
}
@ -255,7 +255,7 @@ public class CardUtil {
*/
public static void adjustCost(SpellAbility spellAbility, ManaCosts<ManaCost> manaCostsToReduce, boolean convertToGeneric) {
ManaCosts<ManaCost> previousCost = spellAbility.getManaCostsToPay();
ManaCosts<ManaCost> adjustedCost = new ManaCostsImpl<>();
ManaCosts<ManaCost> adjustedCost = new ManaCostsImpl<>();
// save X value (e.g. convoke ability)
for (VariableCost vCost: previousCost.getVariableCosts()) {
if (vCost instanceof VariableManaCost) {
@ -352,7 +352,7 @@ public class CardUtil {
adjustedCost.add(0, new GenericManaCost(mana.count()));
}
}
adjustedCost.setSourceFilter(previousCost.getSourceFilter()); // keep mana source restrictions
spellAbility.getManaCostsToPay().clear();
spellAbility.getManaCostsToPay().addAll(adjustedCost);
}