diff --git a/Mage.Sets/src/mage/cards/r/RobberOfTheRich.java b/Mage.Sets/src/mage/cards/r/RobberOfTheRich.java index 34b687bc3a..08592b2ce2 100644 --- a/Mage.Sets/src/mage/cards/r/RobberOfTheRich.java +++ b/Mage.Sets/src/mage/cards/r/RobberOfTheRich.java @@ -1,7 +1,6 @@ package mage.cards.r; import mage.MageInt; -import mage.MageObject; import mage.abilities.Ability; import mage.abilities.common.AttacksTriggeredAbility; import mage.abilities.condition.Condition; @@ -15,6 +14,7 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.*; import mage.game.Game; +import mage.game.permanent.Permanent; import mage.players.Player; import mage.util.CardUtil; import mage.watchers.common.AttackedThisTurnWatcher; @@ -43,17 +43,14 @@ public final class RobberOfTheRich extends CardImpl { this.addAbility(HasteAbility.getInstance()); // Whenever Robber of the Rich attacks, if defending player has more cards in hand than you, exile the top card of their library. During any turn you attacked with a Rogue, you may cast that card and you may spend mana as though it were mana of any color to cast that spell. - Ability ability = new ConditionalInterveningIfTriggeredAbility( + this.addAbility(new ConditionalInterveningIfTriggeredAbility( new AttacksTriggeredAbility( new RobberOfTheRichEffect(), false, "", SetTargetPointer.PLAYER ), RobberOfTheRichAttacksCondition.instance, "Whenever {this} attacks, " + "if defending player has more cards in hand than you, exile the top card of their library. " + "During any turn you attacked with a Rogue, you may cast that card and " + - "you may spend mana as though it were mana of any color to cast that spell."); - ability.addWatcher(new AttackedThisTurnWatcher()); - ability.addHint(new ConditionHint(RobberOfTheRichAnyTurnAttackedCondition.instance)); - - this.addAbility(ability); + "you may spend mana as though it were mana of any color to cast that spell." + ).addHint(new ConditionHint(RobberOfTheRichAnyTurnAttackedCondition.instance)), new AttackedThisTurnWatcher()); } private RobberOfTheRich(final RobberOfTheRich card) { @@ -123,14 +120,13 @@ class RobberOfTheRichEffect extends OneShotEffect { if (controller == null || damagedPlayer == null) { return false; } - MageObject sourceObject = game.getObject(source.getSourceId()); - UUID exileId = CardUtil.getCardExileZoneId(game, source); + Permanent sourceObject = source.getSourcePermanentIfItStillExists(game); Card card = damagedPlayer.getLibrary().getFromTop(game); if (card == null || sourceObject == null) { - return true; + return false; } // move card to exile - controller.moveCardToExileWithInfo(card, exileId, sourceObject.getIdName(), source, game, Zone.LIBRARY, true); + controller.moveCardsToExile(card, source, game, true, CardUtil.getExileZoneId(game, source), sourceObject.getIdName()); // Add effects only if the card has a spellAbility (e.g. not for lands). if (card.getSpellAbility() != null) { // allow to cast the card diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/eld/RobberOfTheRichTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/eld/RobberOfTheRichTest.java new file mode 100644 index 0000000000..ebb23c2dba --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/eld/RobberOfTheRichTest.java @@ -0,0 +1,60 @@ +package org.mage.test.cards.single.eld; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * @author TheElk801 + */ +public class RobberOfTheRichTest extends CardTestPlayerBase { + + private static final String robber = "Robber of the Rich"; + private static final String passage = "Whitesun's Passage"; + private static final String blackguard = "Bane Alley Blackguard"; + + @Test + public void testRobber() { + removeAllCardsFromLibrary(playerB); + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2); + addCard(Zone.BATTLEFIELD, playerA, robber); + addCard(Zone.LIBRARY, playerB, passage); + addCard(Zone.HAND, playerB, "Mountain", 3); + + attack(1, playerA, robber, playerB); + + castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, passage); + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertLife(playerA, 20 + 5); + assertGraveyardCount(playerB, passage, 1); + } + + @Test + public void testRobberWithOtherRogue() { + removeAllCardsFromLibrary(playerB); + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2); + addCard(Zone.BATTLEFIELD, playerA, robber); + addCard(Zone.BATTLEFIELD, playerA, blackguard); + addCard(Zone.LIBRARY, playerB, passage, 5); + addCard(Zone.HAND, playerB, "Mountain"); + + attack(1, playerA, robber, playerB); + attack(3, playerA, blackguard, playerB); + + castSpell(3, PhaseStep.POSTCOMBAT_MAIN, playerA, passage); + + setStrictChooseMode(true); + setStopAt(3, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertLife(playerA, 20 + 5); + assertGraveyardCount(playerB, passage, 1); + } +}