diff --git a/Mage.Sets/src/mage/cards/w/WretchedGryff.java b/Mage.Sets/src/mage/cards/w/WretchedGryff.java index dc14bae6b0..abad76feae 100644 --- a/Mage.Sets/src/mage/cards/w/WretchedGryff.java +++ b/Mage.Sets/src/mage/cards/w/WretchedGryff.java @@ -45,18 +45,18 @@ import mage.constants.CardType; public class WretchedGryff extends CardImpl { public WretchedGryff(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{7}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{7}"); this.subtype.add("Eldrazi"); this.subtype.add("Hippogriff"); this.power = new MageInt(3); this.toughness = new MageInt(4); - // Emerge {5}{U} + // Emerge {5}{U} (You may cast this spell by sacrificing a creature and paying the emerge cost reduced by that creature's converted mana cost.) this.addAbility(new EmergeAbility(this, new ManaCostsImpl<>("{5}{U}"))); // When you cast Wretched Gryff, draw a card. this.addAbility(new CastSourceTriggeredAbility(new DrawCardSourceControllerEffect(1))); - + // Flying this.addAbility(FlyingAbility.getInstance()); } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/EmergeTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/EmergeTest.java new file mode 100644 index 0000000000..548c139844 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/EmergeTest.java @@ -0,0 +1,66 @@ +/* + * 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 org.mage.test.cards.abilities.keywords; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ +public class EmergeTest extends CardTestPlayerBase { + + /** + * Wretched Gryff is bugged. I could not use its Emerge ability. Clicking on + * the card did not give me the interaction menu. + */ + @Test + public void testCastWithEmerge() { + + addCard(Zone.BATTLEFIELD, playerA, "Island", 4); + // Emerge {5}{U} (You may cast this spell by sacrificing a creature and paying the emerge cost reduced by that creature's converted mana cost.) + // When you cast Wretched Gryff, draw a card. + // Flying + addCard(Zone.HAND, playerA, "Wretched Gryff"); // Creature + + addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 1); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Wretched Gryff with emerge"); + setChoice(playerA, "Silvercoat Lion"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertGraveyardCount(playerA, "Silvercoat Lion", 1); + assertPermanentCount(playerA, "Wretched Gryff", 1); + } + +} diff --git a/Mage/src/main/java/mage/abilities/ActivatedAbility.java b/Mage/src/main/java/mage/abilities/ActivatedAbility.java index b8908a8587..be4df4d366 100644 --- a/Mage/src/main/java/mage/abilities/ActivatedAbility.java +++ b/Mage/src/main/java/mage/abilities/ActivatedAbility.java @@ -24,11 +24,11 @@ * 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; import java.util.UUID; +import mage.abilities.mana.ManaOptions; import mage.game.Game; /** @@ -38,20 +38,30 @@ import mage.game.Game; public interface ActivatedAbility extends Ability { boolean canActivate(UUID playerId, Game game); - + + /** + * Returns the minimal possible cost for what the ability can be activated + * or cast + * + * @param playerId + * @param game + * @return + */ + ManaOptions getMinimumCostToActivate(UUID playerId, Game game); + /** * Creates a fresh copy of this activated ability. - * + * * @return A new copy of this ability. */ @Override - ActivatedAbility copy(); - + ActivatedAbility copy(); + /** - * Set a flag to know, that the ability is only created adn used to check + * Set a flag to know, that the ability is only created adn used to check * what's playbable for the player. */ void setCheckPlayableMode(); - + boolean isCheckPlayableMode(); } diff --git a/Mage/src/main/java/mage/abilities/ActivatedAbilityImpl.java b/Mage/src/main/java/mage/abilities/ActivatedAbilityImpl.java index 13724366e7..b6c341dcaa 100644 --- a/Mage/src/main/java/mage/abilities/ActivatedAbilityImpl.java +++ b/Mage/src/main/java/mage/abilities/ActivatedAbilityImpl.java @@ -34,6 +34,7 @@ import mage.abilities.costs.mana.ManaCosts; import mage.abilities.costs.mana.PhyrexianManaCost; import mage.abilities.effects.Effect; import mage.abilities.effects.Effects; +import mage.abilities.mana.ManaOptions; import mage.cards.Card; import mage.constants.AbilityType; import mage.constants.AsThoughEffectType; @@ -199,6 +200,11 @@ public abstract class ActivatedAbilityImpl extends AbilityImpl implements Activa return false; } + @Override + public ManaOptions getMinimumCostToActivate(UUID playerId, Game game) { + return getManaCostsToPay().getOptions(); + } + protected boolean controlsAbility(UUID playerId, Game game) { if (this.controllerId != null && this.controllerId.equals(playerId)) { return true; diff --git a/Mage/src/main/java/mage/abilities/keyword/EmergeAbility.java b/Mage/src/main/java/mage/abilities/keyword/EmergeAbility.java index 15fd4dcfa7..ce1c24afdd 100644 --- a/Mage/src/main/java/mage/abilities/keyword/EmergeAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/EmergeAbility.java @@ -28,10 +28,12 @@ package mage.abilities.keyword; import java.util.UUID; +import mage.Mana; import mage.abilities.SpellAbility; import mage.abilities.costs.common.SacrificeTargetCost; import mage.abilities.costs.mana.ManaCost; import mage.abilities.costs.mana.ManaCosts; +import mage.abilities.mana.ManaOptions; import mage.cards.Card; import mage.constants.Outcome; import mage.constants.SpellAbilityType; @@ -84,6 +86,26 @@ public class EmergeAbility extends SpellAbility { return false; } + @Override + public ManaOptions getMinimumCostToActivate(UUID playerId, Game game) { + int maxCMC = 0; + for (Permanent creature : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), playerId, this.getSourceId(), game)) { + int cmc = creature.getConvertedManaCost(); + if (cmc > maxCMC) { + maxCMC = cmc; + } + } + ManaOptions manaOptions = super.getMinimumCostToActivate(playerId, game); + for (Mana mana : manaOptions) { + if (mana.getGeneric() > maxCMC) { + mana.setGeneric(mana.getGeneric() - maxCMC); + } else { + mana.setGeneric(0); + } + } + return manaOptions; + } + @Override public boolean activate(Game game, boolean noMana) { Player controller = game.getPlayer(this.getControllerId()); diff --git a/Mage/src/main/java/mage/players/PlayerImpl.java b/Mage/src/main/java/mage/players/PlayerImpl.java index ca78a0ae01..6db3584090 100644 --- a/Mage/src/main/java/mage/players/PlayerImpl.java +++ b/Mage/src/main/java/mage/players/PlayerImpl.java @@ -2489,7 +2489,7 @@ public abstract class PlayerImpl implements Player, Serializable { canBeCastRegularly = false; } if (canBeCastRegularly) { - ManaOptions abilityOptions = copy.getManaCostsToPay().getOptions(); + ManaOptions abilityOptions = copy.getMinimumCostToActivate(playerId, game); if (abilityOptions.isEmpty()) { return true; } else {