Skip to content

Commit

Permalink
* Jace, Unraveler of Secrets - Fixed that the emblem still doesn't co…
Browse files Browse the repository at this point in the history
…unter spells (fixes magefree#1855).
  • Loading branch information
LevelX2 committed Apr 14, 2016
1 parent d00f1ad commit 13d9a56
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/
package mage.sets.shadowsoverinnistrad;

import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.LoyaltyAbility;
Expand All @@ -41,9 +42,12 @@
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.FilterSpell;
import mage.game.Game;
import mage.game.command.Emblem;
import mage.game.events.GameEvent;
import mage.game.stack.Spell;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetpointer.FixedTarget;
import mage.watchers.common.SpellsCastWatcher;
Expand Down Expand Up @@ -106,7 +110,7 @@ public JaceUnravelerOfSecretsEmblem() {
class JaceUnravelerOfSecretsTriggeredAbility extends SpellCastOpponentTriggeredAbility {

public JaceUnravelerOfSecretsTriggeredAbility(Effect effect, boolean optional) {
super(effect, optional);
super(Zone.COMMAND, effect, new FilterSpell(), optional);
}

public JaceUnravelerOfSecretsTriggeredAbility(SpellCastOpponentTriggeredAbility ability) {
Expand All @@ -115,15 +119,16 @@ public JaceUnravelerOfSecretsTriggeredAbility(SpellCastOpponentTriggeredAbility

@Override
public SpellCastOpponentTriggeredAbility copy() {
return super.copy();
return new JaceUnravelerOfSecretsTriggeredAbility(this);
}

@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (super.checkTrigger(event, game)) {
SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getName());
if (watcher != null) {
if (watcher.getSpellsCastThisTurn(event.getPlayerId()) == null) {
List<Spell> spells = watcher.getSpellsCastThisTurn(event.getPlayerId());
if (spells != null && spells.size() == 1) {
for (Effect effect : getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getTargetId()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,36 @@ public void testContainmentPriestWithFlipPlaneswalker() {
assertPermanentCount(playerA, "Jace, Telepath Unbound", 1);

}

/**
* I know it's been a bit a rules question recently but I believe flip
* planeswalkers shouldn't be exiled by Containment priest when flipping as
* happens when using xmage (at least with Jace).
*/
@Test
public void testJaceUnravelerOfSecretsEmblem() {
// +1: Scry 1, then draw a card.
// -2: Return target creature to its owner's hand.
// -8: You get an emblem with "Whenever an opponent casts his or her first spell each turn, counter that spell."
addCard(Zone.BATTLEFIELD, playerA, "Jace, Unraveler of Secrets", 1); // starts with 5 Loyality counters
addCounters(1, PhaseStep.UPKEEP, playerA, "Jace, Unraveler of Secrets", CounterType.LOYALTY, 5);

addCard(Zone.BATTLEFIELD, playerB, "Plains", 2);
addCard(Zone.HAND, playerB, "Perimeter Captain", 2);

activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "-8: You get an emblem");

castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Perimeter Captain");
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Perimeter Captain");

setStopAt(2, PhaseStep.END_TURN);
execute();

assertEmblemCount(playerA, 1);

assertPermanentCount(playerB, "Perimeter Captain", 1);
assertGraveyardCount(playerB, "Perimeter Captain", 1);

}

}

0 comments on commit 13d9a56

Please sign in to comment.