* Fixed available mana calculation for Cryptic Trilobite and Titans' Nest. Added some improvements for available mana calculation of conditional mana.

This commit is contained in:
LevelX2 2020-08-16 01:16:52 +02:00
parent 3d989b24ac
commit 768f1bec4f
100 changed files with 507 additions and 144 deletions

View file

@ -1,4 +1,3 @@
package mage.cards.a;
import java.util.UUID;
@ -11,6 +10,7 @@ import mage.abilities.condition.Condition;
import mage.abilities.keyword.FlashbackAbility;
import mage.abilities.mana.ConditionalAnyColorManaAbility;
import mage.abilities.mana.builder.ConditionalManaBuilder;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
@ -25,7 +25,7 @@ import mage.game.stack.Spell;
public final class AltarOfTheLost extends CardImpl {
public AltarOfTheLost(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{3}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}");
// Altar of the Lost enters the battlefield tapped.
this.addAbility(new EntersBattlefieldTappedAbility());
@ -71,6 +71,16 @@ class AltarOfTheLostManaCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
MageObject object = game.getObject(source.getSourceId());
if (game != null && game.inCheckPlayableState()) {
if (object instanceof Card && game.getState().getZone(source.getSourceId()).equals(Zone.GRAVEYARD)) {
for (Ability ability : ((Card) object).getAbilities(game)) {
if (ability instanceof FlashbackAbility) {
return true;
}
}
}
}
if (object instanceof Spell && ((Spell) object).getFromZone() == Zone.GRAVEYARD) {
for (Ability ability : ((Spell) object).getAbilities(game)) {
if (ability instanceof FlashbackAbility) {

View file

@ -5,7 +5,7 @@ import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.EntersBattlefieldWithXCountersEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;

View file

@ -7,7 +7,7 @@ import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.mana.ActivatedManaAbilityImpl;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;

View file

@ -4,7 +4,7 @@ import mage.MageInt;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;

View file

@ -10,7 +10,7 @@ import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.common.ChooseColorEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.mana.TriggeredManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;

View file

@ -3,7 +3,7 @@ package mage.cards.c;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.choices.ChoiceColor;

View file

@ -6,7 +6,7 @@ import mage.abilities.costs.Cost;
import mage.abilities.costs.common.PutTopCardOfYourLibraryToGraveyardCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.*;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.effects.mana.BasicManaEffect;
import mage.abilities.mana.ActivatedManaAbilityImpl;
import mage.abilities.mana.ManaOptions;

View file

@ -7,7 +7,7 @@ import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.Card;
import mage.cards.CardImpl;

View file

@ -5,7 +5,7 @@ import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTappedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.mana.ActivatedManaAbilityImpl;
import mage.cards.Card;
import mage.cards.CardImpl;

View file

@ -12,6 +12,7 @@ import mage.abilities.costs.Cost;
import mage.abilities.costs.common.RemoveCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.common.EntersBattlefieldWithXCountersEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.mana.ConditionalColorlessManaAbility;
@ -42,10 +43,11 @@ public final class CrypticTrilobite extends CardImpl {
new EntersBattlefieldWithXCountersEffect(CounterType.P1P1.createInstance())
));
// Remove a +1/+1 counter from Cryptic Trilobite: Add {C}{C}. Spend this mana only to activate abilities.
// Remove a +1/+1 counter from Cryptic Trilobite: Add {C}{C}. Spend this mana only to activate abilities.
this.addAbility(new ConditionalColorlessManaAbility(
new RemoveCountersSourceCost(CounterType.P1P1.createInstance()),
2, new CrypticTrilobiteManaBuilder()
2, new CrypticTrilobiteManaBuilder(),
new CountersSourceCount(CounterType.P1P1)
));
// {1}, {T}: Put a +1/+1 counter on Cryptic Trilobite.

View file

@ -3,7 +3,7 @@ package mage.cards.d;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.abilities.mana.TriggeredManaAbility;
import mage.cards.CardImpl;

View file

@ -10,7 +10,7 @@ import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.GetEmblemEffect;
import mage.abilities.effects.common.LookLibraryAndPickControllerEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.effects.common.continuous.GainAbilityControlledSpellsEffect;
import mage.abilities.effects.mana.BasicManaEffect;
import mage.abilities.keyword.RiotAbility;

View file

@ -4,7 +4,7 @@ import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTappedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;

View file

@ -9,7 +9,7 @@ import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.mana.VariableManaCost;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.effects.common.discard.DiscardTargetEffect;
import mage.abilities.hint.common.MyTurnHint;
import mage.abilities.mana.ActivatedManaAbilityImpl;

View file

@ -8,7 +8,7 @@ import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.abilities.keyword.VigilanceAbility;
import mage.abilities.mana.SimpleManaAbility;

View file

@ -4,7 +4,7 @@ import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTappedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.effects.mana.AddManaOfTwoDifferentColorsEffect;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl;

View file

@ -5,7 +5,7 @@ import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.ExileTargetCost;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.mana.SimpleManaAbility;
import mage.abilities.mana.builder.ConditionalManaBuilder;
import mage.abilities.mana.conditional.CreatureCastConditionalMana;

View file

@ -7,7 +7,7 @@ import mage.ObjectColor;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.common.TapForManaAllTriggeredManaAbility;
import mage.abilities.effects.mana.AddManaToManaPoolTargetControllerEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.effects.common.continuous.BoostAllEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;

View file

@ -10,7 +10,7 @@ import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.ChooseColorEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.mana.TriggeredManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;

View file

@ -5,7 +5,7 @@ import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;

View file

@ -7,7 +7,7 @@ import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.effects.mana.AddManaOfTwoDifferentColorsEffect;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl;

View file

@ -12,7 +12,7 @@ import mage.abilities.costs.common.PayLifeCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.mana.BasicManaEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
import mage.abilities.keyword.HasteAbility;
import mage.abilities.mana.SimpleManaAbility;

View file

@ -14,7 +14,7 @@ import mage.abilities.decorator.ConditionalActivatedAbility;
import mage.abilities.effects.AsThoughEffect;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.Card;

View file

@ -5,7 +5,7 @@ import mage.Mana;
import mage.abilities.Abilities;
import mage.abilities.Ability;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.keyword.AdaptAbility;
import mage.abilities.mana.ActivatedManaAbilityImpl;
import mage.abilities.mana.SimpleManaAbility;

View file

@ -3,7 +3,7 @@ package mage.cards.j;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;

View file

@ -8,7 +8,7 @@ import mage.abilities.costs.Cost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCost;
import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.keyword.CompanionAbility;
import mage.abilities.keyword.CompanionCondition;
import mage.abilities.mana.SimpleManaAbility;

View file

@ -8,7 +8,7 @@ import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.decorator.ConditionalActivatedAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl;

View file

@ -7,7 +7,7 @@ import mage.abilities.costs.Cost;
import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl;

View file

@ -4,7 +4,7 @@ import mage.Mana;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.TapForManaAllTriggeredManaAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.effects.common.counter.AddCountersAllEffect;
import mage.abilities.effects.mana.BasicManaEffect;
import mage.abilities.keyword.LeylineAbility;

View file

@ -3,7 +3,7 @@ package mage.cards.m;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;

View file

@ -3,7 +3,7 @@ package mage.cards.m;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.mana.ActivatedManaAbilityImpl;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;

View file

@ -3,7 +3,7 @@ package mage.cards.m;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.abilities.mana.TriggeredManaAbility;
import mage.cards.CardImpl;

View file

@ -4,7 +4,7 @@ import mage.MageInt;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;

View file

@ -4,7 +4,7 @@ import mage.Mana;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;

View file

@ -5,7 +5,7 @@ import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfPostCombatMainTriggeredAbility;
import mage.abilities.dynamicvalue.common.OpponentsLostLifeCount;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.effects.mana.DynamicManaEffect;
import mage.abilities.keyword.AfflictAbility;
import mage.cards.CardImpl;

View file

@ -9,7 +9,7 @@ import mage.abilities.Ability;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.mana.ActivatedManaAbilityImpl;
import mage.abilities.mana.ColorlessManaAbility;
import mage.cards.CardImpl;

View file

@ -9,7 +9,7 @@ import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTappedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.mana.ActivatedManaAbilityImpl;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;

View file

@ -6,7 +6,7 @@ import mage.MageInt;
import mage.abilities.costs.common.ExertSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.mana.AddManaOfAnyColorEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.mana.AnyColorManaAbility;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl;

View file

@ -5,7 +5,7 @@ import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;

View file

@ -7,7 +7,7 @@ import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.mana.AddManaOfAnyColorEffect;
import mage.abilities.effects.common.BecomesMonarchSourceEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.keyword.TrampleAbility;
import mage.abilities.mana.TriggeredManaAbility;
import mage.cards.CardImpl;

View file

@ -6,7 +6,7 @@ import mage.abilities.costs.Cost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.effects.mana.BasicManaEffect;
import mage.abilities.effects.mana.DoUnlessAnyPlayerPaysManaEffect;
import mage.abilities.mana.ActivatedManaAbilityImpl;

View file

@ -2,7 +2,7 @@ package mage.cards.r;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;

View file

@ -20,6 +20,7 @@ import mage.constants.Zone;
import mage.game.Game;
import java.util.UUID;
import mage.MageObject;
/**
* @author jeffwadsworth
@ -82,14 +83,20 @@ class RosheenMeandererManaCondition extends ManaCondition {
its mana cost (printed in the upper right corner) or its alternative cost (such as flashback), as well as any additional
costs (such as kicker). If its something you can spend mana on, its a cost. If that cost includes the {X} symbol in it,
you can spend mana generated by Rosheen on that cost. (2017-11-17)
*/
*/
@Override
public boolean apply(Game game, Ability source, UUID originalId, Cost costToPay) {
boolean result;
if (costToPay instanceof ManaCosts) {
return !((ManaCosts) costToPay).getVariableCosts().isEmpty();
result = !((ManaCosts) costToPay).getVariableCosts().isEmpty();
} else {
return costToPay instanceof VariableManaCost;
result = costToPay instanceof VariableManaCost;
}
if (!result) {
if (game != null && game.inCheckPlayableState()) {
return true; // TODO: Check the card if there are related abilities with {X} costs.
}
}
return result;
}
}

View file

@ -4,7 +4,7 @@ import mage.MageInt;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;

View file

@ -9,7 +9,7 @@ import mage.abilities.common.TapForManaAllTriggeredManaAbility;
import mage.abilities.costs.common.RevealHandSourceControllerCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.FlipSourceEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;

View file

@ -5,7 +5,7 @@ import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.common.AttacksTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;

View file

@ -7,7 +7,7 @@ import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.dynamicvalue.common.ParleyCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DrawCardAllEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.mana.ActivatedManaAbilityImpl;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl;

View file

@ -8,7 +8,7 @@ import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.GreatestPowerAmongControlledCreaturesValue;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.effects.mana.AddManaInAnyCombinationEffect;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl;

View file

@ -4,7 +4,7 @@ import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.ChoosePlayerEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;

View file

@ -10,7 +10,7 @@ import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.mana.AnyColorLandsProduceManaAbility;
import mage.abilities.mana.ManaOptions;
import mage.abilities.mana.SimpleManaAbility;

View file

@ -26,6 +26,7 @@ import mage.players.Player;
import mage.target.common.TargetCardInYourGraveyard;
import java.util.UUID;
import mage.abilities.dynamicvalue.common.CardsInControllerGraveyardCount;
/**
* @author TheElk801
@ -90,7 +91,7 @@ class TitansNestManaAbility extends ActivatedManaAbilityImpl {
TitansNestManaAbility() {
super(Zone.BATTLEFIELD, (BasicManaEffect) new BasicManaEffect(
new TitansNestConditionalMana())
new TitansNestConditionalMana(), new CardsInControllerGraveyardCount())
.setText("Add {C}. Spend this mana only to cast a colored spell without {X} in its mana cost."),
new ExileFromGraveCost(new TargetCardInYourGraveyard()));
this.netMana.add(Mana.ColorlessMana(1));

View file

@ -6,7 +6,7 @@ import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.ChooseColorEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.abilities.mana.TriggeredManaAbility;
import mage.cards.CardImpl;

View file

@ -7,7 +7,7 @@ import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.mana.SimpleManaAbility;
import mage.abilities.mana.builder.ConditionalManaBuilder;
import mage.cards.CardImpl;

View file

@ -5,7 +5,7 @@ import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.ChoosePlayerEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.effects.common.continuous.UntapSourceDuringEachOtherPlayersUntapStepEffect;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl;

View file

@ -5,7 +5,7 @@ import mage.MageInt;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.TapForManaAllTriggeredManaAbility;
import mage.abilities.effects.common.DontUntapInControllersNextUntapStepTargetEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.effects.mana.AddManaOfAnyTypeProducedEffect;
import mage.abilities.keyword.TrampleAbility;
import mage.cards.CardImpl;

View file

@ -7,7 +7,7 @@ import mage.abilities.common.TapForManaAllTriggeredManaAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.mana.AddManaOfAnyTypeProducedEffect;
import mage.abilities.effects.common.DontUntapInControllersNextUntapStepTargetEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;

View file

@ -5,7 +5,7 @@ import mage.MageObject;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.effects.mana.BasicManaEffect;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl;

View file

@ -15,19 +15,20 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
*/
public class GatherSpecimensTest extends CardTestPlayerBase {
/* Gather Specimens {3}{U}{U}{U}
/* Gather Specimens - Instant {3}{U}{U}{U}
*
* If a creature would enter the battlefield under an opponent's control this turn, it enters the battlefield under your control instead.
*/
@Test
public void testFromHandEffect() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerA, "Island", 6);
addCard(Zone.HAND, playerA, "Gather Specimens", 1);
addCard(Zone.LIBRARY, playerB, "Mountain", 1);
addCard(Zone.HAND, playerB, "Memnite", 1);
addCard(Zone.HAND, playerB, "Memnite", 1); // Artifact Creature (1/1) {0}
castSpell(2, PhaseStep.UPKEEP, playerA, "Gather Specimens");
@ -37,6 +38,10 @@ public class GatherSpecimensTest extends CardTestPlayerBase {
execute();
assertAllCommandsUsed();
assertGraveyardCount(playerA, "Gather Specimens", 1);
assertPermanentCount(playerA, "Memnite", 1);
assertPermanentCount(playerB, "Memnite", 0);

View file

@ -1,6 +1,5 @@
package org.mage.test.cards.mana;
import mage.constants.ManaType;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
@ -8,12 +7,14 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
public class GaeasGradleTest extends CardTestPlayerBase {
// {T}: Add {G} for each creature you control.
private final String cradle = "Gaea's Cradle";
private final String bears = "Grizzly Bears";
private final String thopter = "Ornithopter";
@Test
public void testGradle(){
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerA, cradle);
addCard(Zone.BATTLEFIELD, playerA, bears, 2);
addCard(Zone.BATTLEFIELD, playerB, thopter);
@ -23,6 +24,8 @@ public class GaeasGradleTest extends CardTestPlayerBase {
checkManaPool("gaeas cradle ",1, PhaseStep.PRECOMBAT_MAIN, playerA, "G", 2);
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
execute();
assertAllCommandsUsed();
}
}

View file

@ -40,7 +40,7 @@ public class RosheenMeandererManaXTest extends CardTestPlayerBase {
@Test
public void test_KickerWithXMana() {
addCard(Zone.BATTLEFIELD, playerA, "Forest", 6 + 2 - 4);
addCard(Zone.BATTLEFIELD, playerA, "Forest", 6);
addCard(Zone.HAND, playerA, "Verdeloth the Ancient");
//
addCard(Zone.BATTLEFIELD, playerA, "Rosheen Meanderer");

View file

@ -1,4 +1,4 @@
package org.mage.test.cards.mana;
package org.mage.test.cards.mana.conditional;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.mana.ManaOptions;
@ -6,7 +6,6 @@ import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.counters.CounterType;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
@ -20,13 +19,17 @@ public class ConditionalManaTest extends CardTestPlayerBase {
@Test
public void testNormalUse() {
setStrictChooseMode(true);
// {T}: Add one mana of any color. Spend this mana only to cast a multicolored spell.
addCard(Zone.BATTLEFIELD, playerA, "Pillar of the Paruns", 2);
// Instant {G}{W}
// Target player gains 7 life.
addCard(Zone.HAND, playerA, "Heroes' Reunion", 1);
addCard(Zone.HAND, playerA, "Heroes' Reunion", 1); // Instant {G}{W}
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Heroes' Reunion", playerA);
setChoice(playerA, "Green"); // Choose color
setChoice(playerA, "White"); // Choose color
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
@ -358,4 +361,37 @@ public class ConditionalManaTest extends CardTestPlayerBase {
assertLife(playerB, 20 - 3);
}
@Test
public void testTwoConditionalMana(){
setStrictChooseMode(true);
// At the beginning of your upkeep, look at the top card of your library. You may put that card into your graveyard.
// Exile a card from your graveyard: Add {C}. Spend this mana only to cast a colored spell without {X} in its mana cost.
addCard(Zone.BATTLEFIELD, playerA, "Titans' Nest"); // Enchantment {1}{B}{G}{U}
// {T}: Add {C}{C}{C}{C}. Spend this mana only on costs that contain {X}.
addCard(Zone.BATTLEFIELD, playerA, "Rosheen Meanderer", 1);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
addCard(Zone.GRAVEYARD, playerA, "Grizzly Bears", 2);
setChoice(playerA, "No"); // Put [Top Card of Library] into your graveyard?
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Titans' Nest", 1);
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
Assert.assertEquals("mana variations don't fit", 4, manaOptions.size());
assertManaOptions("{R}", manaOptions);
assertManaOptions("{C}{C}{R}[{TitansNestManaCondition}]", manaOptions);
assertManaOptions("{C}{C}{C}{C}{R}[{RosheenMeandererManaCondition}]", manaOptions);
assertManaOptions("{C}{C}{C}{C}{C}{C}{R}[{RosheenMeandererManaCondition}{TitansNestManaCondition}]", manaOptions);
}
}

View file

@ -0,0 +1,112 @@
package org.mage.test.cards.mana.conditional;
import mage.abilities.mana.ManaOptions;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.counters.CounterType;
import org.junit.Assert;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
import static org.mage.test.utils.ManaOptionsTestUtils.assertManaOptions;
/**
*
* @author LevelX2
*/
public class CrypticTrilobiteTest extends CardTestPlayerBase {
@Test
public void testAvailableManaCalculation(){
setStrictChooseMode(true);
// Cryptic Trilobite enters the battlefield with X +1/+1 counters on it.
// Remove a +1/+1 counter from Cryptic Trilobite: Add {C}{C}. Spend this mana only to activate abilities.
// {1}, {T}: Put a +1/+1 counter on Cryptic Trilobite.
addCard(Zone.HAND, playerA, "Cryptic Trilobite"); // Creature {X}{X}
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 10);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cryptic Trilobite");
setChoice(playerA, "X=5");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Cryptic Trilobite", 1);
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
Assert.assertEquals("mana variations don't fit", 1, manaOptions.size());
assertManaOptions("{C}{C}{C}{C}{C}{C}{C}{C}{C}{C}[{CrypticTrilobiteManaCondition}]", manaOptions);
}
@Test
public void testUse(){
setStrictChooseMode(true);
// Cryptic Trilobite enters the battlefield with X +1/+1 counters on it.
// Remove a +1/+1 counter from Cryptic Trilobite: Add {C}{C}. Spend this mana only to activate abilities.
// {1}, {T}: Put a +1/+1 counter on Cryptic Trilobite.
addCard(Zone.HAND, playerA, "Cryptic Trilobite"); // Creature {X}{X}
// Flying
// {2}: Deathknell Kami gets +1/+1 until end of turn. Sacrifice it at the beginning of the next end step.
// Soulshift 1 (When this creature dies, you may return target Spirit card with converted mana cost 1 or less from your graveyard to your hand.)
addCard(Zone.BATTLEFIELD, playerA, "Deathknell Kami"); // Creature (0/1)
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 10);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cryptic Trilobite");
setChoice(playerA, "X=5");
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{2}:");
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{2}:");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Cryptic Trilobite", 1);
assertCounterCount(playerA, "Cryptic Trilobite", CounterType.P1P1, 3);
assertPowerToughness(playerA, "Deathknell Kami", 2, 3);
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
Assert.assertEquals("mana variations don't fit", 1, manaOptions.size());
assertManaOptions("{C}{C}{C}{C}{C}{C}[{CrypticTrilobiteManaCondition}]", manaOptions);
}
@Test
public void testCantUse(){
setStrictChooseMode(true);
// Cryptic Trilobite enters the battlefield with X +1/+1 counters on it.
// Remove a +1/+1 counter from Cryptic Trilobite: Add {C}{C}. Spend this mana only to activate abilities.
// {1}, {T}: Put a +1/+1 counter on Cryptic Trilobite.
addCard(Zone.HAND, playerA, "Cryptic Trilobite"); // Creature {X}{X}
// {4}{W}: Return another target creature you control to its owner's hand.
addCard(Zone.HAND, playerA, "Aegis Automaton"); // Creature {2} (0/2)
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 10);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cryptic Trilobite");
setChoice(playerA, "X=5");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN, playerA);
checkPlayableAbility("can't play", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Aegis Automaton", false);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Cryptic Trilobite", 1);
assertCounterCount(playerA, "Cryptic Trilobite", CounterType.P1P1, 5);
}
}

View file

@ -0,0 +1,44 @@
package org.mage.test.cards.mana.conditional;
import mage.abilities.mana.ManaOptions;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Assert;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
import static org.mage.test.utils.ManaOptionsTestUtils.assertManaOptions;
/**
*
* @author LevelX2
*/
public class TitansNestTest extends CardTestPlayerBase {
@Test
public void testTitansNest(){
setStrictChooseMode(true);
// At the beginning of your upkeep, look at the top card of your library. You may put that card into your graveyard.
// Exile a card from your graveyard: Add {C}. Spend this mana only to cast a colored spell without {X} in its mana cost.
addCard(Zone.HAND, playerA, "Titans' Nest"); // Enchantment {1}{B}{G}{U}
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1);
addCard(Zone.BATTLEFIELD, playerA, "Forest", 2);
addCard(Zone.BATTLEFIELD, playerA, "Island", 1);
addCard(Zone.GRAVEYARD, playerA, "Grizzly Bears", 2);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Titans' Nest");
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Titans' Nest", 1);
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
Assert.assertEquals("mana variations don't fit", 1, manaOptions.size());
assertManaOptions("{C}{C}[{TitansNestManaCondition}]", manaOptions);
}
}

