forked from External/mage
* Kicker - added support of X and mana cost interactions like Rosheen Meanderer + Verdeloth the Ancient combo (#3538);
* Rosheen Meanderer - fixed that mana can be payed for mana cost with X instead any cost with X (#3538);
This commit is contained in:
parent
49fc094546
commit
cc54a92daa
7 changed files with 216 additions and 147 deletions
|
|
@ -0,0 +1,73 @@
|
|||
package mage.abilities.dynamicvalue.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.OptionalAdditionalCost;
|
||||
import mage.abilities.costs.OptionalAdditionalCostImpl;
|
||||
import mage.abilities.costs.VariableCost;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.keyword.KickerAbility;
|
||||
import mage.game.Game;
|
||||
import mage.game.stack.Spell;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author JayDi85
|
||||
*/
|
||||
public enum GetKickerXValue implements DynamicValue {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability source, Effect effect) {
|
||||
// calcs only kicker with X values
|
||||
|
||||
// kicker adds additional costs to spell ability
|
||||
// only one X value per card possible
|
||||
// kicker can be calls multiple times (use getKickedCounter)
|
||||
|
||||
int finalValue = 0;
|
||||
Spell spell = game.getSpellOrLKIStack(source.getSourceId());
|
||||
if (spell != null && spell.getSpellAbility() != null) {
|
||||
int xValue = spell.getSpellAbility().getManaCostsToPay().getX();
|
||||
for (Ability ability : spell.getAbilities()) {
|
||||
if (ability instanceof KickerAbility) {
|
||||
|
||||
// search that kicker used X value
|
||||
KickerAbility kickerAbility = (KickerAbility) ability;
|
||||
boolean haveVarCost = false;
|
||||
for (OptionalAdditionalCost cost : kickerAbility.getKickerCosts()) {
|
||||
List<VariableCost> varCosts = ((OptionalAdditionalCostImpl) cost).getVariableCosts();
|
||||
if (!varCosts.isEmpty()) {
|
||||
haveVarCost = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (haveVarCost) {
|
||||
int kickedCount = ((KickerAbility) ability).getKickedCounter(game, source);
|
||||
if (kickedCount > 0) {
|
||||
finalValue += kickedCount * xValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return finalValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GetKickerXValue copy() {
|
||||
return GetKickerXValue.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "X";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue