mirror of
https://github.com/correl/mage.git
synced 2024-12-28 03:00:10 +00:00
- Workaround for #8844. The quirk is that the controller must pay off all generic mana before the generated mana can be used. If you have a better method, please apply it.
This commit is contained in:
parent
51afccfa73
commit
f0ca05e6fa
1 changed files with 27 additions and 56 deletions
|
@ -6,12 +6,8 @@ import mage.Mana;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.costs.Cost;
|
import mage.abilities.costs.Cost;
|
||||||
import mage.abilities.costs.common.TapSourceCost;
|
import mage.abilities.costs.common.TapSourceCost;
|
||||||
import mage.abilities.costs.mana.ManaCost;
|
|
||||||
import mage.abilities.costs.mana.ManaCosts;
|
|
||||||
import mage.abilities.effects.mana.ManaEffect;
|
|
||||||
import mage.abilities.keyword.CompanionAbility;
|
import mage.abilities.keyword.CompanionAbility;
|
||||||
import mage.abilities.keyword.CompanionCondition;
|
import mage.abilities.keyword.CompanionCondition;
|
||||||
import mage.abilities.mana.SimpleManaAbility;
|
|
||||||
import mage.abilities.mana.conditional.ManaCondition;
|
import mage.abilities.mana.conditional.ManaCondition;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
@ -20,6 +16,8 @@ import mage.constants.*;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import mage.abilities.mana.ConditionalColoredManaAbility;
|
||||||
|
import mage.abilities.mana.builder.ConditionalManaBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author TheElk801
|
* @author TheElk801
|
||||||
|
@ -39,8 +37,8 @@ public final class JeganthaTheWellspring extends CardImpl {
|
||||||
this.addAbility(new CompanionAbility(JeganthaTheWellspringCompanionCondition.instance));
|
this.addAbility(new CompanionAbility(JeganthaTheWellspringCompanionCondition.instance));
|
||||||
|
|
||||||
// {T}: Add {W}{U}{B}{R}{G}. This mana can't be spent to pay generic mana costs.
|
// {T}: Add {W}{U}{B}{R}{G}. This mana can't be spent to pay generic mana costs.
|
||||||
this.addAbility(new SimpleManaAbility(
|
this.addAbility(new ConditionalColoredManaAbility(
|
||||||
Zone.BATTLEFIELD, new JeganthaTheWellspringManaEffect(), new TapSourceCost()
|
new TapSourceCost(), new Mana(1, 1, 1, 1, 1, 0, 0, 0), new JeganthaManaBuilder()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,65 +70,38 @@ enum JeganthaTheWellspringCompanionCondition implements CompanionCondition {
|
||||||
return card.getManaCostSymbols()
|
return card.getManaCostSymbols()
|
||||||
.stream()
|
.stream()
|
||||||
.anyMatch(s -> symbolMap.compute(
|
.anyMatch(s -> symbolMap.compute(
|
||||||
s, (str, i) -> (i == null) ? 1 : i + 1
|
s, (str, i) -> (i == null) ? 1 : i + 1
|
||||||
) > 1);
|
) > 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class JeganthaTheWellspringManaEffect extends ManaEffect {
|
class JeganthaManaBuilder extends ConditionalManaBuilder {
|
||||||
|
|
||||||
JeganthaTheWellspringManaEffect() {
|
@Override
|
||||||
super();
|
public ConditionalMana build(Object... options) {
|
||||||
staticText = "Add {W}{U}{B}{R}{G}. This mana can't be spent to pay generic mana costs.";
|
return new JeganthaConditionalMana(this.mana);
|
||||||
}
|
|
||||||
|
|
||||||
private JeganthaTheWellspringManaEffect(final JeganthaTheWellspringManaEffect effect) {
|
|
||||||
super(effect);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mana produceMana(Game game, Ability source) {
|
public String getRule() {
|
||||||
Mana mana = new Mana();
|
return "This mana can't be spent to pay generic mana costs";
|
||||||
mana.add(new JeganthaTheWellspringConditionalMana("W"));
|
|
||||||
mana.add(new JeganthaTheWellspringConditionalMana("U"));
|
|
||||||
mana.add(new JeganthaTheWellspringConditionalMana("B"));
|
|
||||||
mana.add(new JeganthaTheWellspringConditionalMana("R"));
|
|
||||||
mana.add(new JeganthaTheWellspringConditionalMana("G"));
|
|
||||||
return mana;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class JeganthaConditionalMana extends ConditionalMana {
|
||||||
|
|
||||||
|
JeganthaConditionalMana(Mana mana) {
|
||||||
|
super(mana);
|
||||||
|
staticText = "This mana can't be spent to pay generic mana costs";
|
||||||
|
addCondition(new JeganthaManaCondition());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class JeganthaManaCondition extends ManaCondition {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JeganthaTheWellspringManaEffect copy() {
|
public boolean apply(Game game, Ability source, UUID originalId, Cost costsToPay) {
|
||||||
return new JeganthaTheWellspringManaEffect(this);
|
// TODO find a better method. this one forces the user to pay off the generic mana before continuing.
|
||||||
}
|
return source.getManaCostsToPay().getUnpaid().getMana().getGeneric() == 0;
|
||||||
}
|
|
||||||
|
|
||||||
class JeganthaTheWellspringConditionalMana extends ConditionalMana {
|
|
||||||
|
|
||||||
JeganthaTheWellspringConditionalMana(String manaSymbol) {
|
|
||||||
super(new Mana(ColoredManaSymbol.valueOf(manaSymbol)));
|
|
||||||
addCondition(new JeganthaTheWellspringManaCondition(manaSymbol));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class JeganthaTheWellspringManaCondition extends ManaCondition {
|
|
||||||
|
|
||||||
private final String manaSymbol;
|
|
||||||
|
|
||||||
JeganthaTheWellspringManaCondition(String manaSymbol) {
|
|
||||||
this.manaSymbol = manaSymbol.toLowerCase(Locale.ENGLISH);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Game game, Ability source, UUID originalId, Cost costToPay) {
|
|
||||||
if (!(costToPay instanceof ManaCosts)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return Arrays.stream(
|
|
||||||
((ManaCosts<ManaCost>) costToPay)
|
|
||||||
.getUnpaid()
|
|
||||||
.getText()
|
|
||||||
.split("[\\}\\{]")
|
|
||||||
).map(s -> s.toLowerCase(Locale.ENGLISH)).anyMatch(s -> s.contains(manaSymbol));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue