66import mage .abilities .Ability ;
77import mage .abilities .costs .Cost ;
88import mage .abilities .costs .common .TapSourceCost ;
9- import mage .abilities .costs .mana .ManaCost ;
10- import mage .abilities .costs .mana .ManaCosts ;
11- import mage .abilities .effects .mana .ManaEffect ;
129import mage .abilities .keyword .CompanionAbility ;
1310import mage .abilities .keyword .CompanionCondition ;
14- import mage .abilities .mana .SimpleManaAbility ;
1511import mage .abilities .mana .conditional .ManaCondition ;
1612import mage .cards .Card ;
1713import mage .cards .CardImpl ;
2016import mage .game .Game ;
2117
2218import java .util .*;
19+ import mage .abilities .mana .ConditionalColoredManaAbility ;
20+ import mage .abilities .mana .builder .ConditionalManaBuilder ;
2321
2422/**
2523 * @author TheElk801
@@ -39,8 +37,8 @@ public JeganthaTheWellspring(UUID ownerId, CardSetInfo setInfo) {
3937 this .addAbility (new CompanionAbility (JeganthaTheWellspringCompanionCondition .instance ));
4038
4139 // {T}: Add {W}{U}{B}{R}{G}. This mana can't be spent to pay generic mana costs.
42- this .addAbility (new SimpleManaAbility (
43- Zone . BATTLEFIELD , new JeganthaTheWellspringManaEffect ( ), new TapSourceCost ()
40+ this .addAbility (new ConditionalColoredManaAbility (
41+ new TapSourceCost () , new Mana ( 1 , 1 , 1 , 1 , 1 , 0 , 0 , 0 ), new JeganthaManaBuilder ()
4442 ));
4543 }
4644
@@ -72,65 +70,38 @@ private static boolean checkCard(Card card) {
7270 return card .getManaCostSymbols ()
7371 .stream ()
7472 .anyMatch (s -> symbolMap .compute (
75- s , (str , i ) -> (i == null ) ? 1 : i + 1
76- ) > 1 );
73+ s , (str , i ) -> (i == null ) ? 1 : i + 1
74+ ) > 1 );
7775 }
7876}
7977
80- class JeganthaTheWellspringManaEffect extends ManaEffect {
81-
82- JeganthaTheWellspringManaEffect () {
83- super ();
84- staticText = "Add {W}{U}{B}{R}{G}. This mana can't be spent to pay generic mana costs." ;
85- }
86-
87- private JeganthaTheWellspringManaEffect (final JeganthaTheWellspringManaEffect effect ) {
88- super (effect );
89- }
78+ class JeganthaManaBuilder extends ConditionalManaBuilder {
9079
9180 @ Override
92- public Mana produceMana (Game game , Ability source ) {
93- Mana mana = new Mana ();
94- mana .add (new JeganthaTheWellspringConditionalMana ("W" ));
95- mana .add (new JeganthaTheWellspringConditionalMana ("U" ));
96- mana .add (new JeganthaTheWellspringConditionalMana ("B" ));
97- mana .add (new JeganthaTheWellspringConditionalMana ("R" ));
98- mana .add (new JeganthaTheWellspringConditionalMana ("G" ));
99- return mana ;
81+ public ConditionalMana build (Object ... options ) {
82+ return new JeganthaConditionalMana (this .mana );
10083 }
10184
10285 @ Override
103- public JeganthaTheWellspringManaEffect copy () {
104- return new JeganthaTheWellspringManaEffect ( this ) ;
86+ public String getRule () {
87+ return "This mana can't be spent to pay generic mana costs" ;
10588 }
10689}
10790
108- class JeganthaTheWellspringConditionalMana extends ConditionalMana {
91+ class JeganthaConditionalMana extends ConditionalMana {
10992
110- JeganthaTheWellspringConditionalMana (String manaSymbol ) {
111- super (new Mana (ColoredManaSymbol .valueOf (manaSymbol )));
112- addCondition (new JeganthaTheWellspringManaCondition (manaSymbol ));
93+ JeganthaConditionalMana (Mana mana ) {
94+ super (mana );
95+ staticText = "This mana can't be spent to pay generic mana costs" ;
96+ addCondition (new JeganthaManaCondition ());
11397 }
11498}
11599
116- class JeganthaTheWellspringManaCondition extends ManaCondition {
117-
118- private final String manaSymbol ;
119-
120- JeganthaTheWellspringManaCondition (String manaSymbol ) {
121- this .manaSymbol = manaSymbol .toLowerCase (Locale .ENGLISH );
122- }
100+ class JeganthaManaCondition extends ManaCondition {
123101
124102 @ Override
125- public boolean apply (Game game , Ability source , UUID originalId , Cost costToPay ) {
126- if (!(costToPay instanceof ManaCosts )) {
127- return false ;
128- }
129- return Arrays .stream (
130- ((ManaCosts <ManaCost >) costToPay )
131- .getUnpaid ()
132- .getText ()
133- .split ("[\\ }\\ {]" )
134- ).map (s -> s .toLowerCase (Locale .ENGLISH )).anyMatch (s -> s .contains (manaSymbol ));
103+ public boolean apply (Game game , Ability source , UUID originalId , Cost costsToPay ) {
104+ // TODO find a better method. this one forces the user to pay off the generic mana before continuing.
105+ return source .getManaCostsToPay ().getUnpaid ().getMana ().getGeneric () == 0 ;
135106 }
136107}
0 commit comments