mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
* Brutal Expulsion - Fixed that also spell targets were handled correctly.
This commit is contained in:
parent
24d555f41c
commit
391d247e7c
4 changed files with 71 additions and 81 deletions
|
@ -31,18 +31,11 @@ import java.util.UUID;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.common.ReturnToHandTargetEffect;
|
||||||
import mage.abilities.keyword.FlashAbility;
|
import mage.abilities.keyword.FlashAbility;
|
||||||
import mage.cards.Card;
|
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.permanent.Permanent;
|
|
||||||
import mage.game.stack.Spell;
|
|
||||||
import mage.players.Player;
|
|
||||||
import mage.target.Target;
|
import mage.target.Target;
|
||||||
import mage.target.common.TargetSpellOrPermanent;
|
import mage.target.common.TargetSpellOrPermanent;
|
||||||
|
|
||||||
|
@ -65,7 +58,7 @@ public class VenserShaperSavant extends CardImpl {
|
||||||
// Flash
|
// Flash
|
||||||
this.addAbility(FlashAbility.getInstance());
|
this.addAbility(FlashAbility.getInstance());
|
||||||
// When Venser, Shaper Savant enters the battlefield, return target spell or permanent to its owner's hand.
|
// When Venser, Shaper Savant enters the battlefield, return target spell or permanent to its owner's hand.
|
||||||
Ability ability = new EntersBattlefieldTriggeredAbility(new VenserShaperSavantEffect(), false);
|
Ability ability = new EntersBattlefieldTriggeredAbility(new ReturnToHandTargetEffect(true), false);
|
||||||
Target target = new TargetSpellOrPermanent();
|
Target target = new TargetSpellOrPermanent();
|
||||||
ability.addTarget(target);
|
ability.addTarget(target);
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
|
@ -80,56 +73,3 @@ public class VenserShaperSavant extends CardImpl {
|
||||||
return new VenserShaperSavant(this);
|
return new VenserShaperSavant(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class VenserShaperSavantEffect extends OneShotEffect {
|
|
||||||
|
|
||||||
public VenserShaperSavantEffect() {
|
|
||||||
super(Outcome.ReturnToHand);
|
|
||||||
this.staticText = "return target spell or permanent to its owner's hand";
|
|
||||||
}
|
|
||||||
|
|
||||||
public VenserShaperSavantEffect(final VenserShaperSavantEffect effect) {
|
|
||||||
super(effect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VenserShaperSavantEffect copy() {
|
|
||||||
return new VenserShaperSavantEffect(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Game game, Ability source) {
|
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
|
||||||
if (controller != null) {
|
|
||||||
Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
|
|
||||||
if (permanent != null) {
|
|
||||||
return controller.moveCards(permanent, null, Zone.HAND, source, game);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 01.05.2007 If a spell is returned to its owner's hand, it's
|
|
||||||
* removed from the stack and thus will not resolve. The spell isn't
|
|
||||||
* countered; it just no longer exists. 01.05.2007 If a copy of a
|
|
||||||
* spell is returned to its owner's hand, it's moved there, then it
|
|
||||||
* will cease to exist as a state-based action. 01.05.2007 If
|
|
||||||
* Venser's enters-the-battlefield ability targets a spell cast with
|
|
||||||
* flashback, that spell will be exiled instead of returning to its
|
|
||||||
* owner's hand.
|
|
||||||
*/
|
|
||||||
Spell spell = game.getStack().getSpell(this.getTargetPointer().getFirst(game, source));
|
|
||||||
if (spell != null) {
|
|
||||||
Card card = null;
|
|
||||||
if (!spell.isCopy()) {
|
|
||||||
card = spell.getCard();
|
|
||||||
}
|
|
||||||
game.getStack().remove(spell);
|
|
||||||
if (card != null) {
|
|
||||||
controller.moveCards(card, null, Zone.HAND, source, game);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -36,7 +36,6 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
*
|
*
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ReturnToHandTest extends CardTestPlayerBase {
|
public class ReturnToHandTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -92,8 +91,10 @@ public class ReturnToHandTest extends CardTestPlayerBase {
|
||||||
assertHandCount(playerA, "Veilborn Ghoul", 1);
|
assertHandCount(playerA, "Veilborn Ghoul", 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return from graveyard to hand if you play a non swamp land but Urborg, Tomb of Yawgmoth is in play
|
* Return from graveyard to hand if you play a non swamp land but Urborg,
|
||||||
|
* Tomb of Yawgmoth is in play
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void VeilbornGhoulTest2() {
|
public void VeilbornGhoulTest2() {
|
||||||
|
@ -115,4 +116,33 @@ public class ReturnToHandTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a spell from stack to Hand
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void BrutalExpulsionTest() {
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Island", 2);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
|
||||||
|
// Devoid
|
||||||
|
// Choose one or both
|
||||||
|
// - Return target spell or creature to its owner's hand;
|
||||||
|
// or Brutal Expulsion deals 2 damage to target creature or planeswalker. If that permanent would be put into a graveyard this turn, exile it instead.
|
||||||
|
addCard(Zone.HAND, playerA, "Brutal Expulsion"); // {2}{U}{R}
|
||||||
|
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Plains", 4);
|
||||||
|
addCard(Zone.HAND, playerB, "Pillarfield Ox", 1);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion", 1);
|
||||||
|
|
||||||
|
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Pillarfield Ox");
|
||||||
|
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerA, "Brutal Expulsion", "mode=1Pillarfield Ox^mode=2Silvercoat Lion", "Pillarfield Ox");
|
||||||
|
setStopAt(2, PhaseStep.BEGIN_COMBAT);
|
||||||
|
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertGraveyardCount(playerA, "Brutal Expulsion", 1);
|
||||||
|
assertExileCount("Silvercoat Lion", 1);
|
||||||
|
assertPermanentCount(playerB, "Pillarfield Ox", 0);
|
||||||
|
assertHandCount(playerB, "Pillarfield Ox", 1);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -935,7 +935,8 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
||||||
* @param step
|
* @param step
|
||||||
* @param player
|
* @param player
|
||||||
* @param cardName
|
* @param cardName
|
||||||
* @param targetName
|
* @param targetName for modal spells add the mode to the name e.g.
|
||||||
|
* "mode=2SilvercoatLion^mode3=PillarfieldOx"
|
||||||
* @param spellOnStack
|
* @param spellOnStack
|
||||||
*/
|
*/
|
||||||
public void castSpell(int turnNum, PhaseStep step, TestPlayer player, String cardName, String targetName, String spellOnStack) {
|
public void castSpell(int turnNum, PhaseStep step, TestPlayer player, String cardName, String targetName, String spellOnStack) {
|
||||||
|
|
|
@ -2934,6 +2934,18 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Card card = game.getCard(cardId);
|
Card card = game.getCard(cardId);
|
||||||
|
if (card == null) {
|
||||||
|
Spell spell = game.getState().getStack().getSpell(cardId);
|
||||||
|
if (spell != null) {
|
||||||
|
if (!spell.isCopy()) {
|
||||||
|
card = spell.getCard();
|
||||||
|
} else {
|
||||||
|
// If a spell is returned to its owner's hand, it's removed from the stack and thus will not resolve
|
||||||
|
game.getStack().remove(spell);
|
||||||
|
game.informPlayers(spell.getLogName() + " was removed from the stack");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
cardList.add(card);
|
cardList.add(card);
|
||||||
}
|
}
|
||||||
|
@ -2973,6 +2985,13 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
case HAND:
|
case HAND:
|
||||||
for (Card card : cards) {
|
for (Card card : cards) {
|
||||||
fromZone = game.getState().getZone(card.getId());
|
fromZone = game.getState().getZone(card.getId());
|
||||||
|
if (fromZone == Zone.STACK) {
|
||||||
|
// If a spell is returned to its owner's hand, it's removed from the stack and thus will not resolve
|
||||||
|
Spell spell = game.getStack().getSpell(card.getId());
|
||||||
|
if (spell != null) {
|
||||||
|
game.getStack().remove(spell);
|
||||||
|
}
|
||||||
|
}
|
||||||
boolean hideCard = fromZone.equals(Zone.LIBRARY)
|
boolean hideCard = fromZone.equals(Zone.LIBRARY)
|
||||||
|| (card.isFaceDown(game) && !fromZone.equals(Zone.STACK) && !fromZone.equals(Zone.BATTLEFIELD));
|
|| (card.isFaceDown(game) && !fromZone.equals(Zone.STACK) && !fromZone.equals(Zone.BATTLEFIELD));
|
||||||
if (moveCardToHandWithInfo(card, source == null ? null : source.getSourceId(), game, !hideCard)) {
|
if (moveCardToHandWithInfo(card, source == null ? null : source.getSourceId(), game, !hideCard)) {
|
||||||
|
|
Loading…
Reference in a new issue