mirror of
https://github.com/correl/mage.git
synced 2025-04-11 17:00:08 -09:00
Fixed handling and initialization of Fixedtarget object. Fixing a problem of ReturnToBattlefieldUnderYourControlTargetEffect that caused objects to return taht already left the zone they should be moved from.
This commit is contained in:
parent
148fd0e6ae
commit
f45c5cedeb
16 changed files with 398 additions and 209 deletions
Mage.Sets/src/mage/sets
darkascension
eventide
magic2011
mirrodin
returntoravnica
vintagemasters
Mage.Tests/src/test/java/org/mage/test
AI/basic
cards
abilities
mana
single/rtr
triggers
Mage/src/mage
abilities/effects/common
game
target/targetpointer
|
@ -58,12 +58,12 @@ public class SpitefulShadows extends CardImpl {
|
|||
this.expansionSetCode = "DKA";
|
||||
this.subtype.add("Aura");
|
||||
|
||||
|
||||
// Enchant creature
|
||||
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
||||
this.getSpellAbility().addTarget(auraTarget);
|
||||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.UnboostCreature));
|
||||
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
|
||||
|
||||
// Whenever enchanted creature is dealt damage, it deals that much damage to its controller.
|
||||
this.addAbility(new SpitefulShadowsTriggeredAbility());
|
||||
}
|
||||
|
@ -135,16 +135,16 @@ class SpitefulShadowsEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Integer damageAmount = (Integer) this.getValue("damageAmount");
|
||||
UUID targetId = this.targetPointer.getFirst(game, source);
|
||||
if (damageAmount != null && targetId != null) {
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (damageAmount != null) {
|
||||
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
if (permanent == null) {
|
||||
permanent = (Permanent) game.getLastKnownInformation(targetId, Zone.BATTLEFIELD);
|
||||
FixedTarget fixedTarget = (FixedTarget) getTargetPointer();
|
||||
permanent = (Permanent) game.getLastKnownInformation(fixedTarget.getTarget(), Zone.BATTLEFIELD, fixedTarget.getZoneChangeCounter());
|
||||
}
|
||||
if (permanent != null) {
|
||||
Player player = game.getPlayer(permanent.getControllerId());
|
||||
if (player != null) {
|
||||
player.damage(damageAmount, targetId, game, false, true);
|
||||
player.damage(damageAmount, permanent.getId(), game, false, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public class Necroskitter extends CardImpl {
|
|||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(4);
|
||||
|
||||
// Wither
|
||||
// Wither (This deals damage to creatures in the form of -1/-1 counters.)
|
||||
this.addAbility(WitherAbility.getInstance());
|
||||
|
||||
// Whenever a creature an opponent controls with a -1/-1 counter on it dies, you may return that card to the battlefield under your control.
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* 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
|
||||
|
@ -20,23 +20,22 @@
|
|||
* 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 mage.sets.magic2011;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.common.ReturnSourceFromGraveyardToBattlefieldEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -53,6 +52,7 @@ public class ReassemblingSkeleton extends CardImpl {
|
|||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(1);
|
||||
|
||||
// {1}{B}: Return Reassembling Skeleton from your graveyard to the battlefield tapped.
|
||||
this.addAbility(new SimpleActivatedAbility(Zone.GRAVEYARD, new ReturnSourceFromGraveyardToBattlefieldEffect(true), new ManaCostsImpl("{1}{B}")));
|
||||
}
|
||||
|
||||
|
|
|
@ -89,9 +89,6 @@ class ScytheOfTheWretchedTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
public ScytheOfTheWretchedTriggeredAbility() {
|
||||
super(Zone.ALL, new ScytheOfTheWretchedReanimateEffect(), false);
|
||||
Effect effect = new AttachEffect(Outcome.AddAbility);
|
||||
effect.setText("Attach {this} to that creature.");
|
||||
addEffect(effect);
|
||||
}
|
||||
|
||||
public ScytheOfTheWretchedTriggeredAbility(final ScytheOfTheWretchedTriggeredAbility ability) {
|
||||
|
@ -115,7 +112,7 @@ class ScytheOfTheWretchedTriggeredAbility extends TriggeredAbilityImpl {
|
|||
Permanent equippedCreature = getEquippedCreature(game);
|
||||
for (MageObjectReference mor : zoneChange.getTarget().getDealtDamageByThisTurn()) {
|
||||
Permanent permanent = (Permanent) game.getLastKnownInformation(mor.getSourceId(), Zone.BATTLEFIELD);
|
||||
if((equippedCreature != null && mor.refersTo(equippedCreature, game))
|
||||
if ((equippedCreature != null && mor.refersTo(equippedCreature, game))
|
||||
|| (permanent != null && permanent.getAttachments().contains(getSourceId()))) {
|
||||
setTarget(new FixedTarget(event.getTargetId()));
|
||||
return true;
|
||||
|
@ -149,7 +146,7 @@ class ScytheOfTheWretchedReanimateEffect extends OneShotEffect {
|
|||
|
||||
public ScytheOfTheWretchedReanimateEffect() {
|
||||
super(Outcome.PutCreatureInPlay);
|
||||
this.staticText = "return that card to the battlefield under your control";
|
||||
this.staticText = "return that card to the battlefield under your control. Attach {this} to that creature";
|
||||
}
|
||||
|
||||
public ScytheOfTheWretchedReanimateEffect(final ScytheOfTheWretchedReanimateEffect effect) {
|
||||
|
@ -163,6 +160,9 @@ class ScytheOfTheWretchedReanimateEffect extends OneShotEffect {
|
|||
if (card != null && controller != null) {
|
||||
Zone currentZone = game.getState().getZone(card.getId());
|
||||
controller.putOntoBattlefieldWithInfo(card, game, currentZone, source.getSourceId());
|
||||
Effect effect = new AttachEffect(Outcome.AddAbility);
|
||||
effect.setTargetPointer(new FixedTarget(card.getId()));
|
||||
effect.apply(game, source);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@ import mage.abilities.LoyaltyAbility;
|
|||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
|
||||
import mage.abilities.effects.common.continuous.BoostTargetEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.cards.Card;
|
||||
|
@ -65,7 +64,6 @@ import mage.target.common.TargetOpponent;
|
|||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
|
@ -78,11 +76,10 @@ public class JaceArchitectOfThought extends CardImpl {
|
|||
this.expansionSetCode = "RTR";
|
||||
this.subtype.add("Jace");
|
||||
|
||||
|
||||
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.LOYALTY.createInstance(4)), false));
|
||||
|
||||
// +1: Until your next turn, whenever a creature an opponent controls attacks, it gets -1/-0 until end of turn.
|
||||
this.addAbility(new LoyaltyAbility(new CreateDelayedTriggeredAbilityEffect(new JaceArchitectOfThoughtDelayedTriggeredAbility()),1));
|
||||
this.addAbility(new LoyaltyAbility(new JaceArchitectOfThoughtStartEffect1(), 1));
|
||||
|
||||
// -2: Reveal the top three cards of your library. An opponent separates those cards into two piles. Put one pile into your hand and the other on the bottom of your library in any order.
|
||||
this.addAbility(new LoyaltyAbility(new JaceArchitectOfThoughtEffect2(), -2));
|
||||
|
@ -102,16 +99,45 @@ public class JaceArchitectOfThought extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class JaceArchitectOfThoughtStartEffect1 extends OneShotEffect {
|
||||
|
||||
public JaceArchitectOfThoughtStartEffect1() {
|
||||
super(Outcome.UnboostCreature);
|
||||
this.staticText = "Until your next turn, whenever a creature an opponent controls attacks, it gets -1/-0 until end of turn";
|
||||
}
|
||||
|
||||
public JaceArchitectOfThoughtStartEffect1(final JaceArchitectOfThoughtStartEffect1 effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JaceArchitectOfThoughtStartEffect1 copy() {
|
||||
return new JaceArchitectOfThoughtStartEffect1(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
DelayedTriggeredAbility delayedAbility = new JaceArchitectOfThoughtDelayedTriggeredAbility(game.getTurnNum());
|
||||
delayedAbility.setSourceId(source.getSourceId());
|
||||
delayedAbility.setControllerId(source.getControllerId());
|
||||
delayedAbility.setSourceObject(source.getSourceObject(game), game);
|
||||
game.addDelayedTriggeredAbility(delayedAbility);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class JaceArchitectOfThoughtDelayedTriggeredAbility extends DelayedTriggeredAbility {
|
||||
|
||||
private int startingTurn;
|
||||
|
||||
public JaceArchitectOfThoughtDelayedTriggeredAbility() {
|
||||
super(new BoostTargetEffect(-1,0, Duration.EndOfTurn), Duration.Custom, false);
|
||||
|
||||
public JaceArchitectOfThoughtDelayedTriggeredAbility(int startingTurn) {
|
||||
super(new BoostTargetEffect(-1, 0, Duration.EndOfTurn), Duration.Custom, false);
|
||||
this.startingTurn = startingTurn;
|
||||
}
|
||||
|
||||
public JaceArchitectOfThoughtDelayedTriggeredAbility(JaceArchitectOfThoughtDelayedTriggeredAbility ability) {
|
||||
public JaceArchitectOfThoughtDelayedTriggeredAbility(final JaceArchitectOfThoughtDelayedTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.startingTurn = ability.startingTurn;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -135,12 +161,6 @@ class JaceArchitectOfThoughtDelayedTriggeredAbility extends DelayedTriggeredAbil
|
|||
return new JaceArchitectOfThoughtDelayedTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Game game) {
|
||||
startingTurn = game.getTurnNum();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isInactive(Game game) {
|
||||
return game.getActivePlayerId().equals(getControllerId()) && game.getTurnNum() != startingTurn;
|
||||
|
@ -195,10 +215,10 @@ class JaceArchitectOfThoughtEffect2 extends OneShotEffect {
|
|||
opponent = game.getPlayer(targetOpponent.getFirstTarget());
|
||||
}
|
||||
}
|
||||
if (opponent == null) {
|
||||
if (opponent == null) {
|
||||
opponent = game.getPlayer(opponents.iterator().next());
|
||||
}
|
||||
|
||||
|
||||
TargetCard target = new TargetCard(0, cards.size(), Zone.PICK, new FilterCard("cards to put in the first pile"));
|
||||
target.setRequired(false);
|
||||
Cards pile1 = new CardsImpl();
|
||||
|
@ -213,27 +233,27 @@ class JaceArchitectOfThoughtEffect2 extends OneShotEffect {
|
|||
}
|
||||
player.revealCards("Pile 1 (Jace, Architect of Thought)", pile1, game);
|
||||
player.revealCards("Pile 2 (Jace, Architect of Thought)", cards, game);
|
||||
|
||||
|
||||
postPileToLog("Pile 1", pile1.getCards(game), game);
|
||||
postPileToLog("Pile 2", cards.getCards(game), game);
|
||||
|
||||
|
||||
Cards cardsToHand = cards;
|
||||
Cards cardsToLibrary = pile1;
|
||||
List<Card> cardPile1 = new ArrayList<>();
|
||||
List<Card> cardPile2 = new ArrayList<>();
|
||||
for (UUID cardId: pile1) {
|
||||
for (UUID cardId : pile1) {
|
||||
cardPile1.add(game.getCard(cardId));
|
||||
}
|
||||
for (UUID cardId: cards) {
|
||||
for (UUID cardId : cards) {
|
||||
cardPile2.add(game.getCard(cardId));
|
||||
}
|
||||
|
||||
boolean pileChoice = player.choosePile(Outcome.Neutral, "Choose a pile to to put into your hand.", cardPile1, cardPile2, game);
|
||||
if (pileChoice){
|
||||
if (pileChoice) {
|
||||
cardsToHand = pile1;
|
||||
cardsToLibrary = cards;
|
||||
}
|
||||
game.informPlayers(player.getLogName() +" chose pile" + (pileChoice?"1":"2"));
|
||||
game.informPlayers(player.getLogName() + " chose pile" + (pileChoice ? "1" : "2"));
|
||||
|
||||
for (UUID cardUuid : cardsToHand) {
|
||||
Card card = cardsToHand.get(cardUuid, game);
|
||||
|
@ -260,11 +280,11 @@ class JaceArchitectOfThoughtEffect2 extends OneShotEffect {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void postPileToLog(String pileName, Set<Card> cards, Game game) {
|
||||
StringBuilder message = new StringBuilder(pileName).append(": ");
|
||||
for (Card card : cards) {
|
||||
message.append(card.getName()).append(" ");
|
||||
message.append(card.getName()).append(" ");
|
||||
}
|
||||
if (cards.isEmpty()) {
|
||||
message.append(" (empty)");
|
||||
|
@ -320,15 +340,14 @@ class JaceArchitectOfThoughtEffect3 extends OneShotEffect {
|
|||
FilterCard filter = new FilterCard("card to cast without mana costs");
|
||||
TargetCardInExile target = new TargetCardInExile(filter, source.getSourceId());
|
||||
while (jaceExileZone.count(filter, game) > 0 && controller.choose(Outcome.PlayForFree, jaceExileZone, target, game)) {
|
||||
Card card = game.getCard(target.getFirstTarget());
|
||||
if (card != null) {
|
||||
Card card = game.getCard(target.getFirstTarget());
|
||||
if (card != null) {
|
||||
|
||||
if (controller.cast(card.getSpellAbility(), game, true))
|
||||
{
|
||||
game.getExile().removeCard(card, game);
|
||||
}
|
||||
if (controller.cast(card.getSpellAbility(), game, true)) {
|
||||
game.getExile().removeCard(card, game);
|
||||
}
|
||||
target.clearChosen();
|
||||
}
|
||||
target.clearChosen();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -73,7 +73,7 @@ public class MarchesaTheBlackRose extends CardImpl {
|
|||
|
||||
// Dethrone
|
||||
this.addAbility(new DethroneAbility());
|
||||
|
||||
|
||||
// Other creatures you control have dethrone.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
|
||||
new GainAbilityControlledEffect(new DethroneAbility(), Duration.WhileOnBattlefield, new FilterCreaturePermanent(), true)));
|
||||
|
@ -118,11 +118,11 @@ class MarchesaTheBlackRoseTriggeredAbility extends TriggeredAbilityImpl {
|
|||
if (((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD
|
||||
&& ((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD) {
|
||||
Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
|
||||
if (permanent != null &&
|
||||
permanent.getControllerId().equals(this.getControllerId())
|
||||
if (permanent != null
|
||||
&& permanent.getControllerId().equals(this.getControllerId())
|
||||
&& permanent.getCardType().contains(CardType.CREATURE)
|
||||
&& permanent.getCounters().getCount(CounterType.P1P1) > 0) {
|
||||
for (Effect effect: this.getEffects()) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(permanent.getId()));
|
||||
}
|
||||
return true;
|
||||
|
@ -155,7 +155,7 @@ class MarchesaTheBlackRoseEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Card card = game.getCard(this.getTargetPointer().getFirst(game, source));
|
||||
Card card = game.getCard(getTargetPointer().getFirst(game, source));
|
||||
if (card != null) {
|
||||
Effect effect = new ReturnToBattlefieldUnderYourControlTargetEffect();
|
||||
effect.setText("return that card to the battlefield under your control at the beginning of the next end step");
|
||||
|
@ -163,7 +163,7 @@ class MarchesaTheBlackRoseEffect extends OneShotEffect {
|
|||
delayedAbility.setSourceId(source.getSourceId());
|
||||
delayedAbility.setControllerId(source.getControllerId());
|
||||
delayedAbility.setSourceObject(source.getSourceObject(game), game);
|
||||
delayedAbility.getEffects().get(0).setTargetPointer(new FixedTarget(card.getId()));
|
||||
delayedAbility.getEffects().get(0).setTargetPointer(getTargetPointer());
|
||||
game.addDelayedTriggeredAbility(delayedAbility);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* 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.AI.basic;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBaseAI;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class CastAlternateCastingCostsTest extends CardTestPlayerBaseAI {
|
||||
|
||||
/**
|
||||
* Tests that if a spell has alternate casting costs, this option is also calculated
|
||||
*/
|
||||
@Test
|
||||
@Ignore // AI only gets the cast ability yet, but does always say yes to use evoke
|
||||
// TODO: Get the AI both options to calculate
|
||||
public void testEvoke() {
|
||||
// Flying
|
||||
// When Mulldrifter enters the battlefield, draw two cards.
|
||||
// Evoke (You may cast this spell for its evoke cost. If you do, it's sacrificed when it enters the battlefield.)
|
||||
addCard(Zone.HAND, playerA, "Mulldrifter");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Island", 5);
|
||||
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertPermanentCount(playerA, "Mulldrifter", 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -38,22 +38,22 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
|
|||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class ScytheOfTheWretchedTest extends CardTestPlayerBase {
|
||||
|
||||
/**
|
||||
* Test that the creature taht died returns to battlefield under your control
|
||||
* if the previous equiped creature does not die
|
||||
* Test that the creature that died returns to battlefield under your
|
||||
* control if the previous equipped creature does not die
|
||||
*/
|
||||
@Test
|
||||
public void testEquipAlive() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Soulmender", 1);
|
||||
// {T}: You gain 1 life.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Soulmender", 1); // 1/1
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Plains", 4);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
|
||||
// Equipped creature gets +2/+2.
|
||||
// Whenever a creature dealt damage by equipped creature this turn dies, return that card to the battlefield under your control. Attach Scythe of the Wretched to that creature.
|
||||
// Equip {4}
|
||||
// Equip {4}
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Scythe of the Wretched");
|
||||
|
||||
activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Equip {4}", "Silvercoat Lion");
|
||||
|
@ -66,29 +66,31 @@ public class ScytheOfTheWretchedTest extends CardTestPlayerBase {
|
|||
|
||||
assertLife(playerA, 20);
|
||||
assertLife(playerB, 20);
|
||||
|
||||
|
||||
assertPermanentCount(playerA, "Soulmender", 0);
|
||||
assertPermanentCount(playerB, "Soulmender", 1);
|
||||
assertPowerToughness(playerB, "Soulmender", 3, 3);
|
||||
|
||||
|
||||
assertPowerToughness(playerB, "Silvercoat Lion", 2, 2);
|
||||
|
||||
Permanent silvercoatLion = getPermanent("Silvercoat Lion", playerB.getId());
|
||||
Assert.assertTrue("Silvercoat Lion may not have any attachments", silvercoatLion.getAttachments().isEmpty());
|
||||
}
|
||||
/**
|
||||
* Test that the creature that died returns to battlefield under your control
|
||||
* if the previous equiped creature does die after equipment is removed
|
||||
|
||||
/**
|
||||
* Test that the creature that died returns to battlefield under your
|
||||
* control if the previous equiped creature does die after equipment is
|
||||
* removed
|
||||
*/
|
||||
@Test
|
||||
public void testEquipDied() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Oreskos Swiftclaw", 1); // 3/1
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Oreskos Swiftclaw", 1); // 3/1
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Plains", 4);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
|
||||
// Equipped creature gets +2/+2.
|
||||
// Whenever a creature dealt damage by equipped creature this turn dies, return that card to the battlefield under your control. Attach Scythe of the Wretched to that creature.
|
||||
// Equip {4}
|
||||
// Equip {4}
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Scythe of the Wretched");
|
||||
|
||||
activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Equip {4}", "Silvercoat Lion");
|
||||
|
@ -101,27 +103,27 @@ public class ScytheOfTheWretchedTest extends CardTestPlayerBase {
|
|||
|
||||
assertLife(playerA, 20);
|
||||
assertLife(playerB, 20);
|
||||
|
||||
|
||||
assertPermanentCount(playerA, "Oreskos Swiftclaw", 0);
|
||||
assertPermanentCount(playerB, "Oreskos Swiftclaw", 1);
|
||||
assertPowerToughness(playerB, "Oreskos Swiftclaw", 5, 3);
|
||||
|
||||
|
||||
assertGraveyardCount(playerB, "Silvercoat Lion", 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the creature that died returns to battlefield under your control
|
||||
* if the previous equiped creature does die already in combat
|
||||
|
||||
/**
|
||||
* Test that the creature that died returns to battlefield under your
|
||||
* control if the previous equiped creature does die already in combat
|
||||
*/
|
||||
@Test
|
||||
public void testEquipDiedInCombat() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Serra Angel", 1); // 4/4
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Plains", 4);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
|
||||
// Equipped creature gets +2/+2.
|
||||
// Whenever a creature dealt damage by equipped creature this turn dies, return that card to the battlefield under your control. Attach Scythe of the Wretched to that creature.
|
||||
// Equip {4}
|
||||
// Equip {4}
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Scythe of the Wretched");
|
||||
|
||||
activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Equip {4}", "Silvercoat Lion");
|
||||
|
@ -134,18 +136,18 @@ public class ScytheOfTheWretchedTest extends CardTestPlayerBase {
|
|||
|
||||
assertLife(playerA, 20);
|
||||
assertLife(playerB, 20);
|
||||
|
||||
|
||||
assertPermanentCount(playerA, "Serra Angel", 0);
|
||||
assertPermanentCount(playerB, "Serra Angel", 1);
|
||||
assertPowerToughness(playerB, "Serra Angel", 6, 6);
|
||||
|
||||
|
||||
assertGraveyardCount(playerB, "Silvercoat Lion", 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test that the creature that died returns to battlefield under your control
|
||||
* if the previous equiped creature does die already in combat and the equipment was destroyed meanwhile
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the creature that died returns to battlefield under your
|
||||
* control if the previous equiped creature does die already in combat and
|
||||
* the equipment was destroyed meanwhile
|
||||
*/
|
||||
@Test
|
||||
public void testEquipDiedInCombat2() {
|
||||
|
@ -154,17 +156,17 @@ public class ScytheOfTheWretchedTest extends CardTestPlayerBase {
|
|||
addCard(Zone.HAND, playerA, "Disenchant", 1);
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Plains", 4);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
|
||||
// Equipped creature gets +2/+2.
|
||||
// Whenever a creature dealt damage by equipped creature this turn dies, return that card to the battlefield under your control. Attach Scythe of the Wretched to that creature.
|
||||
// Equip {4}
|
||||
// Equip {4}
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Scythe of the Wretched");
|
||||
|
||||
activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Equip {4}", "Silvercoat Lion");
|
||||
|
||||
attack(2, playerB, "Silvercoat Lion");
|
||||
block(2, playerA, "Serra Angel", "Silvercoat Lion");
|
||||
|
||||
|
||||
castSpell(2, PhaseStep.COMBAT_DAMAGE, playerA, "Disenchant", "Scythe of the Wretched", "Whenever a creature dealt damage");
|
||||
|
||||
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
|
||||
|
@ -172,14 +174,14 @@ public class ScytheOfTheWretchedTest extends CardTestPlayerBase {
|
|||
|
||||
assertLife(playerA, 20);
|
||||
assertLife(playerB, 20);
|
||||
|
||||
|
||||
assertGraveyardCount(playerA, "Disenchant", 1);
|
||||
assertGraveyardCount(playerB, "Scythe of the Wretched", 1);
|
||||
|
||||
|
||||
assertPermanentCount(playerA, "Serra Angel", 0);
|
||||
assertPermanentCount(playerB, "Serra Angel", 1);
|
||||
assertPowerToughness(playerB, "Serra Angel", 4, 4);
|
||||
|
||||
|
||||
assertGraveyardCount(playerB, "Silvercoat Lion", 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,18 +8,21 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
|
|||
|
||||
/**
|
||||
*
|
||||
* also tests regenerate and
|
||||
* tests that permanents with protection can be sacrificed
|
||||
*
|
||||
* also tests regenerate and tests that permanents with protection can be
|
||||
* sacrificed
|
||||
*
|
||||
* @author BetaSteward
|
||||
*/
|
||||
public class SpitefulShadowsTest extends CardTestPlayerBase {
|
||||
|
||||
@Test
|
||||
public void testCard() {
|
||||
// Infect (This creature deals damage to creatures in the form of -1/-1 counters and to players in the form of poison counters.)
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Glistener Elf");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
|
||||
// Enchant creature
|
||||
// Whenever enchanted creature is dealt damage, it deals that much damage to its controller.
|
||||
addCard(Zone.HAND, playerA, "Spiteful Shadows");
|
||||
addCard(Zone.HAND, playerA, "Lightning Bolt");
|
||||
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* 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.mana;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class EmptyOnlyOnTurnsEndManaTest extends CardTestPlayerBase {
|
||||
|
||||
@Test
|
||||
public void testDaxosOfMeletis() {
|
||||
// At the beginning of each player's upkeep, that player adds {G}{G}{G} to his or her mana pool. Until end of turn, this mana doesn't empty from that player's mana pool as steps and phases end.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Shizuko, Caller of Autumn", 1);
|
||||
addCard(Zone.HAND, playerA, "Birds of Paradise", 1);
|
||||
|
||||
addCard(Zone.HAND, playerB, "Birds of Paradise", 1);
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Birds of Paradise");
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Birds of Paradise");
|
||||
|
||||
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
assertPermanentCount(playerA, "Birds of Paradise", 1);
|
||||
assertPermanentCount(playerB, "Birds of Paradise", 1);
|
||||
|
||||
Assert.assertEquals("2 {G} have to be still im Mana Pool", "{G}{G}", playerB.getManaPool().getMana().toString());
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -25,7 +25,6 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package org.mage.test.cards.single.rtr;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
|
@ -35,36 +34,32 @@ import org.junit.Test;
|
|||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
* Jace, Architect of Thought {2}{U}{U}
|
||||
* Planeswalker — Jace
|
||||
* Loyalty 4
|
||||
* +1: Until your next turn, whenever a creature an opponent controls attacks, it gets
|
||||
* -1/-0 until end of turn.
|
||||
* -2: Reveal the top three cards of your library. An opponent separates those cards into
|
||||
* two piles. Put one pile into your hand and the other on the bottom of your library
|
||||
* in any order.
|
||||
* -8: For each player, search that player's library for a nonland card and exile it, then
|
||||
* that player shuffles his or her library. You may cast those cards without paying
|
||||
* their mana costs.
|
||||
*
|
||||
* Jace, Architect of Thought {2}{U}{U} Planeswalker — Jace Loyalty 4 +1: Until
|
||||
* your next turn, whenever a creature an opponent controls attacks, it gets
|
||||
* -1/-0 until end of turn. -2: Reveal the top three cards of your library. An
|
||||
* opponent separates those cards into two piles. Put one pile into your hand
|
||||
* and the other on the bottom of your library in any order. -8: For each
|
||||
* player, search that player's library for a nonland card and exile it, then
|
||||
* that player shuffles his or her library. You may cast those cards without
|
||||
* paying their mana costs.
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class JaceArchitectOfThoughtTest extends CardTestPlayerBase {
|
||||
|
||||
@Test
|
||||
public void testAbility1normal() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Jace, Architect of Thought");
|
||||
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion", 1);
|
||||
|
||||
|
||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "+1: Until your next turn, whenever a creature an opponent controls attacks, it gets -1/-0 until end of turn.");
|
||||
|
||||
attack(2, playerB, "Silvercoat Lion");
|
||||
|
||||
|
||||
setStopAt(2, PhaseStep.END_COMBAT);
|
||||
execute();
|
||||
|
||||
|
||||
assertCounterCount("Jace, Architect of Thought", CounterType.LOYALTY, 5);
|
||||
assertPowerToughness(playerB, "Silvercoat Lion", 1, 2);
|
||||
|
||||
|
@ -72,53 +67,56 @@ public class JaceArchitectOfThoughtTest extends CardTestPlayerBase {
|
|||
assertLife(playerB, 20);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAbilit1lastOnlyUntilNextTurn() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Jace, Architect of Thought");
|
||||
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion", 1);
|
||||
|
||||
|
||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "+1: Until your next turn, whenever a creature an opponent controls attacks, it gets -1/-0 until end of turn.");
|
||||
|
||||
attack(2, playerB, "Silvercoat Lion");
|
||||
attack(4, playerB, "Silvercoat Lion");
|
||||
|
||||
|
||||
setStopAt(4, PhaseStep.END_COMBAT);
|
||||
execute();
|
||||
|
||||
|
||||
assertCounterCount("Jace, Architect of Thought", CounterType.LOYALTY, 5);
|
||||
assertPowerToughness(playerB, "Silvercoat Lion", 2, 2);
|
||||
|
||||
assertLife(playerA, 17);
|
||||
assertLife(playerB, 20);
|
||||
|
||||
}
|
||||
}
|
||||
/*
|
||||
Ability 1 has still to trigger next turn if used also if Jace left the battlefield.
|
||||
*/
|
||||
Ability 1 has still to trigger next turn if used also if Jace left the battlefield.
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void testAbility1AfterJacesWasExiled() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Jace, Architect of Thought");
|
||||
|
||||
|
||||
// Sorcery {R}{B}
|
||||
// Destroy target creature or planeswalker.
|
||||
addCard(Zone.HAND, playerB, "Dreadbore");
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Mountain");
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Swamp");
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion", 1);
|
||||
|
||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "+1: Until your next turn, whenever a creature an opponent controls attacks, it gets -1/-0 until end of turn.");
|
||||
|
||||
|
||||
// +1: Until your next turn, whenever a creature an opponent controls attacks, it gets -1/-0 until end of turn.
|
||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "+1: Until your next turn");
|
||||
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Dreadbore", "Jace, Architect of Thought");
|
||||
attack(2, playerB, "Silvercoat Lion");
|
||||
|
||||
|
||||
setStopAt(2, PhaseStep.END_COMBAT);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 19);
|
||||
assertLife(playerB, 20);
|
||||
|
||||
assertPermanentCount(playerB, "Jace, Architect of Thought", 0);
|
||||
|
||||
assertPermanentCount(playerA, "Jace, Architect of Thought", 0);
|
||||
assertPowerToughness(playerB, "Silvercoat Lion", 1, 2);
|
||||
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
|
|||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class ReturnToBattlefieldEffectsTest extends CardTestPlayerBase {
|
||||
|
||||
@Test
|
||||
|
@ -82,9 +81,10 @@ public class ReturnToBattlefieldEffectsTest extends CardTestPlayerBase {
|
|||
assertGraveyardCount(playerB, "Lightning Bolt", 1);
|
||||
assertPermanentCount(playerA, "Arcbound Worker", 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* That that the creature with a +1/+1 counter does not return
|
||||
* if the card was removed from graveyard meanwhile
|
||||
* Test that the creature with a +1/+1 counter does not return if the card
|
||||
* was removed from graveyard meanwhile by Relic of Progenitus
|
||||
*/
|
||||
@Test
|
||||
public void testMarchesatheBlackRoseAfterExile() {
|
||||
|
@ -100,10 +100,10 @@ public class ReturnToBattlefieldEffectsTest extends CardTestPlayerBase {
|
|||
// {T}: Target player exiles a card from his or her graveyard.
|
||||
// {1}, Exile Relic of Progenitus: Exile all cards from all graveyards. Draw a card.
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Relic of Progenitus", 1);
|
||||
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Arcbound Worker");
|
||||
castSpell(1, PhaseStep.END_COMBAT, playerB, "Lightning Bolt", "Arcbound Worker");
|
||||
|
||||
|
||||
activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "{T}: Target player exiles", playerA);
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
|
@ -113,13 +113,15 @@ public class ReturnToBattlefieldEffectsTest extends CardTestPlayerBase {
|
|||
assertPermanentCount(playerA, "Arcbound Worker", 0);
|
||||
|
||||
assertExileCount("Arcbound Worker", 1);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* With my opponent's Deathmist Raptor return-to-battlefield trigger on the stack,
|
||||
* I exiled the Deathmist Raptor with Pharika, God of Affliction. However, the Deathmist Raptor
|
||||
* returned to the battlefield from exile, though it should not have because it had
|
||||
* changed zones so was a different object.
|
||||
* With my opponent's Deathmist Raptor return-to-battlefield trigger on the
|
||||
* stack, I exiled the Deathmist Raptor with Pharika, God of Affliction.
|
||||
* However, the Deathmist Raptor returned to the battlefield from exile,
|
||||
* though it should not have because it had changed zones so was a different
|
||||
* object.
|
||||
*/
|
||||
@Test
|
||||
public void testDeathmistRaptor() {
|
||||
|
@ -129,20 +131,20 @@ public class ReturnToBattlefieldEffectsTest extends CardTestPlayerBase {
|
|||
addCard(Zone.GRAVEYARD, playerA, "Deathmist Raptor");
|
||||
addCard(Zone.HAND, playerA, "Pine Walker");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Forest", 5);
|
||||
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Forest", 1);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Swamp", 1);
|
||||
// {B}{G}: Exile target creature card from a graveyard. It's owner puts a 1/1 black and green Snake enchantment creature token with deathtouch onto the battlefield.
|
||||
// {B}{G}: Exile target creature card from a graveyard. It's owner puts a 1/1 black and green Snake enchantment creature token with deathtouch onto the battlefield.
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Pharika, God of Affliction", 1);
|
||||
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Pine Walker");
|
||||
setChoice(playerA, "Yes"); // cast it face down as 2/2 creature
|
||||
|
||||
activateAbility(3, PhaseStep.POSTCOMBAT_MAIN, playerA, "{4}{G}: Turn this face-down permanent face up.");
|
||||
activateAbility(3, PhaseStep.POSTCOMBAT_MAIN, playerB, "{B}{G}: Exile target creature card from a graveyard",
|
||||
activateAbility(3, PhaseStep.POSTCOMBAT_MAIN, playerA, "{4}{G}: Turn this face-down permanent face up.");
|
||||
activateAbility(3, PhaseStep.POSTCOMBAT_MAIN, playerB, "{B}{G}: Exile target creature card from a graveyard",
|
||||
"Deathmist Raptor", "Whenever a permanent you control is turned face up");
|
||||
|
||||
setStopAt(3, PhaseStep.END_TURN);
|
||||
|
||||
setStopAt(3, PhaseStep.END_TURN);
|
||||
|
||||
execute();
|
||||
assertPermanentCount(playerB, "Pharika, God of Affliction", 1);
|
||||
|
@ -150,6 +152,37 @@ public class ReturnToBattlefieldEffectsTest extends CardTestPlayerBase {
|
|||
assertPermanentCount(playerA, "Pine Walker", 1);
|
||||
|
||||
assertExileCount("Deathmist Raptor", 1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reassembling Skeleton is blocked by Necroskitter, and dies. Necroskitter
|
||||
* triggers. With the trigger on the stack, activate Skeleton and return it
|
||||
* to play. Expected result: trigger can't find Skeleton since it changed
|
||||
* zones. Actual result: trigger steals control of Skeleton when it's
|
||||
* already on the battlefield.
|
||||
*/
|
||||
@Test
|
||||
public void testNecroskitter1() {
|
||||
// Wither (This deals damage to creatures in the form of -1/-1 counters.)
|
||||
// Whenever a creature an opponent controls with a -1/-1 counter on it dies, you may return that card to the battlefield under your control.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Necroskitter", 1); // 1/4
|
||||
|
||||
// {1}{B}: Return Reassembling Skeleton from your graveyard to the battlefield tapped.
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Reassembling Skeleton");
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Swamp", 2);
|
||||
|
||||
attack(2, playerB, "Reassembling Skeleton");
|
||||
block(2, playerA, "Necroskitter", "Reassembling Skeleton");
|
||||
|
||||
activateAbility(2, PhaseStep.COMBAT_DAMAGE, playerB, "{1}{B}: Return", NO_TARGET, "Whenever a creature");
|
||||
|
||||
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
|
||||
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 20);
|
||||
assertPermanentCount(playerB, "Reassembling Skeleton", 1);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* 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
|
||||
|
@ -20,18 +20,16 @@
|
|||
* 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 mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.constants.Outcome;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
@ -69,8 +67,7 @@ public class AttachEffect extends OneShotEffect {
|
|||
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
if (permanent != null) {
|
||||
return permanent.addAttachment(source.getSourceId(), game);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
|
||||
if (player != null) {
|
||||
return player.addAttachment(source.getSourceId(), game);
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* 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
|
||||
|
@ -20,26 +20,22 @@
|
|||
* 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 mage.abilities.effects.common;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.ExileZone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
|
@ -49,14 +45,15 @@ import mage.util.CardUtil;
|
|||
public class ReturnToBattlefieldUnderYourControlTargetEffect extends OneShotEffect {
|
||||
|
||||
private boolean fromExileZone;
|
||||
|
||||
|
||||
public ReturnToBattlefieldUnderYourControlTargetEffect() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fromExileZone - the card will only be returned if it's still in the source object specific exile zone
|
||||
*
|
||||
* @param fromExileZone - the card will only be returned if it's still in
|
||||
* the source object specific exile zone
|
||||
*/
|
||||
public ReturnToBattlefieldUnderYourControlTargetEffect(boolean fromExileZone) {
|
||||
super(Outcome.Benefit);
|
||||
|
@ -77,29 +74,18 @@ public class ReturnToBattlefieldUnderYourControlTargetEffect extends OneShotEffe
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Card card = null;
|
||||
if (controller != null) {
|
||||
Card card = null;
|
||||
if (fromExileZone) {
|
||||
UUID exilZoneId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
|
||||
if (exilZoneId != null) {
|
||||
ExileZone exileZone = game.getExile().getExileZone(exilZoneId);
|
||||
if (exileZone != null && getTargetPointer().getFirst(game, source) != null) {
|
||||
card = exileZone.get(getTargetPointer().getFirst(game, source), game);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
UUID cardId = targetPointer.getFirst(game, source);
|
||||
if(targetPointer instanceof FixedTarget) {
|
||||
UUID fixedTargetCardId = ((FixedTarget) targetPointer).getTarget();
|
||||
//Moved zones from battlefield to graveyard
|
||||
if(fixedTargetCardId != null && cardId == null) {
|
||||
Permanent permanent = game.getPermanentOrLKIBattlefield(fixedTargetCardId);
|
||||
if(permanent != null) {
|
||||
cardId = fixedTargetCardId;
|
||||
}
|
||||
}
|
||||
}
|
||||
card = game.getCard(cardId);
|
||||
card = game.getCard(getTargetPointer().getFirst(game, source));
|
||||
}
|
||||
if (card != null) {
|
||||
Zone currentZone = game.getState().getZone(card.getId());
|
||||
|
|
|
@ -1401,6 +1401,9 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
} else {
|
||||
TriggeredAbility newAbility = ability.copy();
|
||||
newAbility.newId();
|
||||
for (Effect effect : newAbility.getEffects()) {
|
||||
effect.getTargetPointer().init(this, newAbility);
|
||||
}
|
||||
state.addTriggeredAbility(newAbility);
|
||||
}
|
||||
}
|
||||
|
@ -1409,7 +1412,9 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
public UUID addDelayedTriggeredAbility(DelayedTriggeredAbility delayedAbility) {
|
||||
DelayedTriggeredAbility newAbility = delayedAbility.copy();
|
||||
newAbility.newId();
|
||||
newAbility.init(this);
|
||||
// ability.init is called as the ability triggeres not now.
|
||||
// If a FixedTarget pointer is already set from the effect setting up this delayed ability
|
||||
// it has to be already initialized so it won't be overwitten as the ability triggers
|
||||
state.addDelayedTriggeredAbility(newAbility);
|
||||
return newAbility.getId();
|
||||
}
|
||||
|
|
|
@ -1,31 +1,52 @@
|
|||
package mage.target.targetpointer;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.cards.Card;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.cards.Card;
|
||||
import mage.game.Game;
|
||||
|
||||
public class FixedTarget implements TargetPointer {
|
||||
private final UUID target;
|
||||
|
||||
private final UUID targetId;
|
||||
private int zoneChangeCounter;
|
||||
private boolean initialized;
|
||||
|
||||
public FixedTarget(UUID target) {
|
||||
this.target = target;
|
||||
this.targetId = target;
|
||||
this.initialized = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this if you already want to fix the target object to the known zone
|
||||
* now (otherwise the zone will be set if the ability triggers or not at
|
||||
* all) If not initialized, the object of the current zone then will be
|
||||
* used.
|
||||
*
|
||||
* @param targetId
|
||||
* @param zoneChangeCounter
|
||||
*/
|
||||
public FixedTarget(UUID targetId, int zoneChangeCounter) {
|
||||
this.targetId = targetId;
|
||||
this.initialized = true;
|
||||
this.zoneChangeCounter = zoneChangeCounter;
|
||||
}
|
||||
|
||||
public FixedTarget(final FixedTarget fixedTarget) {
|
||||
this.target = fixedTarget.target;
|
||||
this.targetId = fixedTarget.targetId;
|
||||
this.zoneChangeCounter = fixedTarget.zoneChangeCounter;
|
||||
this.initialized = fixedTarget.initialized;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Game game, Ability source) {
|
||||
Card card = game.getCard(target);
|
||||
if (card != null) {
|
||||
this.zoneChangeCounter = card.getZoneChangeCounter(game);
|
||||
if (!initialized) {
|
||||
initialized = true;
|
||||
Card card = game.getCard(targetId);
|
||||
if (card != null) {
|
||||
this.zoneChangeCounter = card.getZoneChangeCounter(game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,14 +54,14 @@ public class FixedTarget implements TargetPointer {
|
|||
public List<UUID> getTargets(Game game, Ability source) {
|
||||
// check target not changed zone
|
||||
if (this.zoneChangeCounter > 0) { // will be zero if not defined in init
|
||||
Card card = game.getCard(target);
|
||||
Card card = game.getCard(targetId);
|
||||
if (card != null && card.getZoneChangeCounter(game) != this.zoneChangeCounter) {
|
||||
return new ArrayList<>(); // return empty
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<UUID> list = new ArrayList<>(1);
|
||||
list.add(target);
|
||||
list.add(targetId);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -48,26 +69,26 @@ public class FixedTarget implements TargetPointer {
|
|||
public UUID getFirst(Game game, Ability source) {
|
||||
// check target not changed zone
|
||||
if (this.zoneChangeCounter > 0) { // will be zero if not defined in init
|
||||
Card card = game.getCard(target);
|
||||
Card card = game.getCard(targetId);
|
||||
if (card != null && card.getZoneChangeCounter(game) != this.zoneChangeCounter) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
return targetId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetPointer copy() {
|
||||
return new FixedTarget(this);
|
||||
}
|
||||
|
||||
|
||||
public UUID getTarget() {
|
||||
return target;
|
||||
return targetId;
|
||||
}
|
||||
|
||||
public int getZoneChangeCounter() {
|
||||
return zoneChangeCounter;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue