From 0ad2d040b19923d2155a8713be531dd150946dbb Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Mon, 25 Nov 2013 07:28:56 +0100 Subject: [PATCH] [C13] Added Azorius Herald, Oloro, Ageless Ascetic and Kingming 'Sleeping Dragon'. Sime fixes to commander handling. --- Mage.Common/src/mage/view/CardsView.java | 7 +- .../sets/commander2013/AzoriusHerald.java | 74 ++++++++++++ .../commander2013/KongmingSleepingDragon.java | 69 +++++++++++ .../commander2013/OloroAgelessAscetic.java | 111 ++++++++++++++++++ .../mage/sets/commander2013/ToxicDeluge.java | 1 - .../mage/sets/dissension/AzoriusHerald.java | 52 ++++++++ .../src/mage/sets/eventide/BatwingBrume.java | 5 +- .../mage/sets/eventide/CankerousThirst.java | 5 +- .../mage/sets/eventide/InvertTheSkies.java | 5 +- .../src/mage/sets/eventide/Moonhold.java | 5 +- .../mage/sets/eventide/UnnervingAssault.java | 5 +- .../sets/shadowmoor/DawnglowInfusion.java | 5 +- .../src/mage/sets/shadowmoor/Firespout.java | 5 +- Mage/src/mage/abilities/AbilityImpl.java | 12 +- .../common/ManaWasSpentCondition.java | 16 ++- .../costs/common/PayVariableLifeCost.java | 13 +- .../SacrificeSourceUnlessConditionEffect.java | 82 +++++++++++++ Mage/src/mage/cards/CardImpl.java | 2 +- 18 files changed, 442 insertions(+), 32 deletions(-) create mode 100644 Mage.Sets/src/mage/sets/commander2013/AzoriusHerald.java create mode 100644 Mage.Sets/src/mage/sets/commander2013/KongmingSleepingDragon.java create mode 100644 Mage.Sets/src/mage/sets/commander2013/OloroAgelessAscetic.java create mode 100644 Mage.Sets/src/mage/sets/dissension/AzoriusHerald.java create mode 100644 Mage/src/mage/abilities/effects/common/SacrificeSourceUnlessConditionEffect.java diff --git a/Mage.Common/src/mage/view/CardsView.java b/Mage.Common/src/mage/view/CardsView.java index 73dedc9653..a505a2e90f 100644 --- a/Mage.Common/src/mage/view/CardsView.java +++ b/Mage.Common/src/mage/view/CardsView.java @@ -73,8 +73,11 @@ public class CardsView extends LinkedHashMap { sourceCard = game.getCard(ability.getSourceId()); break; case COMMAND: - ability.newId(); - this.put(ability.getId(), new AbilityView(ability, "Emblem", new CardView("Emblem"))); + sourceCard = game.getCard(ability.getSourceId()); + if (sourceCard == null) { + ability.newId(); + this.put(ability.getId(), new AbilityView(ability, "Emblem", new CardView("Emblem"))); + } break; } if (sourceCard != null) { diff --git a/Mage.Sets/src/mage/sets/commander2013/AzoriusHerald.java b/Mage.Sets/src/mage/sets/commander2013/AzoriusHerald.java new file mode 100644 index 0000000000..2cab9ea0b3 --- /dev/null +++ b/Mage.Sets/src/mage/sets/commander2013/AzoriusHerald.java @@ -0,0 +1,74 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.sets.commander2013; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.condition.common.ManaWasSpentCondition; +import mage.abilities.effects.common.GainLifeEffect; +import mage.abilities.effects.common.SacrificeSourceUnlessConditionEffect; +import mage.abilities.keyword.UnblockableAbility; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.ColoredManaSymbol; +import mage.constants.Rarity; + +/** + * + * @author LevelX2 + */ +public class AzoriusHerald extends CardImpl { + + public AzoriusHerald(UUID ownerId) { + super(ownerId, 6, "Azorius Herald", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{2}{W}"); + this.expansionSetCode = "C13"; + this.subtype.add("Spirit"); + + this.color.setWhite(true); + this.power = new MageInt(2); + this.toughness = new MageInt(1); + + // Azorius Herald can't be blocked. + this.addAbility(new UnblockableAbility()); + // When Azorius Herald enters the battlefield, you gain 4 life. + this.addAbility(new EntersBattlefieldTriggeredAbility(new GainLifeEffect(4))); + // When Azorius Herald enters the battlefield, sacrifice it unless {U} was spent to cast it. + this.addAbility(new EntersBattlefieldTriggeredAbility(new SacrificeSourceUnlessConditionEffect(new ManaWasSpentCondition(ColoredManaSymbol.U)), false)); + + } + + public AzoriusHerald(final AzoriusHerald card) { + super(card); + } + + @Override + public AzoriusHerald copy() { + return new AzoriusHerald(this); + } +} diff --git a/Mage.Sets/src/mage/sets/commander2013/KongmingSleepingDragon.java b/Mage.Sets/src/mage/sets/commander2013/KongmingSleepingDragon.java new file mode 100644 index 0000000000..9a06748ebc --- /dev/null +++ b/Mage.Sets/src/mage/sets/commander2013/KongmingSleepingDragon.java @@ -0,0 +1,69 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.sets.commander2013; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.common.continious.BoostControlledEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.constants.Zone; + +/** + * + * @author LevelX2 + */ +public class KongmingSleepingDragon extends CardImpl { + + public KongmingSleepingDragon(UUID ownerId) { + super(ownerId, 16, "Kongming, 'Sleeping Dragon'", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{2}{W}{W}"); + this.expansionSetCode = "C13"; + this.supertype.add("Legendary"); + this.subtype.add("Human"); + this.subtype.add("Advisor"); + + this.color.setWhite(true); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // Other creatures you control get +1/+1. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostControlledEffect(1,1,Duration.WhileOnBattlefield, true))); + } + + public KongmingSleepingDragon(final KongmingSleepingDragon card) { + super(card); + } + + @Override + public KongmingSleepingDragon copy() { + return new KongmingSleepingDragon(this); + } +} diff --git a/Mage.Sets/src/mage/sets/commander2013/OloroAgelessAscetic.java b/Mage.Sets/src/mage/sets/commander2013/OloroAgelessAscetic.java new file mode 100644 index 0000000000..56bc3f0be1 --- /dev/null +++ b/Mage.Sets/src/mage/sets/commander2013/OloroAgelessAscetic.java @@ -0,0 +1,111 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.sets.commander2013; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfUntapTriggeredAbility; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.common.GainLifeControllerTriggeredAbility; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.dynamicvalue.common.StaticValue; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DamagePlayersEffect; +import mage.abilities.effects.common.DoIfCostPaid; +import mage.abilities.effects.common.DrawCardControllerEffect; +import mage.abilities.effects.common.GainLifeEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.TargetController; +import mage.constants.Zone; +import mage.game.Game; + +/** + * + * @author LevelX2 + */ +public class OloroAgelessAscetic extends CardImpl { + + public OloroAgelessAscetic(UUID ownerId) { + super(ownerId, 203, "Oloro, Ageless Ascetic", Rarity.MYTHIC, new CardType[]{CardType.CREATURE}, "{3}{W}{U}{B}"); + this.expansionSetCode = "C13"; + this.supertype.add("Legendary"); + this.subtype.add("Giant"); + this.subtype.add("Soldier"); + + this.color.setBlue(true); + this.color.setBlack(true); + this.color.setWhite(true); + this.power = new MageInt(4); + this.toughness = new MageInt(5); + + // At the beginning of your upkeep, you gain 2 life. + this.addAbility(new BeginningOfUpkeepTriggeredAbility(new GainLifeEffect(2), TargetController.YOU, false)); + // Whenever you gain life, you may pay {1}. If you do, draw a card and each opponent loses 1 life. + this.addAbility(new GainLifeControllerTriggeredAbility(new DoIfCostPaid(new OloroAgelessAsceticEffect(), new GenericManaCost(1)),false)); + // At the beginning of your upkeep, if Oloro, Ageless Ascetic is in the command zone, you gain 2 life. + this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.COMMAND, + new GainLifeEffect(new StaticValue(2), "if Oloro, Ageless Ascetic is in the command zone, you gain 2 life"),TargetController.YOU, false)); + } + + public OloroAgelessAscetic(final OloroAgelessAscetic card) { + super(card); + } + + @Override + public OloroAgelessAscetic copy() { + return new OloroAgelessAscetic(this); + } +} + +class OloroAgelessAsceticEffect extends OneShotEffect { + + public OloroAgelessAsceticEffect() { + super(Outcome.Benefit); + this.staticText = "draw a card and each opponent loses 1 life"; + } + + public OloroAgelessAsceticEffect(final OloroAgelessAsceticEffect effect) { + super(effect); + } + + @Override + public OloroAgelessAsceticEffect copy() { + return new OloroAgelessAsceticEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + new DrawCardControllerEffect(1).apply(game, source); + new DamagePlayersEffect(1, TargetController.OPPONENT).apply(game, source); + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/commander2013/ToxicDeluge.java b/Mage.Sets/src/mage/sets/commander2013/ToxicDeluge.java index 22b8d2c3ac..d14a85cad1 100644 --- a/Mage.Sets/src/mage/sets/commander2013/ToxicDeluge.java +++ b/Mage.Sets/src/mage/sets/commander2013/ToxicDeluge.java @@ -28,7 +28,6 @@ package mage.sets.commander2013; import java.util.UUID; -import mage.abilities.costs.common.PayLifeCost; import mage.abilities.costs.common.PayVariableLifeCost; import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.common.GetXValue; diff --git a/Mage.Sets/src/mage/sets/dissension/AzoriusHerald.java b/Mage.Sets/src/mage/sets/dissension/AzoriusHerald.java new file mode 100644 index 0000000000..c0ae2d2141 --- /dev/null +++ b/Mage.Sets/src/mage/sets/dissension/AzoriusHerald.java @@ -0,0 +1,52 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.sets.dissension; + +import java.util.UUID; + +/** + * + * @author LevelX2 + */ +public class AzoriusHerald extends mage.sets.commander2013.AzoriusHerald { + + public AzoriusHerald(UUID ownerId) { + super(ownerId); + this.cardNumber = 2; + this.expansionSetCode = "DIS"; + } + + public AzoriusHerald(final AzoriusHerald card) { + super(card); + } + + @Override + public AzoriusHerald copy() { + return new AzoriusHerald(this); + } +} diff --git a/Mage.Sets/src/mage/sets/eventide/BatwingBrume.java b/Mage.Sets/src/mage/sets/eventide/BatwingBrume.java index a2955c69f9..21583966ba 100644 --- a/Mage.Sets/src/mage/sets/eventide/BatwingBrume.java +++ b/Mage.Sets/src/mage/sets/eventide/BatwingBrume.java @@ -36,6 +36,7 @@ import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.PreventAllDamageEffect; import mage.cards.CardImpl; import mage.constants.CardType; +import mage.constants.ColoredManaSymbol; import mage.constants.Duration; import mage.constants.ManaType; import mage.constants.Outcome; @@ -61,10 +62,10 @@ public class BatwingBrume extends CardImpl { // Prevent all combat damage that would be dealt this turn if {W} was spent to cast Batwing Brume. Each player loses 1 life for each attacking creature he or she controls if {B} was spent to cast Batwing Brume. this.getSpellAbility().addEffect(new ConditionalContinousEffect( new PreventAllDamageEffect(Duration.EndOfTurn, true), - new ManaWasSpentCondition(ManaType.WHITE), "Prevent all combat damage that would be dealt this turn if {W} was spent to cast {this}", true)); + new ManaWasSpentCondition(ColoredManaSymbol.W), "Prevent all combat damage that would be dealt this turn if {W} was spent to cast {this}", true)); this.getSpellAbility().addEffect(new ConditionalOneShotEffect( new BatwingBrumeEffect(), - new ManaWasSpentCondition(ManaType.BLACK), "Each player loses 1 life for each attacking creature he or she controls if {B} was spent to cast {this}")); + new ManaWasSpentCondition(ColoredManaSymbol.W), "Each player loses 1 life for each attacking creature he or she controls if {B} was spent to cast {this}")); this.addInfo("Info1", "(Do both if {W}{B} was spent.)"); } diff --git a/Mage.Sets/src/mage/sets/eventide/CankerousThirst.java b/Mage.Sets/src/mage/sets/eventide/CankerousThirst.java index 07ae3d656c..82f39cf0b4 100644 --- a/Mage.Sets/src/mage/sets/eventide/CankerousThirst.java +++ b/Mage.Sets/src/mage/sets/eventide/CankerousThirst.java @@ -33,6 +33,7 @@ import mage.abilities.decorator.ConditionalContinousEffect; import mage.abilities.effects.common.continious.BoostTargetEffect; import mage.cards.CardImpl; import mage.constants.CardType; +import mage.constants.ColoredManaSymbol; import mage.constants.Duration; import mage.constants.ManaType; import mage.constants.Rarity; @@ -55,10 +56,10 @@ public class CankerousThirst extends CardImpl { // If {B} was spent to cast Cankerous Thirst, you may have target creature get -3/-3 until end of turn. If {G} was spent to cast Cankerous Thirst, you may have target creature get +3/+3 until end of turn. this.getSpellAbility().addEffect(new ConditionalContinousEffect( new BoostTargetEffect(-3, -3, Duration.EndOfTurn), - new ManaWasSpentCondition(ManaType.BLACK), "If {B} was spent to cast {this}, you may have target creature get -3/-3 until end of turn", true)); + new ManaWasSpentCondition(ColoredManaSymbol.B), "If {B} was spent to cast {this}, you may have target creature get -3/-3 until end of turn", true)); this.getSpellAbility().addEffect(new ConditionalContinousEffect( new BoostTargetEffect(3, 3, Duration.EndOfTurn), - new ManaWasSpentCondition(ManaType.GREEN), "If {G} was spent to cast {this}, you may have target creature get +3/+3 until end of turn", true)); + new ManaWasSpentCondition(ColoredManaSymbol.G), "If {G} was spent to cast {this}, you may have target creature get +3/+3 until end of turn", true)); this.getSpellAbility().addTarget(new TargetCreaturePermanent()); this.addInfo("Info1", "(Do both if {B}{G} was spent.)"); } diff --git a/Mage.Sets/src/mage/sets/eventide/InvertTheSkies.java b/Mage.Sets/src/mage/sets/eventide/InvertTheSkies.java index 369185ae4b..c3f61ddb06 100644 --- a/Mage.Sets/src/mage/sets/eventide/InvertTheSkies.java +++ b/Mage.Sets/src/mage/sets/eventide/InvertTheSkies.java @@ -37,6 +37,7 @@ import mage.abilities.effects.common.continious.GainAbilityControlledEffect; import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; import mage.constants.CardType; +import mage.constants.ColoredManaSymbol; import mage.constants.Duration; import mage.constants.Layer; import mage.constants.ManaType; @@ -64,10 +65,10 @@ public class InvertTheSkies extends CardImpl { // Creatures your opponents control lose flying until end of turn if {G} was spent to cast Invert the Skies, and creatures you control gain flying until end of turn if {U} was spent to cast it. this.getSpellAbility().addEffect(new ConditionalContinousEffect( new InvertTheSkiesEffect(), - new ManaWasSpentCondition(ManaType.GREEN), "Creatures your opponents control lose flying until end of turn if {G} was spent to cast {this},", true)); + new ManaWasSpentCondition(ColoredManaSymbol.G), "Creatures your opponents control lose flying until end of turn if {G} was spent to cast {this},", true)); this.getSpellAbility().addEffect(new ConditionalContinousEffect( new GainAbilityControlledEffect(FlyingAbility.getInstance(), Duration.EndOfTurn), - new ManaWasSpentCondition(ManaType.BLUE), "and creatures you control gain flying until end of turn if {U} was spent to cast it", true)); + new ManaWasSpentCondition(ColoredManaSymbol.U), "and creatures you control gain flying until end of turn if {U} was spent to cast it", true)); this.addInfo("Info1", "(Do both if {G}{U} was spent.)"); } diff --git a/Mage.Sets/src/mage/sets/eventide/Moonhold.java b/Mage.Sets/src/mage/sets/eventide/Moonhold.java index a899e5a69b..5e6b9e4743 100644 --- a/Mage.Sets/src/mage/sets/eventide/Moonhold.java +++ b/Mage.Sets/src/mage/sets/eventide/Moonhold.java @@ -36,6 +36,7 @@ import mage.abilities.effects.ReplacementEffectImpl; import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.CardType; +import mage.constants.ColoredManaSymbol; import mage.constants.Duration; import mage.constants.ManaType; import mage.constants.Outcome; @@ -64,10 +65,10 @@ public class Moonhold extends CardImpl { effect2.setText("and can't play creature cards this turn if {W} was spent to cast it."); this.getSpellAbility().addEffect(new ConditionalReplacementEffect( effect, - new ManaWasSpentCondition(ManaType.RED), false)); + new ManaWasSpentCondition(ColoredManaSymbol.R), false)); this.getSpellAbility().addEffect(new ConditionalReplacementEffect( effect2, - new ManaWasSpentCondition(ManaType.WHITE), false)); + new ManaWasSpentCondition(ColoredManaSymbol.W), false)); this.getSpellAbility().addTarget(new TargetPlayer(true)); this.addInfo("Info1", "(Do both if {R}{W} was spent.)"); } diff --git a/Mage.Sets/src/mage/sets/eventide/UnnervingAssault.java b/Mage.Sets/src/mage/sets/eventide/UnnervingAssault.java index c5ffd73037..e2b698e4ec 100644 --- a/Mage.Sets/src/mage/sets/eventide/UnnervingAssault.java +++ b/Mage.Sets/src/mage/sets/eventide/UnnervingAssault.java @@ -33,6 +33,7 @@ import mage.abilities.decorator.ConditionalContinousEffect; import mage.abilities.effects.common.continious.BoostAllEffect; import mage.cards.CardImpl; import mage.constants.CardType; +import mage.constants.ColoredManaSymbol; import mage.constants.Duration; import mage.constants.ManaType; import mage.constants.Rarity; @@ -65,10 +66,10 @@ public class UnnervingAssault extends CardImpl { // Creatures your opponents control get -1/-0 until end of turn if {U} was spent to cast Unnerving Assault, and creatures you control get +1/+0 until end of turn if {R} was spent to cast it. this.getSpellAbility().addEffect(new ConditionalContinousEffect( new BoostAllEffect(-1, 0, Duration.EndOfTurn, filter, false), - new ManaWasSpentCondition(ManaType.BLUE), "Creatures your opponents control get -1/0 until end of turn if {U} was spent to cast {this},")); + new ManaWasSpentCondition(ColoredManaSymbol.U), "Creatures your opponents control get -1/0 until end of turn if {U} was spent to cast {this},")); this.getSpellAbility().addEffect(new ConditionalContinousEffect( new BoostAllEffect(1, 0, Duration.EndOfTurn, filter2, false), - new ManaWasSpentCondition(ManaType.RED), " and creatures you control get +1/0 until end of turn if {R} was spent to cast it")); + new ManaWasSpentCondition(ColoredManaSymbol.R), " and creatures you control get +1/0 until end of turn if {R} was spent to cast it")); this.addInfo("Info1", "(Do both if {U}{R} was spent.)"); } diff --git a/Mage.Sets/src/mage/sets/shadowmoor/DawnglowInfusion.java b/Mage.Sets/src/mage/sets/shadowmoor/DawnglowInfusion.java index 21c82dbba7..7751271a25 100644 --- a/Mage.Sets/src/mage/sets/shadowmoor/DawnglowInfusion.java +++ b/Mage.Sets/src/mage/sets/shadowmoor/DawnglowInfusion.java @@ -37,6 +37,7 @@ import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.effects.common.GainLifeEffect; import mage.cards.CardImpl; +import mage.constants.ColoredManaSymbol; import mage.constants.ManaType; /** @@ -56,10 +57,10 @@ public class DawnglowInfusion extends CardImpl { DynamicValue xValue = new ManacostVariableValue(); this.getSpellAbility().addEffect(new ConditionalOneShotEffect( new GainLifeEffect(xValue), - new ManaWasSpentCondition(ManaType.GREEN), "You gain X life if {G} was spent to cast {this}")); + new ManaWasSpentCondition(ColoredManaSymbol.G), "You gain X life if {G} was spent to cast {this}")); this.getSpellAbility().addEffect(new ConditionalOneShotEffect( new GainLifeEffect(xValue), - new ManaWasSpentCondition(ManaType.WHITE), " And X life if {W} was spent to cast it")); + new ManaWasSpentCondition(ColoredManaSymbol.W), " And X life if {W} was spent to cast it")); this.addInfo("Info1", "(Do both if {G}{W} was spent.)"); diff --git a/Mage.Sets/src/mage/sets/shadowmoor/Firespout.java b/Mage.Sets/src/mage/sets/shadowmoor/Firespout.java index 1db39ce182..30e01e6140 100644 --- a/Mage.Sets/src/mage/sets/shadowmoor/Firespout.java +++ b/Mage.Sets/src/mage/sets/shadowmoor/Firespout.java @@ -36,6 +36,7 @@ import mage.abilities.decorator.ConditionalOneShotEffect; import mage.abilities.effects.common.DamageAllEffect; import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; +import mage.constants.ColoredManaSymbol; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.AbilityPredicate; @@ -63,10 +64,10 @@ public class Firespout extends CardImpl { // Firespout deals 3 damage to each creature without flying if {R} was spent to cast Firespout and 3 damage to each creature with flying if {G} was spent to cast it. this.getSpellAbility().addEffect(new ConditionalOneShotEffect( new DamageAllEffect(3, filter1), - new ManaWasSpentCondition(ManaType.RED), "{this} deals 3 damage to each creature without flying if {R} was spent to cast {this}")); + new ManaWasSpentCondition(ColoredManaSymbol.R), "{this} deals 3 damage to each creature without flying if {R} was spent to cast {this}")); this.getSpellAbility().addEffect(new ConditionalOneShotEffect( new DamageAllEffect(3, filter2), - new ManaWasSpentCondition(ManaType.GREEN), " And 3 damage to each creature with flying if {G} was spent to cast it")); + new ManaWasSpentCondition(ColoredManaSymbol.G), " And 3 damage to each creature with flying if {G} was spent to cast it")); this.addInfo("Info1", "(Do both if {R}{G} was spent.)"); diff --git a/Mage/src/mage/abilities/AbilityImpl.java b/Mage/src/mage/abilities/AbilityImpl.java index b82c1b7cac..df7d477acf 100644 --- a/Mage/src/mage/abilities/AbilityImpl.java +++ b/Mage/src/mage/abilities/AbilityImpl.java @@ -52,6 +52,7 @@ import org.apache.log4j.Logger; import java.util.ArrayList; import java.util.List; import java.util.UUID; +import mage.game.command.Emblem; /** @@ -608,10 +609,15 @@ public abstract class AbilityImpl> implements Ability { @Override public boolean isInUseableZone(Game game, MageObject source, boolean checkLKI) { - - // emblem are always actual (also true for a commander? LevelX) if (zone.equals(Zone.COMMAND)) { - return true; + if (this.getSourceId() == null) { // commander effects + return true; + } + MageObject object = game.getObject(this.getSourceId()); + // emblem are always actual + if (object != null && object instanceof Emblem) { + return true; + } } // try LKI first diff --git a/Mage/src/mage/abilities/condition/common/ManaWasSpentCondition.java b/Mage/src/mage/abilities/condition/common/ManaWasSpentCondition.java index dc4868443e..32da2f977a 100644 --- a/Mage/src/mage/abilities/condition/common/ManaWasSpentCondition.java +++ b/Mage/src/mage/abilities/condition/common/ManaWasSpentCondition.java @@ -28,9 +28,9 @@ package mage.abilities.condition.common; -import mage.constants.ManaType; import mage.abilities.Ability; import mage.abilities.condition.Condition; +import mage.constants.ColoredManaSymbol; import mage.game.Game; /** @@ -41,14 +41,20 @@ import mage.game.Game; public class ManaWasSpentCondition implements Condition { - protected ManaType manaType; + protected ColoredManaSymbol coloredManaSymbol; - public ManaWasSpentCondition(ManaType manaType) { - this.manaType = manaType; + public ManaWasSpentCondition(ColoredManaSymbol coloredManaSymbol) { + this.coloredManaSymbol = coloredManaSymbol; } @Override public boolean apply(Game game, Ability source) { - return (source.getManaCostsToPay().getPayment().get(manaType) > 0); + return (source.getManaCostsToPay().getPayment().getColor(coloredManaSymbol) > 0); } + + @Override + public String toString() { + return new StringBuilder("{").append(coloredManaSymbol.toString()).append("} was spent to cast it").toString(); + } + } diff --git a/Mage/src/mage/abilities/costs/common/PayVariableLifeCost.java b/Mage/src/mage/abilities/costs/common/PayVariableLifeCost.java index 0a50406b58..3c52f111d7 100644 --- a/Mage/src/mage/abilities/costs/common/PayVariableLifeCost.java +++ b/Mage/src/mage/abilities/costs/common/PayVariableLifeCost.java @@ -32,10 +32,8 @@ import java.util.UUID; import mage.abilities.Ability; import mage.abilities.costs.CostImpl; import mage.abilities.costs.VariableCost; -import mage.counters.CounterType; import mage.filter.FilterMana; import mage.game.Game; -import mage.game.permanent.Permanent; import mage.players.Player; /** @@ -65,11 +63,14 @@ public class PayVariableLifeCost extends CostImpl implement @Override public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) { Player controller = game.getPlayer(controllerId); - this.amountPaid = controller.getAmount(0, controller.getLife(), "Choose X", game); - if (this.amountPaid> 0) { - controller.loseLife(amountPaid, game); + if (controller != null) { + this.amountPaid = controller.getAmount(0, controller.getLife(), "Choose X (life to pay)", game); + if (this.amountPaid> 0) { + controller.loseLife(amountPaid, game); + } + game.informPlayers(new StringBuilder(controller.getName()).append(" pays ").append(amountPaid).append(" life.").toString()); + this.paid = true; } - this.paid = true; return paid; } diff --git a/Mage/src/mage/abilities/effects/common/SacrificeSourceUnlessConditionEffect.java b/Mage/src/mage/abilities/effects/common/SacrificeSourceUnlessConditionEffect.java new file mode 100644 index 0000000000..4f04c7b797 --- /dev/null +++ b/Mage/src/mage/abilities/effects/common/SacrificeSourceUnlessConditionEffect.java @@ -0,0 +1,82 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.abilities.effects.common; + +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.condition.Condition; +import mage.abilities.effects.OneShotEffect; +import mage.constants.Outcome; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; + +/** + * + * @author LevelX2 + */ +public class SacrificeSourceUnlessConditionEffect extends OneShotEffect { + + protected Condition condition; + + public SacrificeSourceUnlessConditionEffect(Condition condition) { + super(Outcome.Sacrifice); + this.condition = condition; + } + + public SacrificeSourceUnlessConditionEffect(final SacrificeSourceUnlessConditionEffect effect) { + super(effect); + this.condition = effect.condition; + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + Permanent permanent = game.getPermanent(source.getSourceId()); + if (player != null && permanent != null) { + if (condition.apply(game, source)) { + return true; + } + permanent.sacrifice(source.getSourceId(), game); + return true; + } + return false; + } + + @Override + public SacrificeSourceUnlessConditionEffect copy() { + return new SacrificeSourceUnlessConditionEffect(this); + } + + @Override + public String getText(Mode mode) { + StringBuilder sb = new StringBuilder("sacrifice {this} unless "); + sb.append(condition.toString()); + return sb.toString(); + } +} diff --git a/Mage/src/mage/cards/CardImpl.java b/Mage/src/mage/cards/CardImpl.java index a196c7d973..aab82814aa 100644 --- a/Mage/src/mage/cards/CardImpl.java +++ b/Mage/src/mage/cards/CardImpl.java @@ -471,7 +471,7 @@ public abstract class CardImpl> extends MageObjectImpl removed = true; break; case COMMAND: - game.getState().getCommand().remove((Commander)game.getObject(objectId)); + // command object (commander) is only on the stack, so no removing neccessary here removed = true; break; case PICK: