* JumpStart - fixed that card was not always moved to exile after cast from graveyard.

This commit is contained in:
LevelX2 2018-09-26 16:30:17 +02:00
parent fa7ae3ee35
commit 61b1b1ba05
4 changed files with 103 additions and 5 deletions

View file

@ -0,0 +1,71 @@
package org.mage.test.cards.abilities.keywords;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* Jump-start is found on instants and sorceries. You can cast a card with
* jump-start from your graveyard by paying all its regular costs and one
* additional cost: discarding a card from your hand.
*
* @author LevelX2
*/
public class JumpStartTest extends CardTestPlayerBase {
@Test
public void testNormalUse() {
// Direct Current deals 2 damage to any target.
// Jump-start
addCard(Zone.HAND, playerA, "Direct Current", 1); // Sorcery {1}{R}{R}
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 6);
addCard(Zone.HAND, playerA, "Disenchant", 1);
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion", 1); // 2/2
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Direct Current", "Silvercoat Lion");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Direct Current with jump-start", playerB);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerB, "Silvercoat Lion", 1);
assertHandCount(playerA, 0); // 1 from sacrificed Clue and 1 from draw of turn 3
assertExileCount(playerA, "Direct Current", 1);
assertLife(playerA, 20);
assertLife(playerB, 18);
}
@Test
public void testCastFromGraveyardCountered() {
// Direct Current deals 2 damage to any target.
// Jump-start
addCard(Zone.HAND, playerA, "Direct Current", 1); // Sorcery {1}{R}{R}
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 6);
addCard(Zone.HAND, playerA, "Disenchant", 1);
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion", 1); // 2/2
addCard(Zone.HAND, playerB, "Counterspell", 1);
addCard(Zone.BATTLEFIELD, playerB, "Island", 2);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Direct Current", "Silvercoat Lion");
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Direct Current with jump-start", playerB);
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Counterspell", "Direct Current");
setStopAt(1, PhaseStep.END_TURN);
execute();
assertGraveyardCount(playerB, "Silvercoat Lion", 1);
assertGraveyardCount(playerB, "Counterspell", 1);
assertHandCount(playerA, 0); // 1 from sacrificed Clue and 1 from draw of turn 3
assertGraveyardCount(playerA, "Direct Current", 0);
assertExileCount(playerA, "Direct Current", 1);
assertLife(playerA, 20);
assertLife(playerB, 20);
}
}

View file

@ -10,7 +10,7 @@ public class CryptRatsTest extends CardTestPlayerBase {
String cRats = "Crypt Rats";
@Test
public void damageOnlyCreatureAndPlayers(){
public void damageOnlyCreatureAndPlayers() {
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 10);
addCard(Zone.BATTLEFIELD, playerA, cRats, 1);
addCard(Zone.BATTLEFIELD, playerB, "Shivan Dragon", 1);
@ -20,6 +20,7 @@ public class CryptRatsTest extends CardTestPlayerBase {
setChoice(playerA, "X=4");
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertLife(playerA, 16);
assertLife(playerB, 16);
assertGraveyardCount(playerA, cRats, 1);

View file

@ -1,4 +1,3 @@
package mage.abilities.keyword;
import java.util.UUID;
@ -158,7 +157,7 @@ public class FlashbackAbility extends SpellAbility {
}
/**
* Used for split card sin PlayerImpl method:
* Used for split card in PlayerImpl method:
* getOtherUseableActivatedAbilities
*
* @param abilityName

View file

@ -4,6 +4,7 @@ import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.DiscardTargetCost;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.Card;
import mage.constants.Duration;
@ -15,13 +16,25 @@ import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.players.Player;
import mage.target.common.TargetCardInHand;
import mage.target.targetpointer.FixedTarget;
/**
* Jump-start is found on instants and sorceries. You can cast a card with
* jump-start from your graveyard by paying all its regular costs and one
* additional cost: discarding a card from your hand. Casting a spell with
* jump-start follows all the normal timing rules, so sorceries with jump-start
* are still limited to your main phases. A spell with jump-start that was cast
* from your graveyard can still be countered, and if it has targets, it won't
* do anything if all its targets disappear or otherwise become illegal. After a
* spell with jump-start cast from your graveyard resolves, is countered, or
* leaves the stack in any way, it's exiled.
*
* @author TheElk801
*/
public class JumpStartAbility extends SpellAbility {
private boolean replacementEffectAdded = false;
public JumpStartAbility(Card card) {
super(card.getManaCost(), card.getName() + " with jump-start", Zone.GRAVEYARD, SpellAbilityType.BASE_ALTERNATE);
this.getCosts().addAll(card.getSpellAbility().getCosts().copy());
@ -29,7 +42,6 @@ public class JumpStartAbility extends SpellAbility {
cost.setText("");
this.addCost(cost);
this.getEffects().addAll(card.getSpellAbility().getEffects().copy());
this.addEffect(new JumpStartReplacementEffect());
this.getTargets().addAll(card.getSpellAbility().getTargets().copy());
this.spellAbilityType = SpellAbilityType.BASE_ALTERNATE;
this.timing = card.getSpellAbility().getTiming();
@ -38,6 +50,21 @@ public class JumpStartAbility extends SpellAbility {
public JumpStartAbility(final JumpStartAbility ability) {
super(ability);
this.replacementEffectAdded = ability.replacementEffectAdded;
}
@Override
public SpellAbility getSpellAbilityToResolve(Game game) {
Card card = game.getCard(getSourceId());
if (card != null) {
if (!replacementEffectAdded) {
replacementEffectAdded = true;
ContinuousEffect effect = new JumpStartReplacementEffect();
effect.setTargetPointer(new FixedTarget(getSourceId(), game.getState().getZoneChangeCounter(getSourceId())));
game.addEffect(effect, this);
}
}
return this;
}
@Override
@ -105,7 +132,7 @@ class JumpStartReplacementEffect extends ReplacementEffectImpl {
if (event.getTargetId().equals(source.getSourceId())
&& ((ZoneChangeEvent) event).getFromZone() == Zone.STACK
&& ((ZoneChangeEvent) event).getToZone() != Zone.EXILED) {
if (game.getState().getZoneChangeCounter(source.getSourceId()) == source.getSourceObjectZoneChangeCounter()) {
if (game.getState().getZoneChangeCounter(source.getSourceId()) == source.getSourceObjectZoneChangeCounter() + 1) {
return true;
}