diff --git a/Mage.Sets/src/mage/sets/avacynrestored/StolenGoods.java b/Mage.Sets/src/mage/sets/avacynrestored/StolenGoods.java index f6550ca84e..591adb8e6a 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/StolenGoods.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/StolenGoods.java @@ -141,7 +141,7 @@ class StolenGoodsCastFromExileEffect extends AsThoughEffectImpl { Card card = game.getCard(sourceId); if (card != null && game.getState().getZone(sourceId) == Zone.EXILED) { Player player = game.getPlayer(affectedControllerId); - player.setCastSourceIdWithAlternateMana(sourceId, null); + player.setCastSourceIdWithAlternateMana(sourceId, null, null); return true; } } diff --git a/Mage.Sets/src/mage/sets/commander2015/ScourgeOfNelToth.java b/Mage.Sets/src/mage/sets/commander2015/ScourgeOfNelToth.java new file mode 100644 index 0000000000..38eaaf4a7e --- /dev/null +++ b/Mage.Sets/src/mage/sets/commander2015/ScourgeOfNelToth.java @@ -0,0 +1,120 @@ +/* + * 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.commander2015; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.Cost; +import mage.abilities.costs.Costs; +import mage.abilities.costs.CostsImpl; +import mage.abilities.costs.common.SacrificeTargetCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.AsThoughEffectImpl; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.CardImpl; +import mage.constants.AsThoughEffectType; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.game.Game; +import mage.players.Player; +import mage.target.common.TargetControlledCreaturePermanent; + +/** + * + * @author LevelX2 + */ +public class ScourgeOfNelToth extends CardImpl { + + public ScourgeOfNelToth(UUID ownerId) { + super(ownerId, 21, "Scourge of Nel Toth", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{5}{B}{B}"); + this.expansionSetCode = "C15"; + this.subtype.add("Zombie"); + this.subtype.add("Dragon"); + this.power = new MageInt(6); + this.toughness = new MageInt(6); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + // You may cast Scourge of Nel Toth from your graveyard by paying {B}{B} and sacrificing two creatures rather than paying its mana cost. + this.addAbility(new SimpleStaticAbility(Zone.ALL, new ScourgeOfNelTothPlayEffect())); + } + + public ScourgeOfNelToth(final ScourgeOfNelToth card) { + super(card); + } + + @Override + public ScourgeOfNelToth copy() { + return new ScourgeOfNelToth(this); + } +} + +class ScourgeOfNelTothPlayEffect extends AsThoughEffectImpl { + + public ScourgeOfNelTothPlayEffect() { + super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.EndOfGame, Outcome.Benefit); + staticText = "You may cast {this} from your graveyard by paying {B}{B} and sacrificing two creatures rather than paying its mana cost"; + } + + public ScourgeOfNelTothPlayEffect(final ScourgeOfNelTothPlayEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public ScourgeOfNelTothPlayEffect copy() { + return new ScourgeOfNelTothPlayEffect(this); + } + + @Override + public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) { + if (sourceId.equals(source.getSourceId()) && source.getControllerId().equals(affectedControllerId)) { + if (game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD) { + Player player = game.getPlayer(affectedControllerId); + if (player != null) { + // can sometimes be cast with base mana cost from grave???? + Costs costs = new CostsImpl<>(); + costs.add(new SacrificeTargetCost(new TargetControlledCreaturePermanent(2))); + player.setCastSourceIdWithAlternateMana(sourceId, new ManaCostsImpl<>("{B}{B}"), costs); + return true; + } + } + } + return false; + } + +} diff --git a/Mage.Sets/src/mage/sets/judgment/Spelljack.java b/Mage.Sets/src/mage/sets/judgment/Spelljack.java index 13152d6939..f6961e9683 100644 --- a/Mage.Sets/src/mage/sets/judgment/Spelljack.java +++ b/Mage.Sets/src/mage/sets/judgment/Spelljack.java @@ -141,7 +141,7 @@ class SpelljackCastFromExileEffect extends AsThoughEffectImpl { if (card != null) { if (game.getState().getZone(sourceId) == Zone.EXILED) { Player player = game.getPlayer(affectedControllerId); - player.setCastSourceIdWithAlternateMana(sourceId, null); + player.setCastSourceIdWithAlternateMana(sourceId, null, null); return true; } else { this.discard(); diff --git a/Mage.Sets/src/mage/sets/khansoftarkir/KheruSpellsnatcher.java b/Mage.Sets/src/mage/sets/khansoftarkir/KheruSpellsnatcher.java index df16a3a0fb..2ce29a65aa 100644 --- a/Mage.Sets/src/mage/sets/khansoftarkir/KheruSpellsnatcher.java +++ b/Mage.Sets/src/mage/sets/khansoftarkir/KheruSpellsnatcher.java @@ -158,7 +158,7 @@ class KheruSpellsnatcherCastFromExileEffect extends AsThoughEffectImpl { if (card != null) { if (game.getState().getZone(sourceId) == Zone.EXILED) { Player player = game.getPlayer(affectedControllerId); - player.setCastSourceIdWithAlternateMana(sourceId, null); + player.setCastSourceIdWithAlternateMana(sourceId, null, null); return true; } else { this.discard(); diff --git a/Mage.Sets/src/mage/sets/khansoftarkir/NarsetEnlightenedMaster.java b/Mage.Sets/src/mage/sets/khansoftarkir/NarsetEnlightenedMaster.java index a5093dcec4..f97744e57b 100644 --- a/Mage.Sets/src/mage/sets/khansoftarkir/NarsetEnlightenedMaster.java +++ b/Mage.Sets/src/mage/sets/khansoftarkir/NarsetEnlightenedMaster.java @@ -151,7 +151,7 @@ class NarsetEnlightenedMasterCastFromExileEffect extends AsThoughEffectImpl { if (card != null) { Player player = game.getPlayer(affectedControllerId); if (player != null) { - player.setCastSourceIdWithAlternateMana(objectId, null); + player.setCastSourceIdWithAlternateMana(objectId, null, null); return true; } } diff --git a/Mage.Sets/src/mage/sets/modernmasters2015/WorldheartPhoenix.java b/Mage.Sets/src/mage/sets/modernmasters2015/WorldheartPhoenix.java index d790518da1..06051fdcd9 100644 --- a/Mage.Sets/src/mage/sets/modernmasters2015/WorldheartPhoenix.java +++ b/Mage.Sets/src/mage/sets/modernmasters2015/WorldheartPhoenix.java @@ -111,7 +111,7 @@ public class WorldheartPhoenix extends CardImpl { Player player = game.getPlayer(affectedControllerId); if (player != null) { // can sometimes be cast with base mana cost from grave???? - player.setCastSourceIdWithAlternateMana(sourceId, new ManaCostsImpl<>("{W}{U}{B}{R}{G}")); + player.setCastSourceIdWithAlternateMana(sourceId, new ManaCostsImpl<>("{W}{U}{B}{R}{G}"), null); return true; } } diff --git a/Mage.Sets/src/mage/sets/planarchaos/IntetTheDreamer.java b/Mage.Sets/src/mage/sets/planarchaos/IntetTheDreamer.java index d3107a9bfb..4e45cd7b79 100644 --- a/Mage.Sets/src/mage/sets/planarchaos/IntetTheDreamer.java +++ b/Mage.Sets/src/mage/sets/planarchaos/IntetTheDreamer.java @@ -166,7 +166,7 @@ class IntetTheDreamerCastEffect extends AsThoughEffectImpl { return controller.chooseUse(outcome, "Play " + card.getName() + "?", source, game); } } else { - controller.setCastSourceIdWithAlternateMana(objectId, null); + controller.setCastSourceIdWithAlternateMana(objectId, null, null); return true; } } diff --git a/Mage.Sets/src/mage/sets/ravnica/SinsOfThePast.java b/Mage.Sets/src/mage/sets/ravnica/SinsOfThePast.java index a199e0cfe0..ba8dd13ec2 100644 --- a/Mage.Sets/src/mage/sets/ravnica/SinsOfThePast.java +++ b/Mage.Sets/src/mage/sets/ravnica/SinsOfThePast.java @@ -131,7 +131,7 @@ class SinsOfThePastCastFromGraveyardEffect extends AsThoughEffectImpl { public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) { if (sourceId.equals(this.getTargetPointer().getFirst(game, source)) && affectedControllerId.equals(source.getControllerId())) { Player player = game.getPlayer(affectedControllerId); - player.setCastSourceIdWithAlternateMana(sourceId, null); + player.setCastSourceIdWithAlternateMana(sourceId, null, null); return true; } return false; diff --git a/Mage.Sets/src/mage/sets/vintagemasters/MindsDesire.java b/Mage.Sets/src/mage/sets/vintagemasters/MindsDesire.java index 0533cb5b64..184e2b898b 100644 --- a/Mage.Sets/src/mage/sets/vintagemasters/MindsDesire.java +++ b/Mage.Sets/src/mage/sets/vintagemasters/MindsDesire.java @@ -140,7 +140,7 @@ class MindsDesireCastFromExileEffect extends AsThoughEffectImpl { Card card = game.getCard(sourceId); if (card != null && game.getState().getZone(sourceId) == Zone.EXILED) { Player player = game.getPlayer(affectedControllerId); - player.setCastSourceIdWithAlternateMana(sourceId, null); + player.setCastSourceIdWithAlternateMana(sourceId, null, null); return true; } } diff --git a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java index 80199a68a9..1f59b9387a 100644 --- a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java +++ b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java @@ -43,6 +43,8 @@ import mage.abilities.Modes; import mage.abilities.SpellAbility; import mage.abilities.TriggeredAbility; import mage.abilities.costs.AlternativeSourceCosts; +import mage.abilities.costs.Cost; +import mage.abilities.costs.Costs; import mage.abilities.costs.VariableCost; import mage.abilities.costs.mana.ManaCost; import mage.abilities.costs.mana.ManaCosts; @@ -1122,8 +1124,8 @@ public class TestPlayer implements Player { } @Override - public void setCastSourceIdWithAlternateMana(UUID sourceId, ManaCosts manaCosts) { - computerPlayer.setCastSourceIdWithAlternateMana(sourceId, manaCosts); + public void setCastSourceIdWithAlternateMana(UUID sourceId, ManaCosts manaCosts, Costs costs) { + computerPlayer.setCastSourceIdWithAlternateMana(sourceId, manaCosts, costs); } @Override @@ -1136,6 +1138,11 @@ public class TestPlayer implements Player { return computerPlayer.getCastSourceIdManaCosts(); } + @Override + public Costs getCastSourceIdCosts() { + return computerPlayer.getCastSourceIdCosts(); + } + @Override public boolean isInPayManaMode() { return computerPlayer.isInPayManaMode(); diff --git a/Mage/src/mage/players/Player.java b/Mage/src/mage/players/Player.java index 3dae03761b..dce42de2d6 100644 --- a/Mage/src/mage/players/Player.java +++ b/Mage/src/mage/players/Player.java @@ -44,6 +44,8 @@ import mage.abilities.Modes; import mage.abilities.SpellAbility; import mage.abilities.TriggeredAbility; import mage.abilities.costs.AlternativeSourceCosts; +import mage.abilities.costs.Cost; +import mage.abilities.costs.Costs; import mage.abilities.costs.VariableCost; import mage.abilities.costs.mana.ManaCost; import mage.abilities.costs.mana.ManaCosts; @@ -756,19 +758,23 @@ public interface Player extends MageItem, Copyable { void cleanUpOnMatchEnd(); /** - * If the next cast spell has the set sourceId, the spell will be cast - * without mana. + * If the next spell cast has the set sourceId, the spell will be cast + * without mana (null) or the mana set to manaCosts instead of its normal + * mana costs. * * @param sourceId the source that can be cast without mana * @param manaCosts alternate ManaCost, null if it can be cast without mana * cost + * @param costs alternate other costs you need to pay */ - void setCastSourceIdWithAlternateMana(UUID sourceId, ManaCosts manaCosts); + void setCastSourceIdWithAlternateMana(UUID sourceId, ManaCosts manaCosts, mage.abilities.costs.Costs costs); UUID getCastSourceIdWithAlternateMana(); ManaCosts getCastSourceIdManaCosts(); + Costs getCastSourceIdCosts(); + // permission handling to show hand cards void addPermissionToShowHandCards(UUID watcherUserId); diff --git a/Mage/src/mage/players/PlayerImpl.java b/Mage/src/mage/players/PlayerImpl.java index 7f2e1424af..f21805dffc 100644 --- a/Mage/src/mage/players/PlayerImpl.java +++ b/Mage/src/mage/players/PlayerImpl.java @@ -61,6 +61,7 @@ import mage.abilities.costs.AlternativeCost; import mage.abilities.costs.AlternativeCostSourceAbility; import mage.abilities.costs.AlternativeSourceCosts; import mage.abilities.costs.Cost; +import mage.abilities.costs.Costs; import mage.abilities.costs.OptionalAdditionalSourceCosts; import mage.abilities.costs.mana.ManaCost; import mage.abilities.costs.mana.ManaCosts; @@ -222,7 +223,8 @@ public abstract class PlayerImpl implements Player, Serializable { // indicates that the spell with the set sourceId can be cast with an alternate mana costs (can also be no mana costs) protected UUID castSourceIdWithAlternateMana; - protected ManaCosts castSourceIdManaCosts; + protected ManaCosts castSourceIdManaCosts; + protected Costs castSourceIdCosts; // indicates that the player is in mana payment phase protected boolean payManaMode = false; @@ -326,6 +328,7 @@ public abstract class PlayerImpl implements Player, Serializable { this.castSourceIdWithAlternateMana = player.castSourceIdWithAlternateMana; this.castSourceIdManaCosts = player.castSourceIdManaCosts; + this.castSourceIdCosts = player.castSourceIdCosts; this.payManaMode = player.payManaMode; } @@ -388,6 +391,7 @@ public abstract class PlayerImpl implements Player, Serializable { this.reachedNextTurnAfterLeaving = player.hasReachedNextTurnAfterLeaving(); this.castSourceIdWithAlternateMana = player.getCastSourceIdWithAlternateMana(); this.castSourceIdManaCosts = player.getCastSourceIdManaCosts(); + this.castSourceIdCosts = player.getCastSourceIdCosts(); // Don't restore! // this.storedBookmark @@ -453,6 +457,7 @@ public abstract class PlayerImpl implements Player, Serializable { this.castSourceIdWithAlternateMana = null; this.castSourceIdManaCosts = null; + this.castSourceIdCosts = null; } /** @@ -476,6 +481,7 @@ public abstract class PlayerImpl implements Player, Serializable { this.alternativeSourceCosts.clear(); this.castSourceIdWithAlternateMana = null; this.castSourceIdManaCosts = null; + this.castSourceIdCosts = null; this.getManaPool().clearEmptyManaPoolRules(); } @@ -684,6 +690,12 @@ public abstract class PlayerImpl implements Player, Serializable { return true; } + /** + * + * @param amount + * @param source + * @param game + */ @Override public void discard(int amount, Ability source, Game game) { discard(amount, false, source, game); @@ -917,9 +929,10 @@ public abstract class PlayerImpl implements Player, Serializable { } @Override - public void setCastSourceIdWithAlternateMana(UUID sourceId, ManaCosts manaCosts) { + public void setCastSourceIdWithAlternateMana(UUID sourceId, ManaCosts manaCosts, mage.abilities.costs.Costs costs) { castSourceIdWithAlternateMana = sourceId; castSourceIdManaCosts = manaCosts; + castSourceIdCosts = costs; } @Override @@ -927,6 +940,11 @@ public abstract class PlayerImpl implements Player, Serializable { return castSourceIdWithAlternateMana; } + @Override + public Costs getCastSourceIdCosts() { + return castSourceIdCosts; + } + @Override public ManaCosts getCastSourceIdManaCosts() { return castSourceIdManaCosts; @@ -950,20 +968,25 @@ public abstract class PlayerImpl implements Player, Serializable { Zone fromZone = game.getState().getZone(card.getMainCard().getId()); card.cast(game, fromZone, ability, playerId); Spell spell = game.getStack().getSpell(ability.getId()); - // some effects set sourceId to cast without paying mana costs + // some effects set sourceId to cast without paying mana costs or other costs if (ability.getSourceId().equals(getCastSourceIdWithAlternateMana())) { - ManaCosts alternateCosts = getCastSourceIdManaCosts(); Ability spellAbility = spell.getSpellAbility(); + ManaCosts alternateCosts = getCastSourceIdManaCosts(); + Costs costs = getCastSourceIdCosts(); if (alternateCosts == null) { noMana = true; } else { spellAbility.getManaCosts().clear(); - spellAbility.getManaCosts().add(alternateCosts.copy()); spellAbility.getManaCostsToPay().clear(); + spellAbility.getManaCosts().add(alternateCosts.copy()); spellAbility.getManaCostsToPay().add(alternateCosts.copy()); } + spellAbility.getCosts().clear(); + if (costs != null) { + spellAbility.getCosts().addAll(costs); + } } - setCastSourceIdWithAlternateMana(null, null); + setCastSourceIdWithAlternateMana(null, null, null); GameEvent event = GameEvent.getEvent(GameEvent.EventType.CAST_SPELL, spell.getSpellAbility().getId(), spell.getSpellAbility().getSourceId(), playerId); game.fireEvent(event); if (spell.activate(game, noMana)) { @@ -984,12 +1007,14 @@ public abstract class PlayerImpl implements Player, Serializable { } @Override - public SpellAbility chooseSpellAbilityForCast(SpellAbility ability, Game game, boolean noMana) { + public SpellAbility chooseSpellAbilityForCast(SpellAbility ability, Game game, boolean noMana + ) { return ability; } @Override - public boolean playLand(Card card, Game game) { + public boolean playLand(Card card, Game game + ) { // Check for alternate casting possibilities: e.g. land with Morph ActivatedAbility playLandAbility = null; boolean found = false;