* Emrakul, the Aeons Torn, Ulamog, the Infinite Gyre, Kozilek, Butcher of Truth - Fixed that the shuffle graveyard to library was wrongly done for the controller of instead the owner.

This commit is contained in:
LevelX2 2015-09-27 00:22:51 +02:00
parent 56a5030f93
commit 46fa935172
8 changed files with 180 additions and 296 deletions

View file

@ -29,30 +29,20 @@ package mage.sets.riseoftheeldrazi;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.CantBeCounteredAbility; import mage.abilities.common.CantBeCounteredAbility;
import mage.abilities.common.PutIntoGraveFromAnywhereSourceTriggeredAbility; import mage.abilities.common.PutIntoGraveFromAnywhereSourceTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.CastSourceTriggeredAbility;
import mage.abilities.effects.common.ShuffleIntoLibraryGraveOfSourceOwnerEffect;
import mage.abilities.effects.common.turn.AddExtraTurnControllerEffect;
import mage.abilities.keyword.AnnihilatorAbility; import mage.abilities.keyword.AnnihilatorAbility;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.ProtectionAbility; import mage.abilities.keyword.ProtectionAbility;
import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.FilterSpell; import mage.filter.FilterSpell;
import mage.filter.predicate.Predicates; import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.ColorlessPredicate; import mage.filter.predicate.mageobject.ColorlessPredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.stack.Spell;
import mage.game.turn.TurnMod;
import mage.players.Player;
/** /**
* @author Loki * @author Loki
@ -76,13 +66,14 @@ public class EmrakulTheAeonsTorn extends CardImpl {
// Emrakul, the Aeons Torn can't be countered. // Emrakul, the Aeons Torn can't be countered.
this.addAbility(new CantBeCounteredAbility()); this.addAbility(new CantBeCounteredAbility());
// When you cast Emrakul, take an extra turn after this one. // When you cast Emrakul, take an extra turn after this one.
this.addAbility(new EmrakulTheAeonsTornOnCastAbility()); this.addAbility(new CastSourceTriggeredAbility(new AddExtraTurnControllerEffect()));
// Flying, protection from colored spells, annihilator 6 // Flying, protection from colored spells, annihilator 6
this.addAbility(FlyingAbility.getInstance()); this.addAbility(FlyingAbility.getInstance());
this.addAbility(new ProtectionAbility(filter)); this.addAbility(new ProtectionAbility(filter));
this.addAbility(new AnnihilatorAbility(6)); this.addAbility(new AnnihilatorAbility(6));
// When Emrakul is put into a graveyard from anywhere, its owner shuffles his or her graveyard into his or her library. // When Emrakul is put into a graveyard from anywhere, its owner shuffles his or her graveyard into his or her library.
this.addAbility(new PutIntoGraveFromAnywhereSourceTriggeredAbility(new EmrakulTheAeonsTornEffect(), false)); this.addAbility(new PutIntoGraveFromAnywhereSourceTriggeredAbility(new ShuffleIntoLibraryGraveOfSourceOwnerEffect(), false));
} }
public EmrakulTheAeonsTorn(final EmrakulTheAeonsTorn card) { public EmrakulTheAeonsTorn(final EmrakulTheAeonsTorn card) {
@ -94,89 +85,3 @@ public class EmrakulTheAeonsTorn extends CardImpl {
return new EmrakulTheAeonsTorn(this); return new EmrakulTheAeonsTorn(this);
} }
} }
class EmrakulTheAeonsTornOnCastAbility extends TriggeredAbilityImpl {
private static final String abilityText = "When you cast {this}, take an extra turn after this one";
EmrakulTheAeonsTornOnCastAbility() {
super(Zone.STACK, new EmrakulExtraTurnEffect());
}
EmrakulTheAeonsTornOnCastAbility(EmrakulTheAeonsTornOnCastAbility ability) {
super(ability);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.SPELL_CAST;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Spell spell = (Spell) game.getObject(event.getTargetId());
return this.getSourceId().equals(spell.getSourceId());
}
@Override
public EmrakulTheAeonsTornOnCastAbility copy() {
return new EmrakulTheAeonsTornOnCastAbility(this);
}
@Override
public String getRule() {
return abilityText;
}
}
class EmrakulTheAeonsTornEffect extends OneShotEffect {
EmrakulTheAeonsTornEffect() {
super(Outcome.Benefit);
staticText = "its owner shuffles his or her graveyard into his or her library";
}
EmrakulTheAeonsTornEffect(final EmrakulTheAeonsTornEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
for (Card card: player.getGraveyard().getCards(game)) {
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
}
player.shuffleLibrary(game);
return true;
}
return false;
}
@Override
public EmrakulTheAeonsTornEffect copy() {
return new EmrakulTheAeonsTornEffect(this);
}
}
class EmrakulExtraTurnEffect extends OneShotEffect {
EmrakulExtraTurnEffect() {
super(Outcome.ExtraTurn);
staticText = "take an extra turn after this one";
}
EmrakulExtraTurnEffect(final EmrakulExtraTurnEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
game.getState().getTurnMods().add(new TurnMod(source.getControllerId(), false));
return true;
}
@Override
public EmrakulExtraTurnEffect copy() {
return new EmrakulExtraTurnEffect(this);
}
}

View file

@ -25,28 +25,18 @@
* authors and should not be interpreted as representing official policies, either expressed * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.sets.riseoftheeldrazi; package mage.sets.riseoftheeldrazi;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.PutIntoGraveFromAnywhereSourceTriggeredAbility; import mage.abilities.common.PutIntoGraveFromAnywhereSourceTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.CastSourceTriggeredAbility;
import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.ShuffleIntoLibraryGraveOfSourceOwnerEffect;
import mage.abilities.keyword.AnnihilatorAbility; import mage.abilities.keyword.AnnihilatorAbility;
import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.game.Game; import mage.constants.CardType;
import mage.game.events.GameEvent; import mage.constants.Rarity;
import mage.game.stack.Spell;
import mage.players.Player;
/** /**
* *
@ -63,13 +53,13 @@ public class KozilekButcherOfTruth extends CardImpl {
this.toughness = new MageInt(12); this.toughness = new MageInt(12);
// When you cast Kozilek, Butcher of Truth, draw four cards. // When you cast Kozilek, Butcher of Truth, draw four cards.
this.addAbility(new KozilekButcherOfTruthOnCastAbility()); this.addAbility(new CastSourceTriggeredAbility(new DrawCardSourceControllerEffect(4)));
// Annihilator 4 (Whenever this creature attacks, defending player sacrifices four permanents.) // Annihilator 4 (Whenever this creature attacks, defending player sacrifices four permanents.)
this.addAbility(new AnnihilatorAbility(4)); this.addAbility(new AnnihilatorAbility(4));
// When Kozilek is put into a graveyard from anywhere, its owner shuffles his or her graveyard into his or her library. // When Kozilek is put into a graveyard from anywhere, its owner shuffles his or her graveyard into his or her library.
this.addAbility(new PutIntoGraveFromAnywhereSourceTriggeredAbility(new KozilekButcherOfTruthEffect(), false)); this.addAbility(new PutIntoGraveFromAnywhereSourceTriggeredAbility(new ShuffleIntoLibraryGraveOfSourceOwnerEffect(), false));
} }
public KozilekButcherOfTruth(final KozilekButcherOfTruth card) { public KozilekButcherOfTruth(final KozilekButcherOfTruth card) {
@ -82,67 +72,3 @@ public class KozilekButcherOfTruth extends CardImpl {
} }
} }
class KozilekButcherOfTruthOnCastAbility extends TriggeredAbilityImpl {
private static final String abilityText = "When you cast {this}, draw four cards";
KozilekButcherOfTruthOnCastAbility() {
super(Zone.STACK, new DrawCardSourceControllerEffect(4));
}
KozilekButcherOfTruthOnCastAbility(final KozilekButcherOfTruthOnCastAbility ability) {
super(ability);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.SPELL_CAST;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Spell spell = (Spell) game.getObject(event.getTargetId());
return this.getSourceId().equals(spell.getSourceId());
}
@Override
public KozilekButcherOfTruthOnCastAbility copy() {
return new KozilekButcherOfTruthOnCastAbility(this);
}
@Override
public String getRule() {
return abilityText;
}
}
class KozilekButcherOfTruthEffect extends OneShotEffect {
KozilekButcherOfTruthEffect() {
super(Outcome.Benefit);
staticText = "its owner shuffles his or her graveyard into his or her library";
}
KozilekButcherOfTruthEffect(final KozilekButcherOfTruthEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (Card card: controller.getGraveyard().getCards(game)) {
controller.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD, true, true);
}
controller.shuffleLibrary(game);
return true;
}
return false;
}
@Override
public KozilekButcherOfTruthEffect copy() {
return new KozilekButcherOfTruthEffect(this);
}
}

View file

@ -30,22 +30,15 @@ package mage.sets.riseoftheeldrazi;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.PutIntoGraveFromAnywhereSourceTriggeredAbility; import mage.abilities.common.PutIntoGraveFromAnywhereSourceTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.CastSourceTriggeredAbility;
import mage.abilities.effects.common.DestroyTargetEffect; import mage.abilities.effects.common.DestroyTargetEffect;
import mage.abilities.effects.common.ShuffleIntoLibraryGraveOfSourceOwnerEffect;
import mage.abilities.keyword.AnnihilatorAbility; import mage.abilities.keyword.AnnihilatorAbility;
import mage.abilities.keyword.IndestructibleAbility; import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.stack.Spell;
import mage.players.Player;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
/** /**
@ -64,13 +57,16 @@ public class UlamogTheInfiniteGyre extends CardImpl {
this.toughness = new MageInt(10); this.toughness = new MageInt(10);
// When you cast Ulamog, the Infinite Gyre, destroy target permanent. // When you cast Ulamog, the Infinite Gyre, destroy target permanent.
this.addAbility(new UlamogTheInfiniteGyreDestroyOnCastAbility()); Ability ability = new CastSourceTriggeredAbility(new DestroyTargetEffect());
ability.addTarget(new TargetPermanent());
this.addAbility(ability);
// Annihilator 4 (Whenever this creature attacks, defending player sacrifices four permanents.) // Annihilator 4 (Whenever this creature attacks, defending player sacrifices four permanents.)
this.addAbility(new AnnihilatorAbility(4)); this.addAbility(new AnnihilatorAbility(4));
// Indestructible // Indestructible
this.addAbility(IndestructibleAbility.getInstance()); this.addAbility(IndestructibleAbility.getInstance());
// When Ulamog is put into a graveyard from anywhere, its owner shuffles his or her graveyard into his or her library. // When Ulamog is put into a graveyard from anywhere, its owner shuffles his or her graveyard into his or her library.
this.addAbility(new PutIntoGraveFromAnywhereSourceTriggeredAbility(new UlamogTheInfiniteGyreEnterGraveyardEffect(), false)); this.addAbility(new PutIntoGraveFromAnywhereSourceTriggeredAbility(new ShuffleIntoLibraryGraveOfSourceOwnerEffect(), false));
} }
public UlamogTheInfiniteGyre(final UlamogTheInfiniteGyre card) { public UlamogTheInfiniteGyre(final UlamogTheInfiniteGyre card) {
@ -82,64 +78,3 @@ public class UlamogTheInfiniteGyre extends CardImpl {
return new UlamogTheInfiniteGyre(this); return new UlamogTheInfiniteGyre(this);
} }
} }
class UlamogTheInfiniteGyreDestroyOnCastAbility extends TriggeredAbilityImpl {
UlamogTheInfiniteGyreDestroyOnCastAbility() {
super(Zone.STACK, new DestroyTargetEffect());
this.addTarget(new TargetPermanent());
}
UlamogTheInfiniteGyreDestroyOnCastAbility(UlamogTheInfiniteGyreDestroyOnCastAbility ability) {
super(ability);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.SPELL_CAST;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Spell spell = (Spell) game.getObject(event.getTargetId());
return this.getSourceId().equals(spell.getSourceId());
}
@Override
public UlamogTheInfiniteGyreDestroyOnCastAbility copy() {
return new UlamogTheInfiniteGyreDestroyOnCastAbility(this);
}
@Override
public String getRule() {
return "When you cast {this}, " + super.getRule();
}
}
class UlamogTheInfiniteGyreEnterGraveyardEffect extends OneShotEffect {
UlamogTheInfiniteGyreEnterGraveyardEffect() {
super(Outcome.Benefit);
staticText = "its owner shuffles his or her graveyard into his or her library";
}
UlamogTheInfiniteGyreEnterGraveyardEffect(UlamogTheInfiniteGyreEnterGraveyardEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player owner = game.getPlayer(game.getOwnerId(source.getSourceId()));
if (owner != null) {
owner.moveCards(owner.getGraveyard(), null, Zone.LIBRARY, source, game);
owner.shuffleLibrary(game);
return true;
}
return false;
}
@Override
public UlamogTheInfiniteGyreEnterGraveyardEffect copy() {
return new UlamogTheInfiniteGyreEnterGraveyardEffect(this);
}
}

View file

@ -36,11 +36,11 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
* *
* @author LevelX2 * @author LevelX2
*/ */
public class UlamogTheInfiniteGyreTest extends CardTestPlayerBase { public class UlamogTheInfiniteGyreTest extends CardTestPlayerBase {
/** /**
* Tests if Ulamog, the Infinite Gyre is countered its triggered ability resolves anyway * Tests if Ulamog, the Infinite Gyre is countered its triggered ability
* resolves anyway
*/ */
@Test @Test
public void testDisabledEffectOnChangeZone() { public void testDisabledEffectOnChangeZone() {
@ -57,11 +57,57 @@ public class UlamogTheInfiniteGyreTest extends CardTestPlayerBase {
setStopAt(1, PhaseStep.BEGIN_COMBAT); setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute(); execute();
assertHandCount(playerA, "Ulamog, the Infinite Gyre", 0); assertHandCount(playerA, "Ulamog, the Infinite Gyre", 0);
assertPermanentCount(playerA, "Ulamog, the Infinite Gyre", 0); assertPermanentCount(playerA, "Ulamog, the Infinite Gyre", 0);
assertGraveyardCount(playerB, "Counterspell", 1); assertGraveyardCount(playerB, "Counterspell", 1);
assertPermanentCount(playerB, "Island", 1); assertPermanentCount(playerB, "Island", 1);
} }
/**
* If one of the big eldrazi is under the control of someone that is not its
* owner when it goes to the graveyard, it's ability doesn't trigger
* correctly.
*/
@Test
public void testControlledByOtherPlayer() {
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 15);
// When you cast Kozilek, Butcher of Truth, draw four cards.
// Annihilator 4 (Whenever this creature attacks, defending player sacrifices four permanents.)
// When Kozilek is put into a graveyard from anywhere, its owner shuffles his or her graveyard into his or her library.
addCard(Zone.HAND, playerA, "Kozilek, Butcher of Truth"); // {10}
// Destroy target creature.
// Spell mastery - If there are two or more instant and/or sorcery cards in your graveyard, you gain 2 life.
addCard(Zone.HAND, playerA, "Unholy Hunger"); // {3}{B}{B}
addCard(Zone.GRAVEYARD, playerA, "Silvercoat Lion");
addCard(Zone.BATTLEFIELD, playerB, "Island", 4);
addCard(Zone.HAND, playerB, "Control Magic", 1);
addCard(Zone.GRAVEYARD, playerB, "Silvercoat Lion");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Kozilek, Butcher of Truth");
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Control Magic", "Kozilek, Butcher of Truth");
castSpell(2, PhaseStep.POSTCOMBAT_MAIN, playerA, "Unholy Hunger", "Kozilek, Butcher of Truth");
setStopAt(2, PhaseStep.END_TURN);
execute();
assertPermanentCount(playerA, "Kozilek, Butcher of Truth", 0);
assertPermanentCount(playerB, "Kozilek, Butcher of Truth", 0);
assertLife(playerA, 20);
assertGraveyardCount(playerB, "Silvercoat Lion", 1);
assertHandCount(playerB, "Control Magic", 0);
assertGraveyardCount(playerB, "Control Magic", 1);
assertGraveyardCount(playerA, "Kozilek, Butcher of Truth", 0);
assertHandCount(playerA, "Kozilek, Butcher of Truth", 0);
assertGraveyardCount(playerA, "Silvercoat Lion", 0);
assertGraveyardCount(playerA, "Unholy Hunger", 0);
assertHandCount(playerA, 4);
}
} }

View file

@ -858,7 +858,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
} }
} }
Assert.assertEquals("(Graveyard) Card counts are not equal (" + cardName + ")", count, actualCount); Assert.assertEquals("(Graveyard " + player.getName() + ") Card counts are not equal (" + cardName + ")", count, actualCount);
} }
/** /**

View file

@ -0,0 +1,72 @@
/*
* 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 mage.abilities.effects.common;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
/**
*
* @author LevelX2
*/
public class ShuffleIntoLibraryGraveOfSourceOwnerEffect extends OneShotEffect {
public ShuffleIntoLibraryGraveOfSourceOwnerEffect() {
super(Outcome.Benefit);
staticText = "its owner shuffles his or her graveyard into his or her library";
}
public ShuffleIntoLibraryGraveOfSourceOwnerEffect(final ShuffleIntoLibraryGraveOfSourceOwnerEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
UUID ownerId = game.getOwnerId(source.getSourceId());
if (ownerId == null) {
return false;
}
Player owner = game.getPlayer(ownerId);
if (owner != null) {
owner.moveCards(owner.getGraveyard(), null, Zone.LIBRARY, source, game);
owner.shuffleLibrary(game);
return true;
}
return false;
}
@Override
public ShuffleIntoLibraryGraveOfSourceOwnerEffect copy() {
return new ShuffleIntoLibraryGraveOfSourceOwnerEffect(this);
}
}

View file

@ -54,7 +54,7 @@ public class AddExtraTurnControllerEffect extends OneShotEffect {
public AddExtraTurnControllerEffect(boolean loseGameAtEnd) { public AddExtraTurnControllerEffect(boolean loseGameAtEnd) {
super(loseGameAtEnd ? Outcome.AIDontUseIt : Outcome.ExtraTurn); super(loseGameAtEnd ? Outcome.AIDontUseIt : Outcome.ExtraTurn);
this.loseGameAtEnd = loseGameAtEnd; this.loseGameAtEnd = loseGameAtEnd;
staticText = "Take an extra turn after this one"; staticText = "take an extra turn after this one";
if (loseGameAtEnd) { if (loseGameAtEnd) {
staticText += ". At the beginning of that turn's end step, you lose the game"; staticText += ". At the beginning of that turn's end step, you lose the game";
} }