diff --git a/Mage.Sets/src/mage/sets/dragonsoftarkir/SunscorchRegent.java b/Mage.Sets/src/mage/sets/dragonsoftarkir/SunscorchRegent.java index 25ea467de0..5e42c28db0 100644 --- a/Mage.Sets/src/mage/sets/dragonsoftarkir/SunscorchRegent.java +++ b/Mage.Sets/src/mage/sets/dragonsoftarkir/SunscorchRegent.java @@ -54,6 +54,7 @@ public class SunscorchRegent extends CardImpl { // Flying this.addAbility(FlyingAbility.getInstance()); + // Whenever an opponent casts a spell, put a +1/+1 counter on Sunscorch Regent and you gain 1 life. Ability ability = new SpellCastOpponentTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance()), false); ability.addEffect(new GainLifeEffect(1)); diff --git a/Mage.Sets/src/mage/sets/judgment/CabalTherapy.java b/Mage.Sets/src/mage/sets/judgment/CabalTherapy.java index 0990589c10..ae30ce6a2e 100644 --- a/Mage.Sets/src/mage/sets/judgment/CabalTherapy.java +++ b/Mage.Sets/src/mage/sets/judgment/CabalTherapy.java @@ -28,6 +28,7 @@ package mage.sets.judgment; import java.util.UUID; +import mage.MageObject; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Rarity; @@ -57,11 +58,10 @@ public class CabalTherapy extends CardImpl { super(ownerId, 62, "Cabal Therapy", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{B}"); this.expansionSetCode = "JUD"; - this.color.setBlack(true); - // Name a nonland card. Target player reveals his or her hand and discards all cards with that name. this.getSpellAbility().addTarget(new TargetPlayer()); this.getSpellAbility().addEffect(new CabalTherapyEffect()); + // Flashback-Sacrifice a creature. this.addAbility(new FlashbackAbility( new SacrificeTargetCost(new TargetControlledCreaturePermanent(1,1,new FilterControlledCreaturePermanent("a creature"), true)), @@ -91,10 +91,12 @@ class CabalTherapyEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(targetPointer.getFirst(game, source)); + Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source)); Player controller = game.getPlayer(source.getControllerId()); - if (player != null && controller != null) { - Choice cardChoice = new ChoiceImpl(); + MageObject sourceObject = game.getObject(source.getSourceId()); + if (targetPlayer != null && controller != null && sourceObject != null) { + Choice cardChoice = new ChoiceImpl(true); + cardChoice.setMessage("Name a nonland card."); cardChoice.setChoices(CardRepository.instance.getNonLandNames()); cardChoice.clearChoice(); @@ -105,14 +107,14 @@ class CabalTherapyEffect extends OneShotEffect { } String cardName = cardChoice.getChoice(); - game.informPlayers("Cabal Therapy, named card: [" + cardName + "]"); - for (Card card : player.getHand().getCards(game)) { + game.informPlayers(sourceObject.getLogName() + ", named card: [" + cardName + "]"); + for (Card card : targetPlayer.getHand().getCards(game)) { if (card.getName().equals(cardName)) { - player.discard(card, source, game); + targetPlayer.discard(card, source, game); } } - controller.lookAtCards("Cabal Therapy Hand", player.getHand(), game); + controller.lookAtCards(sourceObject.getLogName() + " Hand", targetPlayer.getHand(), game); } return true; } diff --git a/Mage.Sets/src/mage/sets/magic2015/ChiefEngineer.java b/Mage.Sets/src/mage/sets/magic2015/ChiefEngineer.java index c7c1aedaf6..32f86d943a 100644 --- a/Mage.Sets/src/mage/sets/magic2015/ChiefEngineer.java +++ b/Mage.Sets/src/mage/sets/magic2015/ChiefEngineer.java @@ -117,16 +117,13 @@ class ChiefEngineerGainAbilitySpellsEffect extends ContinuousEffectImpl { Player player = game.getPlayer(source.getControllerId()); Permanent permanent = game.getPermanent(source.getSourceId()); if (player != null && permanent != null) { - for (Iterator<StackObject> iterator = game.getStack().iterator(); iterator.hasNext();) { - StackObject stackObject = iterator.next(); - // only cast spells, so no copies - if (!stackObject.isCopy() && stackObject.getControllerId().equals(source.getControllerId())) { - if (stackObject instanceof Spell) { - Spell spell = (Spell) stackObject; - if (filter.match(spell, game)) { - if (!spell.getAbilities().contains(ability)) { - game.getState().addOtherAbility(spell.getCard(), ability); - } + for (StackObject stackObject : game.getStack()) { + // only spells cast, so no copies of spells + if ((stackObject instanceof Spell) && !stackObject.isCopy() && stackObject.getControllerId().equals(source.getControllerId())) { + Spell spell = (Spell) stackObject; + if (filter.match(spell, game)) { + if (!spell.getAbilities().contains(ability)) { + game.getState().addOtherAbility(spell.getCard(), ability); } } } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/ConvokeTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/ConvokeTest.java index f8ab8e88da..d802ef98db 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/ConvokeTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/ConvokeTest.java @@ -138,4 +138,34 @@ public class ConvokeTest extends CardTestPlayerBase { } } + @Test + @Ignore + public void testConvokeFromChiefEngineer() { + /** + * Chief Engineer {1}{U} + * Creature - Vedalken, Artificer + * Artifact spells you cast have convoke. + */ + + // THIS TEST IS NOT FINISHED + addCard(Zone.BATTLEFIELD, playerA, "Plains", 2); + addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 1); // creatures to use for convoek + addCard(Zone.BATTLEFIELD, playerA, "Chief Engineer", 1); + + addCard(Zone.HAND, playerA, "ARTIFACT TO CAST", 1); + + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "ARTIFACT TO CAST"); + setChoice(playerA, "Yes"); + addTarget(playerA, "Silvercoat Lion"); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 20); + + + } + } \ No newline at end of file diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/SpellCastTriggerTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/SpellCastTriggerTest.java new file mode 100644 index 0000000000..97da7f949d --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/SpellCastTriggerTest.java @@ -0,0 +1,68 @@ +/* + * 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.triggers; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ + +public class SpellCastTriggerTest extends CardTestPlayerBase { + + /** + * Tests Sunscorch Regent + */ + @Test + public void testSunscorchRegent() { + // Creature - Dragon 4/3 + // Flying + // Whenever an opponent casts a spell, put a +1/+1 counter on Sunscorch Regent and you gain 1 life. + addCard(Zone.BATTLEFIELD, playerA, "Sunscorch Regent", 1); + + addCard(Zone.HAND, playerB, "Lightning Bolt"); + addCard(Zone.BATTLEFIELD, playerB, "Mountain", 1); + + castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Lightning Bolt", playerA); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + + assertLife(playerA, 18); // 20 -3 +1 + assertLife(playerB, 20); + + assertGraveyardCount(playerB, "Lightning Bolt", 1); + + assertPowerToughness(playerA, "Sunscorch Regent", 5, 4); + } + +} \ No newline at end of file diff --git a/Mage/src/mage/abilities/keyword/DredgeAbility.java b/Mage/src/mage/abilities/keyword/DredgeAbility.java index 0ef0acc1de..86c1baf550 100644 --- a/Mage/src/mage/abilities/keyword/DredgeAbility.java +++ b/Mage/src/mage/abilities/keyword/DredgeAbility.java @@ -97,10 +97,10 @@ class DredgeEffect extends ReplacementEffectImpl { } Player player = game.getPlayer(source.getControllerId()); if (player != null && player.getLibrary().size() >= amount - && player.chooseUse(outcome, new StringBuilder("Dredge ").append(sourceCard.getName()). + && player.chooseUse(outcome, new StringBuilder("Dredge ").append(sourceCard.getLogName()). append("? (").append(amount).append(" cards go from top of library to graveyard)").toString(), game)) { if (!game.isSimulation()) { - game.informPlayers(new StringBuilder(player.getLogName()).append(" dreges ").append(sourceCard.getName()).toString()); + game.informPlayers(new StringBuilder(player.getLogName()).append(" dreges ").append(sourceCard.getLogName()).toString()); } Cards cardsToGrave = new CardsImpl(); cardsToGrave.addAll(player.getLibrary().getTopCards(game, amount)); diff --git a/Mage/src/mage/game/permanent/token/Token.java b/Mage/src/mage/game/permanent/token/Token.java index db626620e9..48d99e43df 100644 --- a/Mage/src/mage/game/permanent/token/Token.java +++ b/Mage/src/mage/game/permanent/token/Token.java @@ -163,12 +163,11 @@ public class Token extends MageObjectImpl { if (attacking && game.getCombat() != null) { game.getCombat().addAttackingCreature(newToken.getId(), game); } + if (!game.isSimulation()) { + game.informPlayers(controller.getLogName() + " puts a " + newToken.getLogName() + " token onto the battlefield"); + } } - if (!game.isSimulation()) { - game.informPlayers(new StringBuilder(controller.getLogName()).append(" puts ") - .append(CardUtil.numberToText(amount, "a")).append(" ").append(this.getName()).append(" token").append(amount==1?"":"s") - .append(" onto the battlefield").toString()); - } + return true; } return false;