From 26e81ab26d5d3af75ebc624eb21ad61c7b774d7b Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Fri, 28 Apr 2017 15:41:38 +0200 Subject: [PATCH] * Added UT for #3251. --- Mage.Sets/src/mage/cards/r/RagsRiches.java | 5 +- .../single/soi/TheGitrogMonsterTest.java | 53 +++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/Mage.Sets/src/mage/cards/r/RagsRiches.java b/Mage.Sets/src/mage/cards/r/RagsRiches.java index d14601815e..2e80139033 100644 --- a/Mage.Sets/src/mage/cards/r/RagsRiches.java +++ b/Mage.Sets/src/mage/cards/r/RagsRiches.java @@ -75,7 +75,8 @@ class RichesEffect extends OneShotEffect { Player opponent = game.getPlayer(playerId); if (opponent != null) { TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent(); - if (opponent.chooseTarget(Outcome.Detriment, target, source, game)) { + target.setNotTarget(true); + if (opponent.choose(Outcome.Detriment, target, source.getSourceId(), game)) { creaturesToSteal.add(target.getTargets().get(0)); } } @@ -85,7 +86,7 @@ class RichesEffect extends OneShotEffect { // Has to be done as a separate loop in case there's a situation where one creature's // controller depends on another creatures controller. for (UUID target : creaturesToSteal) { - GainControlTargetEffect eff = new GainControlTargetEffect(Duration.EndOfGame, true); + GainControlTargetEffect eff = new GainControlTargetEffect(Duration.Custom, true); eff.setTargetPointer(new FixedTarget(target)); game.addEffect(eff, source); } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/soi/TheGitrogMonsterTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/soi/TheGitrogMonsterTest.java index 322f47980c..82ca94b6a2 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/single/soi/TheGitrogMonsterTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/soi/TheGitrogMonsterTest.java @@ -95,4 +95,57 @@ public class TheGitrogMonsterTest extends CardTestPlayerBase { assertPermanentCount(playerA, "The Gitrog Monster", 0); assertPermanentCount(playerB, "Planar Outburst", 0); } + + /** + * I took control of a Gitrog Monster, while the Gitrog Monster's owner + * controlled a Dryad Arbor and cast Toxic Deluge for 6. + */ + @Test + public void controlChange() { + // Deathtouch + // At the beginning of your upkeep, sacrifice The Gitrog Monster unless you sacrifice a land. + // You may play an additional land on each of your turns. + // Whenever one or more land cards are put into your graveyard from anywhere, draw a card. + addCard(Zone.HAND, playerA, "The Gitrog Monster", 1); // Creature 6/6 {3}{B}{G} + addCard(Zone.HAND, playerA, "Toxic Deluge", 1); // Sorcery {2}{B} + // (Dryad Arbor isn't a spell, it's affected by summoning sickness, and it has "{T}: Add {G} to your mana pool.") + addCard(Zone.HAND, playerA, "Dryad Arbor", 1); // Land Creature 1/1 + addCard(Zone.HAND, playerA, "Swamp", 1); + addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2); + addCard(Zone.BATTLEFIELD, playerA, "Forest", 2); + + // Rags Sorcery {2}{B}{B} + // All creatures get -2/-2 until end of turn. + // Riches Sorcery {5}{U}{U} + // Each opponent chooses a creature he or she controls. You gain control of each of those creatures. + addCard(Zone.GRAVEYARD, playerB, "Rags // Riches", 1); + addCard(Zone.BATTLEFIELD, playerB, "Island", 7); + + playLand(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Swamp"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "The Gitrog Monster"); + playLand(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Dryad Arbor"); + + castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Riches"); + setChoice(playerA, "The Gitrog Monster"); + + // As an additional cost to cast Toxic Deluge, pay X life. + // All creatures get -X/-X until end of turn. + castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Toxic Deluge"); + setChoice(playerA, "X=6"); + + setStopAt(3, PhaseStep.BEGIN_COMBAT); + execute(); + + assertExileCount(playerB, "Rags // Riches", 1); + + assertGraveyardCount(playerA, "Toxic Deluge", 1); + assertLife(playerA, 14); + + assertGraveyardCount(playerA, "The Gitrog Monster", 1); + assertGraveyardCount(playerA, "Dryad Arbor", 1); + + assertHandCount(playerB, 1); // 1 drawn in draw of turn 2 + assertHandCount(playerA, 1); // 1 drawn in draw of turn 3 - no card sfro Gitrog + + } }