mirror of
https://github.com/correl/mage.git
synced 2024-11-25 11:09:53 +00:00
[ELD] fixed issues with Robber of the Rich
This commit is contained in:
parent
c842fd271c
commit
8f37428518
2 changed files with 67 additions and 11 deletions
|
@ -1,7 +1,6 @@
|
||||||
package mage.cards.r;
|
package mage.cards.r;
|
||||||
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.MageObject;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.AttacksTriggeredAbility;
|
import mage.abilities.common.AttacksTriggeredAbility;
|
||||||
import mage.abilities.condition.Condition;
|
import mage.abilities.condition.Condition;
|
||||||
|
@ -15,6 +14,7 @@ import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.*;
|
import mage.constants.*;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.util.CardUtil;
|
import mage.util.CardUtil;
|
||||||
import mage.watchers.common.AttackedThisTurnWatcher;
|
import mage.watchers.common.AttackedThisTurnWatcher;
|
||||||
|
@ -43,17 +43,14 @@ public final class RobberOfTheRich extends CardImpl {
|
||||||
this.addAbility(HasteAbility.getInstance());
|
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.
|
// 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 AttacksTriggeredAbility(
|
||||||
new RobberOfTheRichEffect(), false, "", SetTargetPointer.PLAYER
|
new RobberOfTheRichEffect(), false, "", SetTargetPointer.PLAYER
|
||||||
), RobberOfTheRichAttacksCondition.instance, "Whenever {this} attacks, " +
|
), RobberOfTheRichAttacksCondition.instance, "Whenever {this} attacks, " +
|
||||||
"if defending player has more cards in hand than you, exile the top card of their library. " +
|
"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 " +
|
"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.");
|
"you may spend mana as though it were mana of any color to cast that spell."
|
||||||
ability.addWatcher(new AttackedThisTurnWatcher());
|
).addHint(new ConditionHint(RobberOfTheRichAnyTurnAttackedCondition.instance)), new AttackedThisTurnWatcher());
|
||||||
ability.addHint(new ConditionHint(RobberOfTheRichAnyTurnAttackedCondition.instance));
|
|
||||||
|
|
||||||
this.addAbility(ability);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private RobberOfTheRich(final RobberOfTheRich card) {
|
private RobberOfTheRich(final RobberOfTheRich card) {
|
||||||
|
@ -123,14 +120,13 @@ class RobberOfTheRichEffect extends OneShotEffect {
|
||||||
if (controller == null || damagedPlayer == null) {
|
if (controller == null || damagedPlayer == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
Permanent sourceObject = source.getSourcePermanentIfItStillExists(game);
|
||||||
UUID exileId = CardUtil.getCardExileZoneId(game, source);
|
|
||||||
Card card = damagedPlayer.getLibrary().getFromTop(game);
|
Card card = damagedPlayer.getLibrary().getFromTop(game);
|
||||||
if (card == null || sourceObject == null) {
|
if (card == null || sourceObject == null) {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
// move card to exile
|
// 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).
|
// Add effects only if the card has a spellAbility (e.g. not for lands).
|
||||||
if (card.getSpellAbility() != null) {
|
if (card.getSpellAbility() != null) {
|
||||||
// allow to cast the card
|
// allow to cast the card
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue