mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
fix #12355 (Hypnox)
This commit is contained in:
parent
0c299da2df
commit
c013f4bcfe
2 changed files with 50 additions and 26 deletions
|
|
@ -7,6 +7,7 @@ import mage.abilities.common.LeavesBattlefieldTriggeredAbility;
|
|||
import mage.abilities.condition.common.CastFromHandSourcePermanentCondition;
|
||||
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.ReturnFromExileForSourceEffect;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
|
|
@ -14,7 +15,6 @@ import mage.constants.CardType;
|
|||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.ExileZone;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetOpponent;
|
||||
|
|
@ -48,7 +48,8 @@ public final class Hypnox extends CardImpl {
|
|||
this.addAbility(ability, new CastFromHandWatcher());
|
||||
|
||||
// When Hypnox leaves the battlefield, return the exiled cards to their owner's hand.
|
||||
this.addAbility(new LeavesBattlefieldTriggeredAbility(new HypnoxReturnEffect(), false));
|
||||
this.addAbility(new LeavesBattlefieldTriggeredAbility(new ReturnFromExileForSourceEffect(Zone.HAND)
|
||||
.withText(true, false, false), false));
|
||||
}
|
||||
|
||||
private Hypnox(final Hypnox card) {
|
||||
|
|
@ -90,27 +91,3 @@ class HypnoxExileEffect extends OneShotEffect {
|
|||
return new HypnoxExileEffect(this);
|
||||
}
|
||||
}
|
||||
|
||||
class HypnoxReturnEffect extends OneShotEffect {
|
||||
|
||||
HypnoxReturnEffect() {
|
||||
super(Outcome.ReturnToHand);
|
||||
this.staticText = "return the exiled cards to their owner's hand";
|
||||
}
|
||||
|
||||
private HypnoxReturnEffect(final HypnoxReturnEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HypnoxReturnEffect copy() {
|
||||
return new HypnoxReturnEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
ExileZone exZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source));
|
||||
return controller != null && exZone != null && controller.moveCards(exZone, Zone.HAND, source, game);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
package org.mage.test.cards.single.tor;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
* @author xenohedron
|
||||
*/
|
||||
public class HypnoxTest extends CardTestPlayerBase {
|
||||
|
||||
private static final String hypnox = "Hypnox";
|
||||
/** Hypnox {8}{B}{B}{B}
|
||||
* Flying
|
||||
* When Hypnox enters the battlefield, if you cast it from your hand, exile all cards from target opponent’s hand.
|
||||
* When Hypnox leaves the battlefield, return the exiled cards to their owner’s hand.
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void testExileAndReturn() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 11);
|
||||
addCard(Zone.HAND, playerA, hypnox);
|
||||
addCard(Zone.HAND, playerB, "Shock");
|
||||
addCard(Zone.HAND, playerB, "Watchwolf");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Bloodthrone Vampire");
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, hypnox);
|
||||
addTarget(playerA, playerB);
|
||||
|
||||
checkPT("Hypnox", 1, PhaseStep.BEGIN_COMBAT, playerA, hypnox, 8, 8);
|
||||
checkExileCount("exiled from hand", 1, PhaseStep.BEGIN_COMBAT, playerB, "Shock", 1);
|
||||
checkExileCount("exiled from hand", 1, PhaseStep.BEGIN_COMBAT, playerB, "Watchwolf", 1);
|
||||
|
||||
activateAbility(1, PhaseStep.END_COMBAT, playerA, "Sacrifice");
|
||||
setChoice(playerA, hypnox);
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
assertGraveyardCount(playerA, hypnox, 1);
|
||||
assertHandCount(playerB, "Shock", 1);
|
||||
assertHandCount(playerB, "Watchwolf", 1);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue