diff --git a/Mage.Sets/src/mage/cards/a/AnimarSoulOfElements.java b/Mage.Sets/src/mage/cards/a/AnimarSoulOfElements.java index 1ac2052194d..9a655149599 100644 --- a/Mage.Sets/src/mage/cards/a/AnimarSoulOfElements.java +++ b/Mage.Sets/src/mage/cards/a/AnimarSoulOfElements.java @@ -1,5 +1,6 @@ package mage.cards.a; +import java.util.UUID; import mage.MageInt; import mage.ObjectColor; import mage.abilities.Ability; @@ -19,8 +20,6 @@ import mage.game.Game; import mage.game.permanent.Permanent; import mage.util.CardUtil; -import java.util.UUID; - /** * @author LevelX2 */ @@ -82,9 +81,12 @@ class AnimarCostReductionEffect extends CostModificationEffectImpl { public boolean applies(Ability abilityToModify, Ability source, Game game) { if (abilityToModify instanceof SpellAbility) { if (abilityToModify.isControlledBy(source.getControllerId())) { - Card card = ((SpellAbility) abilityToModify).getCharacteristics(game); - if (card != null) { - return card.isCreature(); + Card spellCard = ((SpellAbility) abilityToModify).getCharacteristics(game); + if (spellCard != null) { + if (((SpellAbility) abilityToModify).getSpellAbilityCastMode() != SpellAbilityCastMode.NORMAL) { + spellCard = ((SpellAbility) abilityToModify).getSpellAbilityCastMode().getTypeModifiedCardObjectCopy(spellCard, game); + } + return spellCard.isCreature(); } } } diff --git a/Mage.Sets/src/mage/cards/d/Drought.java b/Mage.Sets/src/mage/cards/d/Drought.java index 201ab8d18d4..090b0501913 100644 --- a/Mage.Sets/src/mage/cards/d/Drought.java +++ b/Mage.Sets/src/mage/cards/d/Drought.java @@ -1,4 +1,3 @@ - package mage.cards.d; import java.util.UUID; @@ -11,12 +10,12 @@ import mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect; import mage.abilities.effects.common.cost.CostModificationEffectImpl; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.SubType; import mage.constants.AbilityType; +import mage.constants.CardType; import mage.constants.CostModificationType; import mage.constants.Duration; import mage.constants.Outcome; +import mage.constants.SubType; import mage.constants.TargetController; import mage.constants.Zone; import mage.filter.common.FilterControlledPermanent; @@ -54,9 +53,10 @@ public final class Drought extends CardImpl { class DroughtAdditionalCostEffect extends CostModificationEffectImpl { - private boolean appliesToSpells; + private final boolean appliesToSpells; private static final FilterControlledPermanent filter = new FilterControlledPermanent("a Swamp"); - static{ + + static { filter.add(SubType.SWAMP.getPredicate()); } diff --git a/Mage.Sets/src/mage/cards/e/ElspethConquersDeath.java b/Mage.Sets/src/mage/cards/e/ElspethConquersDeath.java index 0dbe61b9b80..117721c4f48 100644 --- a/Mage.Sets/src/mage/cards/e/ElspethConquersDeath.java +++ b/Mage.Sets/src/mage/cards/e/ElspethConquersDeath.java @@ -1,5 +1,6 @@ package mage.cards.e; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.SpellAbility; import mage.abilities.common.SagaAbility; @@ -23,8 +24,6 @@ import mage.target.TargetPermanent; import mage.target.common.TargetCardInYourGraveyard; import mage.util.CardUtil; -import java.util.UUID; - /** * @author TheElk801 */ @@ -99,12 +98,17 @@ class ElspethConquersDeathCostEffect extends CostModificationEffectImpl { @Override public boolean applies(Ability abilityToModify, Ability source, Game game) { - if (!(abilityToModify instanceof SpellAbility) || - !game.getOpponents(source.getControllerId()).contains(abilityToModify.getControllerId())) { - return false; + if ((abilityToModify instanceof SpellAbility) + && game.getOpponents(source.getControllerId()).contains(abilityToModify.getControllerId())) { + Card spellCard = ((SpellAbility) abilityToModify).getCharacteristics(game); + if (spellCard != null) { + if (((SpellAbility) abilityToModify).getSpellAbilityCastMode() != SpellAbilityCastMode.NORMAL) { + spellCard = ((SpellAbility) abilityToModify).getSpellAbilityCastMode().getTypeModifiedCardObjectCopy(spellCard, game); + } + return !spellCard.isCreature(); + } } - Card card = game.getCard(abilityToModify.getSourceId()); - return card != null && !card.isCreature(); + return false; } @Override @@ -117,8 +121,8 @@ class ElspethConquersDeathReturnEffect extends OneShotEffect { ElspethConquersDeathReturnEffect() { super(Outcome.Benefit); - staticText = "Return target creature or planeswalker card from your graveyard to the battlefield. " + - "Put a +1/+1 counter or a loyalty counter on it"; + staticText = "Return target creature or planeswalker card from your graveyard to the battlefield. " + + "Put a +1/+1 counter or a loyalty counter on it"; } private ElspethConquersDeathReturnEffect(final ElspethConquersDeathReturnEffect effect) { @@ -149,4 +153,5 @@ class ElspethConquersDeathReturnEffect extends OneShotEffect { permanent.addCounters(counter, source, game); return true; } -} \ No newline at end of file + +} diff --git a/Mage.Sets/src/mage/cards/h/HeraldOfWar.java b/Mage.Sets/src/mage/cards/h/HeraldOfWar.java index 4ab890792c6..27bbed4c1e5 100644 --- a/Mage.Sets/src/mage/cards/h/HeraldOfWar.java +++ b/Mage.Sets/src/mage/cards/h/HeraldOfWar.java @@ -1,4 +1,3 @@ - package mage.cards.h; import java.util.UUID; @@ -25,7 +24,7 @@ import mage.util.CardUtil; public final class HeraldOfWar extends CardImpl { public HeraldOfWar(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{W}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{W}{W}"); this.subtype.add(SubType.ANGEL); this.power = new MageInt(3); @@ -54,7 +53,7 @@ class HeraldOfWarCostReductionEffect extends CostModificationEffectImpl { HeraldOfWarCostReductionEffect() { super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.REDUCE_COST); - staticText = "Angel spells and Human spells you cast cost {1} less to cast for each +1/+1 counter on Herald of War"; + staticText = "Angel spells and Human spells you cast cost {1} less to cast for each +1/+1 counter on {this}"; } HeraldOfWarCostReductionEffect(HeraldOfWarCostReductionEffect effect) { diff --git a/Mage.Sets/src/mage/cards/h/HumOfTheRadix.java b/Mage.Sets/src/mage/cards/h/HumOfTheRadix.java index 7e806c12c61..8cf5a54708c 100644 --- a/Mage.Sets/src/mage/cards/h/HumOfTheRadix.java +++ b/Mage.Sets/src/mage/cards/h/HumOfTheRadix.java @@ -1,6 +1,5 @@ package mage.cards.h; -import mage.MageObject; import mage.abilities.Ability; import mage.abilities.SpellAbility; import mage.abilities.common.SimpleStaticAbility; @@ -13,6 +12,7 @@ import mage.game.Game; import mage.util.CardUtil; import java.util.UUID; +import mage.cards.Card; /** * @author Pete Rossi @@ -58,9 +58,12 @@ class HumOfTheRadixCostIncreaseEffect extends CostModificationEffectImpl { @Override public boolean applies(Ability abilityToModify, Ability source, Game game) { if (abilityToModify instanceof SpellAbility) { - MageObject sourceObject = abilityToModify.getSourceObject(game); - if (sourceObject != null && sourceObject.isArtifact()) { - return true; + Card spellCard = ((SpellAbility) abilityToModify).getCharacteristics(game); + if (spellCard != null) { + if (((SpellAbility) abilityToModify).getSpellAbilityCastMode() != SpellAbilityCastMode.NORMAL) { + spellCard = ((SpellAbility) abilityToModify).getSpellAbilityCastMode().getTypeModifiedCardObjectCopy(spellCard, game); + } + return !spellCard.isArtifact(); } } return false; diff --git a/Mage.Sets/src/mage/cards/r/RakdosLordOfRiots.java b/Mage.Sets/src/mage/cards/r/RakdosLordOfRiots.java index 00a84e1aeeb..0fdb43f8e3b 100644 --- a/Mage.Sets/src/mage/cards/r/RakdosLordOfRiots.java +++ b/Mage.Sets/src/mage/cards/r/RakdosLordOfRiots.java @@ -15,10 +15,10 @@ import mage.constants.*; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; -import mage.game.stack.Spell; import mage.util.CardUtil; import java.util.UUID; +import mage.cards.Card; /** * @author LevelX2 @@ -115,9 +115,12 @@ class RakdosLordOfRiotsCostReductionEffect extends CostModificationEffectImpl { public boolean applies(Ability abilityToModify, Ability source, Game game) { if (abilityToModify instanceof SpellAbility) { if (abilityToModify.isControlledBy(source.getControllerId())) { - Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId()); - if (spell != null) { - return spell.isCreature(); + Card spellCard = ((SpellAbility) abilityToModify).getCharacteristics(game); + if (spellCard != null) { + if (((SpellAbility) abilityToModify).getSpellAbilityCastMode() != SpellAbilityCastMode.NORMAL) { + spellCard = ((SpellAbility) abilityToModify).getSpellAbilityCastMode().getTypeModifiedCardObjectCopy(spellCard, game); + } + return spellCard.isCreature(); } } } diff --git a/Mage.Sets/src/mage/cards/s/SemblanceAnvil.java b/Mage.Sets/src/mage/cards/s/SemblanceAnvil.java index dba8d34db80..18308677210 100644 --- a/Mage.Sets/src/mage/cards/s/SemblanceAnvil.java +++ b/Mage.Sets/src/mage/cards/s/SemblanceAnvil.java @@ -1,5 +1,7 @@ package mage.cards.s; +import java.util.List; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.SpellAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility; @@ -18,9 +20,6 @@ import mage.players.Player; import mage.target.TargetCard; import mage.util.CardUtil; -import java.util.List; -import java.util.UUID; - /** * @author nantuko */ @@ -107,15 +106,19 @@ class SemblanceAnvilCostReductionEffect extends CostModificationEffectImpl { @Override public boolean applies(Ability abilityToModify, Ability source, Game game) { - if (abilityToModify instanceof SpellAbility) { - Card sourceCard = game.getCard(abilityToModify.getSourceId()); - if (sourceCard != null && sourceCard.isOwnedBy(source.getControllerId())) { + if (abilityToModify instanceof SpellAbility + && abilityToModify.isControlledBy(source.getControllerId())) { + Card spellCard = ((SpellAbility) abilityToModify).getCharacteristics(game); + if (spellCard != null) { + if (((SpellAbility) abilityToModify).getSpellAbilityCastMode() != SpellAbilityCastMode.NORMAL) { + spellCard = ((SpellAbility) abilityToModify).getSpellAbilityCastMode().getTypeModifiedCardObjectCopy(spellCard, game); + } Permanent permanent = game.getPermanent(source.getSourceId()); if (permanent != null) { List imprinted = permanent.getImprinted(); if (imprinted != null && !imprinted.isEmpty()) { Card imprintedCard = game.getCard(imprinted.get(0)); - return imprintedCard != null && imprintedCard.shareTypes(sourceCard); + return imprintedCard != null && imprintedCard.shareTypes(spellCard); } } } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/BestowTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/BestowTest.java index 6dd7e5e3974..9404a4dbfab 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/BestowTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/BestowTest.java @@ -191,7 +191,6 @@ public class BestowTest extends CardTestPlayerBase { addTarget(playerB, playerA); // Away addTarget(playerA, "Nyxborn Rollicker"); - setStrictChooseMode(true); setStopAt(1, PhaseStep.END_TURN); execute(); @@ -463,4 +462,26 @@ public class BestowTest extends CardTestPlayerBase { Assert.assertFalse("The unattached Nighthowler may not have the aura subtype.", nighthowler.getSubtype(currentGame).contains(SubType.AURA)); } + @Test + public void testCastBestowWithCostReduction() { + // Enchantment Creature — Horror + // Bestow {5}{G} (If you cast this card for its bestow cost, it's an Aura spell with enchant creature. It becomes a creature again if it's not attached to a creature.) + // Trample + // Enchanted creature gets +3/+3 and has trample. + addCard(Zone.HAND, playerA, "Nylea's Emissary"); // Enchantment Creature + addCard(Zone.BATTLEFIELD, playerA, "Forest", 4); + addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion"); // {1}{W} 2/2 creature + // Aura spells you cast cost {1} less to cast. + addCard(Zone.BATTLEFIELD, playerA, "Transcendent Envoy", 2); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Nylea's Emissary using bestow", "Silvercoat Lion"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertPermanentCount(playerA, "Nylea's Emissary", 1); + assertPowerToughness(playerA, "Silvercoat Lion", 5, 5); + assertType("Nylea's Emissary", CardType.CREATURE, false); + assertType("Nylea's Emissary", CardType.ENCHANTMENT, SubType.AURA); + } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/cost/AbilitiesCostReductionControllerEffect.java b/Mage/src/main/java/mage/abilities/effects/common/cost/AbilitiesCostReductionControllerEffect.java index aad1ebcc761..86a4c0de5b7 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/cost/AbilitiesCostReductionControllerEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/cost/AbilitiesCostReductionControllerEffect.java @@ -18,7 +18,7 @@ import mage.util.CardUtil; */ public class AbilitiesCostReductionControllerEffect extends CostModificationEffectImpl { - private Class activatedAbility; + private final Class activatedAbility; public AbilitiesCostReductionControllerEffect(Class activatedAbility, String activatedAbilityName) { super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.REDUCE_COST); diff --git a/Mage/src/main/java/mage/abilities/effects/common/cost/CostModificationSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/cost/CostModificationSourceEffect.java index c1be451a4c4..607f180aeef 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/cost/CostModificationSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/cost/CostModificationSourceEffect.java @@ -10,8 +10,6 @@ import mage.game.Game; import mage.players.Player; import mage.util.CardUtil; -import java.util.UUID; - public class CostModificationSourceEffect extends CostModificationEffectImpl { private final Class abilityType; diff --git a/Mage/src/main/java/mage/abilities/effects/common/cost/SpellCostReductionForEachSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/cost/SpellCostReductionForEachSourceEffect.java index 0719d6aee76..f7c1b9e95df 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/cost/SpellCostReductionForEachSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/cost/SpellCostReductionForEachSourceEffect.java @@ -18,7 +18,7 @@ import mage.util.CardUtil; public class SpellCostReductionForEachSourceEffect extends CostModificationEffectImpl { private final DynamicValue eachAmount; - private ManaCosts reduceManaCosts; + private final ManaCosts reduceManaCosts; private final int reduceGenericMana; public SpellCostReductionForEachSourceEffect(int reduceGenericMana, DynamicValue eachAmount) { @@ -50,7 +50,6 @@ public class SpellCostReductionForEachSourceEffect extends CostModificationEffec this.staticText = sb.toString(); } - protected SpellCostReductionForEachSourceEffect(final SpellCostReductionForEachSourceEffect effect) { super(effect); this.eachAmount = effect.eachAmount; diff --git a/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostIncreasingAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostIncreasingAllEffect.java index 9786f8c0778..fdec9bfdd34 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostIncreasingAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostIncreasingAllEffect.java @@ -23,7 +23,7 @@ public class SpellsCostIncreasingAllEffect extends CostModificationEffectImpl { private final FilterCard filter; private final TargetController targetController; private final int increaseGenericCost; - private ManaCosts increaseManaCosts; + private final ManaCosts increaseManaCosts; public SpellsCostIncreasingAllEffect(int increaseGenericCost, FilterCard filter, TargetController targetController) { super(Duration.WhileOnBattlefield, Outcome.Detriment, CostModificationType.INCREASE_COST); diff --git a/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostModificationThatTargetSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostModificationThatTargetSourceEffect.java index 3a380982265..3364e3c02ad 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostModificationThatTargetSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostModificationThatTargetSourceEffect.java @@ -1,5 +1,7 @@ package mage.abilities.effects.common.cost; +import java.util.Set; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.SpellAbility; import mage.constants.CostModificationType; @@ -12,9 +14,6 @@ import mage.game.stack.Spell; import mage.players.Player; import mage.util.CardUtil; -import java.util.Set; -import java.util.UUID; - /** * @author JayDi85 */ @@ -23,7 +22,7 @@ public class SpellsCostModificationThatTargetSourceEffect extends CostModificati private final FilterCard spellFilter; private final int modificationAmount; private String targetName = "{this}"; - private TargetController targetController; + private final TargetController targetController; public SpellsCostModificationThatTargetSourceEffect(int modificationAmount, FilterCard spellFilter, TargetController targetController) { super(Duration.WhileOnBattlefield, Outcome.Neutral, modificationAmount < 0 ? CostModificationType.REDUCE_COST : CostModificationType.INCREASE_COST); diff --git a/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostReductionAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostReductionAllEffect.java index 5b1dd4811cd..db88ba0bcb2 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostReductionAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostReductionAllEffect.java @@ -1,5 +1,8 @@ package mage.abilities.effects.common.cost; +import java.util.LinkedHashSet; +import java.util.Set; +import java.util.UUID; import mage.Mana; import mage.abilities.Ability; import mage.abilities.SpellAbility; @@ -8,16 +11,12 @@ import mage.choices.ChoiceImpl; import mage.constants.CostModificationType; import mage.constants.Duration; import mage.constants.Outcome; +import mage.constants.SpellAbilityCastMode; import mage.filter.FilterCard; import mage.game.Game; -import mage.game.stack.Spell; import mage.players.Player; import mage.util.CardUtil; -import java.util.LinkedHashSet; -import java.util.Set; -import java.util.UUID; - /** * @author LevelX2 */ @@ -123,15 +122,12 @@ public class SpellsCostReductionAllEffect extends CostModificationEffectImpl { return false; } if (abilityToModify instanceof SpellAbility) { - Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId()); - if (spell != null) { - // real cast with put on stack - return this.filter.match(spell, game) && selectedByRuntimeData(spell, source, game); - } else { - // get playable and other staff without put on stack - // used at least for flashback ability because Flashback ability doesn't use stack - Card sourceCard = game.getCard(abilityToModify.getSourceId()); - return sourceCard != null && this.filter.match(sourceCard, game) && selectedByRuntimeData(sourceCard, source, game); + Card spellCard = ((SpellAbility) abilityToModify).getCharacteristics(game); + if (spellCard != null) { + if (((SpellAbility) abilityToModify).getSpellAbilityCastMode() != SpellAbilityCastMode.NORMAL) { + spellCard = ((SpellAbility) abilityToModify).getSpellAbilityCastMode().getTypeModifiedCardObjectCopy(spellCard, game); + } + return this.filter.match(spellCard, game) && selectedByRuntimeData(spellCard, source, game); } } return false; diff --git a/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostReductionControllerEffect.java b/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostReductionControllerEffect.java index 7fcab94aaf9..2b68bfd19e9 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostReductionControllerEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostReductionControllerEffect.java @@ -1,5 +1,7 @@ package mage.abilities.effects.common.cost; +import java.util.LinkedHashSet; +import java.util.Set; import mage.MageObject; import mage.Mana; import mage.abilities.Ability; @@ -11,15 +13,12 @@ import mage.choices.ChoiceImpl; import mage.constants.CostModificationType; import mage.constants.Duration; import mage.constants.Outcome; +import mage.constants.SpellAbilityCastMode; import mage.filter.FilterCard; import mage.game.Game; -import mage.game.stack.Spell; import mage.players.Player; import mage.util.CardUtil; -import java.util.LinkedHashSet; -import java.util.Set; - /** * @author North */ @@ -114,15 +113,12 @@ public class SpellsCostReductionControllerEffect extends CostModificationEffectI public boolean applies(Ability abilityToModify, Ability source, Game game) { if (abilityToModify instanceof SpellAbility) { if (abilityToModify.isControlledBy(source.getControllerId())) { - Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId()); - if (spell != null) { - // real cast with put on stack - return this.filter.match(spell, source.getSourceId(), source.getControllerId(), game); - } else { - // get playable and other staff without put on stack - // used at least for flashback ability because Flashback ability doesn't use stack - Card sourceCard = game.getCard(abilityToModify.getSourceId()); - return sourceCard != null && this.filter.match(sourceCard, source.getSourceId(), source.getControllerId(), game); + Card spellCard = ((SpellAbility) abilityToModify).getCharacteristics(game);; + if (spellCard != null) { + if (((SpellAbility) abilityToModify).getSpellAbilityCastMode() != SpellAbilityCastMode.NORMAL) { + spellCard = ((SpellAbility) abilityToModify).getSpellAbilityCastMode().getTypeModifiedCardObjectCopy(spellCard, game); + } + return this.filter.match(spellCard, source.getSourceId(), source.getControllerId(), game); } } } diff --git a/Mage/src/main/java/mage/abilities/keyword/BestowAbility.java b/Mage/src/main/java/mage/abilities/keyword/BestowAbility.java index 3682e850293..e9ce835df98 100644 --- a/Mage/src/main/java/mage/abilities/keyword/BestowAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/BestowAbility.java @@ -1,4 +1,3 @@ - package mage.abilities.keyword; import mage.MageObject; @@ -138,6 +137,14 @@ public class BestowAbility extends SpellAbility { } } + + static public void becomeAura(Card card) { + if (card != null) { + card.getSubtype(null).add(SubType.AURA); + card.getCardType().remove(CardType.CREATURE); + card.getCardType().add(CardType.ENCHANTMENT); + } + } } class BestowEntersBattlefieldEffect extends ReplacementEffectImpl { diff --git a/Mage/src/main/java/mage/constants/SpellAbilityCastMode.java b/Mage/src/main/java/mage/constants/SpellAbilityCastMode.java index 19bf79cc6b5..9fa3da28629 100644 --- a/Mage/src/main/java/mage/constants/SpellAbilityCastMode.java +++ b/Mage/src/main/java/mage/constants/SpellAbilityCastMode.java @@ -1,6 +1,9 @@ - package mage.constants; +import mage.abilities.keyword.BestowAbility; +import mage.cards.Card; +import mage.game.Game; + /** * * @author LevelX2 @@ -21,4 +24,12 @@ public enum SpellAbilityCastMode { public String toString() { return text; } + + public Card getTypeModifiedCardObjectCopy(Card card, Game game) { + Card cardCopy = card.copy(); + if (this.equals(BESTOW)) { + BestowAbility.becomeAura(cardCopy); + } + return cardCopy; + } } diff --git a/Mage/src/main/java/mage/game/command/planes/FeedingGroundsPlane.java b/Mage/src/main/java/mage/game/command/planes/FeedingGroundsPlane.java index f60f1517200..553e7ce747e 100644 --- a/Mage/src/main/java/mage/game/command/planes/FeedingGroundsPlane.java +++ b/Mage/src/main/java/mage/game/command/planes/FeedingGroundsPlane.java @@ -1,5 +1,7 @@ package mage.game.command.planes; +import java.util.ArrayList; +import java.util.List; import mage.MageObject; import mage.ObjectColor; import mage.abilities.Ability; @@ -29,9 +31,6 @@ import mage.target.common.TargetCreaturePermanent; import mage.util.CardUtil; import mage.watchers.common.PlanarRollWatcher; -import java.util.ArrayList; -import java.util.List; - /** * @author spjspj */ @@ -52,9 +51,9 @@ public class FeedingGroundsPlane extends Plane { Effect chaosEffect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(), TargetConvertedManaCost.instance); Target chaosTarget = new TargetCreaturePermanent(1, 1, filter, false); - List chaosEffects = new ArrayList(); + List chaosEffects = new ArrayList<>(); chaosEffects.add(chaosEffect); - List chaosTargets = new ArrayList(); + List chaosTargets = new ArrayList<>(); chaosTargets.add(chaosTarget); ActivateIfConditionActivatedAbility chaosAbility = new ActivateIfConditionActivatedAbility(Zone.COMMAND, new RollPlanarDieEffect(chaosEffects, chaosTargets), new GenericManaCost(0), MainPhaseStackEmptyCondition.instance); diff --git a/Mage/src/main/java/mage/game/command/planes/TurriIslandPlane.java b/Mage/src/main/java/mage/game/command/planes/TurriIslandPlane.java index 5291caf194d..3f737edfbb1 100644 --- a/Mage/src/main/java/mage/game/command/planes/TurriIslandPlane.java +++ b/Mage/src/main/java/mage/game/command/planes/TurriIslandPlane.java @@ -17,7 +17,6 @@ import mage.filter.FilterCard; import mage.filter.common.FilterCreatureCard; import mage.game.Game; import mage.game.command.Plane; -import mage.game.stack.Spell; import mage.target.Target; import mage.util.CardUtil; import mage.watchers.common.PlanarRollWatcher; @@ -42,9 +41,9 @@ public class TurriIslandPlane extends Plane { Effect chaosEffect = new RevealLibraryPutIntoHandEffect(3, new FilterCreatureCard("creature cards"), Zone.GRAVEYARD); Target chaosTarget = null; - List chaosEffects = new ArrayList(); + List chaosEffects = new ArrayList<>(); chaosEffects.add(chaosEffect); - List chaosTargets = new ArrayList(); + List chaosTargets = new ArrayList<>(); chaosTargets.add(chaosTarget); ActivateIfConditionActivatedAbility chaosAbility = new ActivateIfConditionActivatedAbility(Zone.COMMAND, new RollPlanarDieEffect(chaosEffects, chaosTargets), new GenericManaCost(0), MainPhaseStackEmptyCondition.instance); @@ -110,14 +109,12 @@ class TurriIslandEffect extends CostModificationEffectImpl { if (!cPlane.getPlaneType().equals(Planes.PLANE_TURRI_ISLAND)) { return false; } - - Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId()); - if (spell != null) { - return filter.match(spell, game) && selectedByRuntimeData(spell, source, game); - } else { - // used at least for flashback ability because Flashback ability doesn't use stack - Card sourceCard = game.getCard(abilityToModify.getSourceId()); - return sourceCard != null && filter.match(sourceCard, game) && selectedByRuntimeData(sourceCard, source, game); + Card spellCard = ((SpellAbility) abilityToModify).getCharacteristics(game); + if (spellCard != null) { + if (((SpellAbility) abilityToModify).getSpellAbilityCastMode() != SpellAbilityCastMode.NORMAL) { + spellCard = ((SpellAbility) abilityToModify).getSpellAbilityCastMode().getTypeModifiedCardObjectCopy(spellCard, game); + } + return filter.match(spellCard, game) && selectedByRuntimeData(spellCard, source, game); } } return false;