View file

@ -6,6 +6,7 @@ import org.junit.Assert;
import java.util.HashSet;
import java.util.Set;
import mage.ConditionalMana;
public class ManaOptionsTestUtils {
@ -18,29 +19,34 @@ public class ManaOptionsTestUtils {
//mana info
//logger.info(playerA.getManaPool().getMana().toString());
//logger.info(playerA.getManaAvailable(currentGame).toString());
public static boolean manaOptionsContain(ManaOptions list, String searchMana){
for(Mana mana: list){
if (mana.toString().equals(searchMana)){
return true;
public static boolean manaOptionsContain(ManaOptions list, String searchMana) {
for (Mana mana : list) {
if (mana instanceof ConditionalMana) {
if ((mana.toString() + ((ConditionalMana)mana).getConditionString()).equals(searchMana)) {
return true;
}
} else {
if (mana.toString().equals(searchMana)) {
return true;
}
}
}
return false;
}
public static void assertManaOptions(String searchMana, ManaOptions manaList){
if(!manaOptionsContain(manaList, searchMana)){
public static void assertManaOptions(String searchMana, ManaOptions manaList) {
if (!manaOptionsContain(manaList, searchMana)) {
Assert.fail("Can't find " + searchMana + " in " + manaList.toString());
}
}
public static void assertDuplicatedManaOptions(ManaOptions manaList){
public static void assertDuplicatedManaOptions(ManaOptions manaList) {
Set<String> list = new HashSet<>();
for(Mana mana: manaList){
for (Mana mana : manaList) {
String s = mana.toString();
if(list.contains(s)){
if (list.contains(s)) {
Assert.fail("Found duplicated mana option " + s + " in " + manaList.toString());
}else{
} else {
list.add(s);
}
}

View file

@ -52,7 +52,7 @@ public class ConditionalMana extends Mana implements Serializable {
public ConditionalMana(final ConditionalMana conditionalMana) {
super(conditionalMana);
conditions = conditionalMana.conditions;
conditions.addAll(conditionalMana.conditions);
scope = conditionalMana.scope;
staticText = conditionalMana.staticText;
manaProducerId = conditionalMana.manaProducerId;
@ -67,6 +67,10 @@ public class ConditionalMana extends Mana implements Serializable {
this.scope = scope;
}
public List<Condition> getConditions() {
return conditions;
}
public boolean apply(Ability ability, Game game, UUID manaProducerId, Cost costToPay) {
if (conditions.isEmpty()) {
throw new IllegalStateException("Conditional mana should contain at least one Condition");
@ -173,6 +177,24 @@ public class ConditionalMana extends Mana implements Serializable {
}
}
@Override
public void add(Mana mana) {
if (mana instanceof ConditionalMana) {
for (Condition condition : ((ConditionalMana) mana).getConditions()) {
addCondition(condition);
}
}
super.add(mana);
}
public String getConditionString() {
String condStr = "[";
for (Condition condition : conditions) {
condStr += condition.getManaText();
}
return condStr + "]";
}
public void add(ManaType manaType, int amount) {
switch (manaType) {
case BLACK:

View file

@ -275,6 +275,7 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
/**
* Adds mana from the passed in {@link Mana} object to this object.
* Ignores conditions from conditional mana
*
* @param mana mana to add to this object.
*/
@ -1111,6 +1112,17 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
* @return
*/
public static Mana getMoreValuableMana(final Mana mana1, final Mana mana2) {
String conditionString1 = "";
String conditionString2 = "";
if (mana1 instanceof ConditionalMana){
conditionString1 = ((ConditionalMana)mana1).getConditionString();
}
if (mana2 instanceof ConditionalMana){
conditionString2 = ((ConditionalMana)mana2).getConditionString();
}
if (!conditionString1.equals(conditionString2)) {
return null;
}
Mana moreMana;
Mana lessMana;
if (mana2.countColored() > mana1.countColored() || mana2.getAny() > mana1.getAny() || mana2.count() > mana1.count()) {

View file

@ -8,7 +8,7 @@ import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.Effects;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.hint.Hint;
import mage.abilities.mana.ActivatedManaAbilityImpl;
import mage.cards.Card;

View file

@ -16,7 +16,6 @@ import mage.players.Player;
import java.util.Optional;
import java.util.UUID;
import javax.naming.directory.InvalidAttributesException;
/**
* @author BetaSteward_at_googlemail.com

View file

@ -2,7 +2,7 @@
package mage.abilities.common;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.mana.TriggeredManaAbility;
import mage.constants.SetTargetPointer;
import mage.constants.Zone;

View file

@ -2,7 +2,7 @@
package mage.abilities.common;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.mana.TriggeredManaAbility;
import mage.constants.Zone;
import mage.game.Game;

View file

@ -5,7 +5,6 @@ import mage.game.Game;
import java.io.Serializable;
/**
* Interface describing condition occurrence.
*
@ -16,10 +15,14 @@ public interface Condition extends Serializable {
/**
* Checks the game to see if this condition applies for the given ability.
*
*
* @param game
* @param source
* @return
*/
boolean apply(Game game, Ability source);
default String getManaText() {
return "{" + this.getClass().getSimpleName() + "}";
}
}

View file

@ -3,7 +3,7 @@ package mage.abilities.decorator;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.effects.mana.BasicManaEffect;
import mage.choices.ChoiceColor;
import mage.game.Game;

View file

@ -6,6 +6,7 @@
package mage.abilities.effects.mana;
import mage.Mana;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.mana.builder.ConditionalManaBuilder;
/**
@ -15,7 +16,11 @@ import mage.abilities.mana.builder.ConditionalManaBuilder;
public class AddConditionalColorlessManaEffect extends AddConditionalManaEffect {
public AddConditionalColorlessManaEffect(int amount, ConditionalManaBuilder manaBuilder) {
super(Mana.ColorlessMana(amount), manaBuilder);
this(amount, manaBuilder, null);
}
public AddConditionalColorlessManaEffect(int amount, ConditionalManaBuilder manaBuilder, DynamicValue netAmount) {
super(Mana.ColorlessMana(amount), manaBuilder, netAmount);
}
public AddConditionalColorlessManaEffect(final AddConditionalColorlessManaEffect effect) {

View file

@ -5,10 +5,13 @@
*/
package mage.abilities.effects.mana;
import java.util.ArrayList;
import java.util.List;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.mana.builder.ConditionalManaBuilder;
import mage.constants.ManaType;
import mage.game.Game;
/**
@ -18,18 +21,26 @@ public class AddConditionalManaEffect extends ManaEffect {
private final Mana mana;
private final ConditionalManaBuilder manaBuilder;
private final DynamicValue netAmount;
public AddConditionalManaEffect(Mana mana, ConditionalManaBuilder manaBuilder) {
this(mana, manaBuilder, null);
}
public AddConditionalManaEffect(Mana mana, ConditionalManaBuilder manaBuilder, DynamicValue netAmount) {
super();
this.mana = mana;
this.manaBuilder = manaBuilder;
this.netAmount = netAmount;
staticText = "Add " + this.mana.toString() + ". " + manaBuilder.getRule();
}
public AddConditionalManaEffect(final AddConditionalManaEffect effect) {
super(effect);
this.mana = effect.mana.copy();
this.manaBuilder = effect.manaBuilder;
this.netAmount = effect.netAmount;
}
@Override
@ -37,6 +48,23 @@ public class AddConditionalManaEffect extends ManaEffect {
return new AddConditionalManaEffect(this);
}
@Override
public List<Mana> getNetMana(Game game, Ability source) {
if (game != null && game.inCheckPlayableState() && netAmount != null) {
List<Mana> maxAvailableMana = new ArrayList<>();
int amountAvailableMana = netAmount.calculate(game, source, this);
if (amountAvailableMana > 0) {
Mana calculatedMana = mana.copy();
for(ManaType manaType: ManaType.getTrueManaTypes()) {
calculatedMana.set(manaType, calculatedMana.get(manaType) * amountAvailableMana);
}
maxAvailableMana.add(manaBuilder.setMana(calculatedMana, source, game).build());
}
return maxAvailableMana;
}
return super.getNetMana(game, source); //To change body of generated methods, choose Tools | Templates.
}
@Override
public Mana produceMana(Game game, Ability source) {
if (game != null) {

View file

@ -7,7 +7,6 @@ import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.mana.builder.ConditionalManaBuilder;
import mage.choices.ChoiceColor;
import mage.game.Game;

View file

@ -8,7 +8,6 @@ package mage.abilities.effects.mana;
import mage.ConditionalMana;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.mana.builder.ConditionalManaBuilder;
import mage.choices.ManaChoice;
import mage.game.Game;

View file

@ -2,7 +2,6 @@ package mage.abilities.effects.mana;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.effects.common.ManaEffect;
import mage.choices.ChoiceColor;
import mage.game.Game;
import mage.game.permanent.Permanent;

View file

@ -4,7 +4,6 @@ import mage.Mana;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.common.ManaEffect;
import mage.constants.ColoredManaSymbol;
import mage.game.Game;

View file

@ -10,7 +10,6 @@ import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.mana.ManaOptions;
import mage.constants.ColoredManaSymbol;
import mage.constants.ManaType;

View file

@ -2,7 +2,6 @@ package mage.abilities.effects.mana;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.effects.common.ManaEffect;
import mage.choices.Choice;
import mage.choices.ChoiceColor;
import mage.game.Game;

View file

@ -3,7 +3,6 @@ package mage.abilities.effects.mana;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.effects.common.ManaEffect;
import mage.choices.ManaChoice;
import mage.game.Game;
import mage.players.Player;

View file

@ -7,7 +7,6 @@ package mage.abilities.effects.mana;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.effects.common.ManaEffect;
import mage.game.Game;
import mage.players.Player;

View file

@ -7,7 +7,6 @@ import mage.ConditionalMana;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.common.ManaEffect;
import mage.game.Game;
public class BasicManaEffect extends ManaEffect {
@ -28,10 +27,14 @@ public class BasicManaEffect extends ManaEffect {
}
public BasicManaEffect(ConditionalMana conditionalMana) {
this(conditionalMana, null);
}
public BasicManaEffect(ConditionalMana conditionalMana, DynamicValue netAmount) {
super();
this.manaTemplate = conditionalMana;
staticText = "add " + manaTemplate.toString() + " " + conditionalMana.getDescription();
this.netAmount = null;
this.netAmount = netAmount;
}
public BasicManaEffect(final BasicManaEffect effect) {
@ -46,7 +49,7 @@ public class BasicManaEffect extends ManaEffect {
if (game != null && game.inCheckPlayableState() && netAmount != null) {
// calculate the maximum available mana
int count = netAmount.calculate(game, source, this);
Mana computedMana = new Mana();
Mana computedMana = manaTemplate.copy(); // Copy to get condition
if (count > 0) {
if (manaTemplate.getBlack() > 0) {
computedMana.setBlack(count * manaTemplate.getBlack());

View file

@ -10,7 +10,6 @@ import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.costs.Cost;
import mage.abilities.effects.common.ManaEffect;
import mage.constants.Outcome;
import mage.game.Game;
import mage.players.Player;

View file

@ -4,7 +4,6 @@ import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.common.ManaEffect;
import mage.choices.ChoiceColor;
import mage.constants.Outcome;
import mage.game.Game;

View file

@ -1,4 +1,4 @@
package mage.abilities.effects.common;
package mage.abilities.effects.mana;
import mage.Mana;
import mage.abilities.Ability;

View file

@ -4,7 +4,7 @@ import mage.Mana;
import mage.abilities.ActivatedAbilityImpl;
import mage.abilities.costs.Cost;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.constants.*;
import mage.game.Game;
import mage.game.stack.Spell;

View file

@ -4,7 +4,7 @@ import mage.Mana;
import mage.abilities.Abilities;
import mage.abilities.Ability;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.choices.Choice;
import mage.constants.TargetController;
import mage.constants.Zone;

View file

@ -7,7 +7,7 @@ import mage.abilities.costs.Cost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.effects.mana.AddManaOfAnyColorEffect;
import mage.constants.Zone;
import mage.game.Game;

View file

@ -9,7 +9,7 @@ import mage.Mana;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.choices.Choice;
import mage.choices.ChoiceColor;
import mage.constants.ColoredManaSymbol;

View file

@ -1,7 +1,7 @@
package mage.abilities.mana;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.constants.Zone;
/**

View file

@ -4,7 +4,7 @@ import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.cards.Card;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;

View file

@ -7,6 +7,7 @@ package mage.abilities.mana;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.mana.AddConditionalColorlessManaEffect;
import mage.abilities.mana.builder.ConditionalManaBuilder;
import mage.constants.Zone;
@ -21,7 +22,11 @@ public class ConditionalColorlessManaAbility extends ActivatedManaAbilityImpl {
}
public ConditionalColorlessManaAbility(Cost cost, int amount, ConditionalManaBuilder manaBuilder) {
super(Zone.BATTLEFIELD, new AddConditionalColorlessManaEffect(amount, manaBuilder), cost);
this(cost, amount, manaBuilder, null);
}
public ConditionalColorlessManaAbility(Cost cost, int amount, ConditionalManaBuilder manaBuilder, DynamicValue netAmount) {
super(Zone.BATTLEFIELD, new AddConditionalColorlessManaEffect(amount, manaBuilder, netAmount), cost);
}
public ConditionalColorlessManaAbility(final ConditionalColorlessManaAbility ability) {

View file

@ -5,7 +5,7 @@ package mage.abilities.mana;
import mage.constants.Zone;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.constants.Duration;
/**

View file

@ -10,8 +10,10 @@ import org.apache.log4j.Logger;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import mage.ConditionalMana;
/**
* @author BetaSteward_at_googlemail.com
@ -312,15 +314,27 @@ public class ManaOptions extends ArrayList<Mana> {
/**
* Adds the given mana value to all existing options
*
*
* @param addMana Mana to add to the existing options
*/
public void addMana(Mana addMana) {
if (isEmpty()) {
this.add(new Mana());
}
for (Mana mana : this) {
mana.add(addMana);
if (addMana instanceof ConditionalMana) {
ManaOptions copy = this.copy();
this.clear();
for (Mana mana : copy) {
ConditionalMana condMana = ((ConditionalMana) addMana).copy();
condMana.add(mana);
add(condMana); // Add mana as option with condition
add(mana); // Add old mana without the condition
}
} else {
for (Mana mana : this) {
mana.add(addMana);
}
}
forceManaDeduplication();
@ -514,8 +528,15 @@ public class ManaOptions extends ArrayList<Mana> {
Set<String> list = new HashSet<>();
for (int i = this.size() - 1; i >= 0; i--) {
String s = this.get(i).toString();
if (list.contains(s)) {
String s;
if (this.get(i) instanceof ConditionalMana) {
s = this.get(i).toString() + ((ConditionalMana) this.get(i)).getConditionString();
} else {
s = this.get(i).toString();
}
if (s.isEmpty()) {
this.remove(i);
} else if (list.contains(s)) {
// remove duplicated
this.remove(i);
} else {
@ -550,4 +571,25 @@ public class ManaOptions extends ArrayList<Mana> {
}
return false;
}
public String toString() {
Iterator<Mana> it = this.iterator();
if (!it.hasNext()) {
return "[]";
}
StringBuilder sb = new StringBuilder();
sb.append('[');
for (;;) {
Mana mana = it.next();
sb.append(mana.toString());
if (mana instanceof ConditionalMana) {
sb.append(((ConditionalMana) mana).getConditionString());
}
if (!it.hasNext()) {
return sb.append(']').toString();
}
sb.append(',').append(' ');
}
}
}

View file

@ -5,7 +5,7 @@ import java.util.List;
import mage.Mana;
import mage.abilities.costs.Cost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.abilities.effects.mana.BasicManaEffect;
import mage.constants.Zone;
import mage.game.Game;

View file

@ -3,7 +3,7 @@ package mage.abilities.mana;
import mage.Mana;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.ManaEffect;
import mage.constants.AbilityType;
import mage.constants.Zone;
import mage.game.Game;

View file

@ -5,7 +5,10 @@
*/
package mage.abilities.mana.conditional;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import javax.sql.rowset.Predicate;
import mage.ConditionalMana;
import mage.MageObject;
import mage.Mana;
@ -14,8 +17,14 @@ import mage.abilities.SpellAbility;
import mage.abilities.condition.Condition;
import mage.abilities.costs.Cost;
import mage.abilities.mana.builder.ConditionalManaBuilder;
import mage.cards.Card;
import mage.constants.DependencyType;
import mage.constants.SubType;
import mage.filter.FilterCard;
import mage.filter.FilterSpell;
import mage.filter.predicate.Predicates;
import mage.game.Game;
import mage.game.stack.Spell;
import mage.game.stack.StackObject;
/**
@ -63,6 +72,10 @@ class SpellCastManaCondition extends ManaCondition implements Condition {
public boolean apply(Game game, Ability source) {
if (source instanceof SpellAbility) {
MageObject object = game.getObject(source.getSourceId());
if (game.inCheckPlayableState() && object instanceof Card) {
Spell spell = new Spell((Card) object, (SpellAbility) source, source.getControllerId(), game.getState().getZone(source.getSourceId()));
return spell != null && filter.match(spell, source.getSourceId(), source.getControllerId(), game);
}
if ((object instanceof StackObject)) {
return filter.match((StackObject) object, source.getSourceId(), source.getControllerId(), game);
}

View file

@ -58,35 +58,35 @@ public enum ManaType {
}
return choice;
}
public static List<Mana> getManaListFromManaTypes(Set<ManaType> manaTypes, boolean onlyColors) {
public static List<Mana> getManaListFromManaTypes(Set<ManaType> manaTypes, boolean onlyColors) {
List<Mana> netManas = new ArrayList<>();
if ((manaTypes.size() == 5 && !manaTypes.contains(ManaType.COLORLESS)) || manaTypes.size() == 6) { // GENERIC should never be returned from getManaTypes
netManas.add(Mana.AnyMana(1));
} else {
if (manaTypes.contains(ManaType.BLACK)) {
netManas.add(Mana.BlackMana(1));
}
if (manaTypes.contains(ManaType.RED)) {
netManas.add(Mana.RedMana(1));
}
if (manaTypes.contains(ManaType.BLUE)) {
netManas.add(Mana.BlueMana(1));
}
if (manaTypes.contains(ManaType.GREEN)) {
netManas.add(Mana.GreenMana(1));
}
if (manaTypes.contains(ManaType.WHITE)) {
netManas.add(Mana.WhiteMana(1));
}
if ((manaTypes.size() == 5 && !manaTypes.contains(ManaType.COLORLESS)) || manaTypes.size() == 6) { // GENERIC should never be returned from getManaTypes
netManas.add(Mana.AnyMana(1));
} else {
if (manaTypes.contains(ManaType.BLACK)) {
netManas.add(Mana.BlackMana(1));
}
if (!onlyColors && manaTypes.contains(ManaType.COLORLESS)) {
netManas.add(Mana.ColorlessMana(1));
if (manaTypes.contains(ManaType.RED)) {
netManas.add(Mana.RedMana(1));
}
if (manaTypes.contains(ManaType.BLUE)) {
netManas.add(Mana.BlueMana(1));
}
if (manaTypes.contains(ManaType.GREEN)) {
netManas.add(Mana.GreenMana(1));
}
if (manaTypes.contains(ManaType.WHITE)) {
netManas.add(Mana.WhiteMana(1));
}
}
if (!onlyColors && manaTypes.contains(ManaType.COLORLESS)) {
netManas.add(Mana.ColorlessMana(1));
}
return netManas;
}
public static Set<ManaType> getManaTypesFromManaList(Mana mana) {
Set<ManaType> manaTypes = EnumSet.noneOf(ManaType.class);
if (mana.getAny() > 0) {
@ -124,4 +124,7 @@ public enum ManaType {
}
return manaTypes;
}
public static Set<ManaType> getTrueManaTypes() {
return EnumSet.of(BLACK, BLUE, GREEN, RED, WHITE, COLORLESS);
}
}

View file

@ -3121,6 +3121,9 @@ public abstract class PlayerImpl implements Player, Serializable {
MageObjectReference permittingObject = game.getContinuousEffects().asThough(ability.getSourceId(),
AsThoughEffectType.SPEND_OTHER_MANA, ability, ability.getControllerId(), game);
for (Mana mana : abilityOptions) {
if (mana.count() == 0) {
return true;
}
for (Mana avail : availableMana) {
// TODO: SPEND_OTHER_MANA effects with getAsThoughManaType can change mana type to pay,
// but that code processing it as any color, need to test and fix another use cases
@ -3131,6 +3134,9 @@ public abstract class PlayerImpl implements Player, Serializable {
if (permittingObject != null && mana.count() <= avail.count()) {
return true;
}
if (avail instanceof ConditionalMana && !((ConditionalMana) avail).apply(ability, game, getId(), ability.getManaCosts())) {
continue;
}
if (mana.enough(avail)) { // here we need to check if spend mana as though allow to pay the mana cost
return true;
}
@ -4620,4 +4626,10 @@ public abstract class PlayerImpl implements Player, Serializable {
public SpellAbility chooseAbilityForCast(Card card, Game game, boolean noMana) {
return card.getSpellAbility();
}
@Override
public String toString() {
return getName() + " " + super.toString();
}
}