* Praetor's Grasp - fixed that it freeze the game after cast;

This commit is contained in:
Oleg Agafonov 2019-07-12 21:49:00 +04:00
parent 9a08ccda95
commit 2197d8ee4a
3 changed files with 40 additions and 15 deletions

View file

@ -1,7 +1,6 @@
package mage.cards.p;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.AsThoughEffectImpl;
@ -9,11 +8,7 @@ import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AsThoughEffectType;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.constants.*;
import mage.game.ExileZone;
import mage.game.Game;
import mage.players.Player;
@ -21,14 +16,15 @@ import mage.target.common.TargetCardInLibrary;
import mage.target.common.TargetOpponent;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author BetaSteward
*/
public final class PraetorsGrasp extends CardImpl {
public PraetorsGrasp(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{1}{B}{B}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{B}{B}");
// Search target opponent's library for a card and exile it face down. Then that player shuffles their library. You may look at and play that card for as long as it remains exiled.
this.getSpellAbility().addEffect(new PraetorsGraspEffect());
@ -120,11 +116,7 @@ class PraetorsGraspPlayEffect extends AsThoughEffectImpl {
if (exileId != null && controller != null) {
ExileZone exileZone = game.getExile().getExileZone(exileId);
if (exileZone != null && exileZone.contains(cardId)) {
if (controller.chooseUse(outcome, "Play the exiled card?", source, game)) {
return true;
}
} else {
discard();
return true;
}
}
}

View file

@ -0,0 +1,34 @@
package org.mage.test.cards.continuous;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author JayDi85
*/
public class PraetorsGraspTest extends CardTestPlayerBase {
@Test
public void test_SimpleCast() {
// Search target opponents library for a card and exile it face down. Then that player shuffles their library.
// You may look at and play that card for as long as it remains exiled.
addCard(Zone.HAND, playerA, "Praetor's Grasp", 1); // {1}{B}{B}
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 3);
addCard(Zone.LIBRARY, playerB, "Mountain", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Praetor's Grasp");
addTarget(playerA, playerB);
addTarget(playerA, "Mountain");
showAvaileableAbilities("after", 1, PhaseStep.POSTCOMBAT_MAIN, playerA);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertGraveyardCount(playerA, "Praetor's Grasp", 1);
}
}

View file

@ -5,7 +5,6 @@ package mage.constants;
* @author North
*/
public enum AsThoughEffectType {
ATTACK,
ATTACK_AS_HASTE,
ACTIVATE_HASTE,
@ -20,7 +19,7 @@ public enum AsThoughEffectType {
BLOCK_FORESTWALK,
DAMAGE_NOT_BLOCKED,
BE_BLOCKED,
PLAY_FROM_NOT_OWN_HAND_ZONE,
PLAY_FROM_NOT_OWN_HAND_ZONE, // do not use dialogs in "applies" method for that type of effect (it calls multiple times)
CAST_AS_INSTANT,
ACTIVATE_AS_INSTANT,
DAMAGE,