From 46fa935172564861381e9509f12ee11fd9f698e2 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 27 Sep 2015 00:22:51 +0200 Subject: [PATCH] * 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. --- .../sets/battleforzendikar/SunkenHollow.java | 4 +- .../riseoftheeldrazi/EmrakulTheAeonsTorn.java | 111 ++---------------- .../KozilekButcherOfTruth.java | 98 ++-------------- .../UlamogTheInfiniteGyre.java | 79 ++----------- .../triggers/UlamogTheInfiniteGyreTest.java | 52 +++++++- .../base/impl/CardTestPlayerAPIImpl.java | 2 +- ...leIntoLibraryGraveOfSourceOwnerEffect.java | 72 ++++++++++++ .../turn/AddExtraTurnControllerEffect.java | 58 ++++----- 8 files changed, 180 insertions(+), 296 deletions(-) create mode 100644 Mage/src/mage/abilities/effects/common/ShuffleIntoLibraryGraveOfSourceOwnerEffect.java diff --git a/Mage.Sets/src/mage/sets/battleforzendikar/SunkenHollow.java b/Mage.Sets/src/mage/sets/battleforzendikar/SunkenHollow.java index 654009000d..0f9edc0a55 100644 --- a/Mage.Sets/src/mage/sets/battleforzendikar/SunkenHollow.java +++ b/Mage.Sets/src/mage/sets/battleforzendikar/SunkenHollow.java @@ -47,9 +47,9 @@ import mage.filter.predicate.mageobject.SupertypePredicate; * @author fireshoes */ public class SunkenHollow extends CardImpl { - + private static final FilterLandPermanent filter = new FilterLandPermanent(); - + static { filter.add(new SupertypePredicate("Basic")); } diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/EmrakulTheAeonsTorn.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/EmrakulTheAeonsTorn.java index 11b0df213d..81f7d3e5c6 100644 --- a/Mage.Sets/src/mage/sets/riseoftheeldrazi/EmrakulTheAeonsTorn.java +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/EmrakulTheAeonsTorn.java @@ -29,30 +29,20 @@ package mage.sets.riseoftheeldrazi; import java.util.UUID; import mage.MageInt; -import mage.abilities.Ability; -import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.CantBeCounteredAbility; 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.FlyingAbility; import mage.abilities.keyword.ProtectionAbility; -import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.Rarity; -import mage.constants.Zone; import mage.filter.FilterSpell; import mage.filter.predicate.Predicates; 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 @@ -72,17 +62,18 @@ public class EmrakulTheAeonsTorn extends CardImpl { this.subtype.add("Eldrazi"); this.power = new MageInt(15); this.toughness = new MageInt(15); - + // Emrakul, the Aeons Torn can't be countered. this.addAbility(new CantBeCounteredAbility()); - // When you cast Emrakul, take an extra turn after this one. - this.addAbility(new EmrakulTheAeonsTornOnCastAbility()); + // When you cast Emrakul, take an extra turn after this one. + this.addAbility(new CastSourceTriggeredAbility(new AddExtraTurnControllerEffect())); + // Flying, protection from colored spells, annihilator 6 this.addAbility(FlyingAbility.getInstance()); this.addAbility(new ProtectionAbility(filter)); 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. - this.addAbility(new PutIntoGraveFromAnywhereSourceTriggeredAbility(new EmrakulTheAeonsTornEffect(), false)); + this.addAbility(new PutIntoGraveFromAnywhereSourceTriggeredAbility(new ShuffleIntoLibraryGraveOfSourceOwnerEffect(), false)); } public EmrakulTheAeonsTorn(final EmrakulTheAeonsTorn card) { @@ -94,89 +85,3 @@ public class EmrakulTheAeonsTorn extends CardImpl { 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); - } -} diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/KozilekButcherOfTruth.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/KozilekButcherOfTruth.java index 81f0622ac4..00a59b921e 100644 --- a/Mage.Sets/src/mage/sets/riseoftheeldrazi/KozilekButcherOfTruth.java +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/KozilekButcherOfTruth.java @@ -25,28 +25,18 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.sets.riseoftheeldrazi; 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.abilities.Ability; -import mage.abilities.TriggeredAbilityImpl; 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.ShuffleIntoLibraryGraveOfSourceOwnerEffect; import mage.abilities.keyword.AnnihilatorAbility; -import mage.cards.Card; import mage.cards.CardImpl; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.stack.Spell; -import mage.players.Player; +import mage.constants.CardType; +import mage.constants.Rarity; /** * @@ -54,25 +44,25 @@ import mage.players.Player; */ public class KozilekButcherOfTruth extends CardImpl { - public KozilekButcherOfTruth (UUID ownerId) { + public KozilekButcherOfTruth(UUID ownerId) { super(ownerId, 6, "Kozilek, Butcher of Truth", Rarity.MYTHIC, new CardType[]{CardType.CREATURE}, "{10}"); this.expansionSetCode = "ROE"; this.supertype.add("Legendary"); this.subtype.add("Eldrazi"); this.power = new MageInt(12); this.toughness = new MageInt(12); - - // When you cast Kozilek, Butcher of Truth, draw four cards. - this.addAbility(new KozilekButcherOfTruthOnCastAbility()); - + + // When you cast Kozilek, Butcher of Truth, draw four cards. + this.addAbility(new CastSourceTriggeredAbility(new DrawCardSourceControllerEffect(4))); + // Annihilator 4 (Whenever this creature attacks, defending player sacrifices four permanents.) 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. - this.addAbility(new PutIntoGraveFromAnywhereSourceTriggeredAbility(new KozilekButcherOfTruthEffect(), false)); + this.addAbility(new PutIntoGraveFromAnywhereSourceTriggeredAbility(new ShuffleIntoLibraryGraveOfSourceOwnerEffect(), false)); } - public KozilekButcherOfTruth (final KozilekButcherOfTruth card) { + public KozilekButcherOfTruth(final KozilekButcherOfTruth card) { super(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); - } - -} diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/UlamogTheInfiniteGyre.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/UlamogTheInfiniteGyre.java index 0c43c1abf8..4a25d967f6 100644 --- a/Mage.Sets/src/mage/sets/riseoftheeldrazi/UlamogTheInfiniteGyre.java +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/UlamogTheInfiniteGyre.java @@ -30,22 +30,15 @@ package mage.sets.riseoftheeldrazi; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; -import mage.abilities.TriggeredAbilityImpl; 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.ShuffleIntoLibraryGraveOfSourceOwnerEffect; import mage.abilities.keyword.AnnihilatorAbility; import mage.abilities.keyword.IndestructibleAbility; import mage.cards.CardImpl; import mage.constants.CardType; -import mage.constants.Outcome; 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; /** @@ -64,13 +57,16 @@ public class UlamogTheInfiniteGyre extends CardImpl { this.toughness = new MageInt(10); // 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.) this.addAbility(new AnnihilatorAbility(4)); // Indestructible 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. - this.addAbility(new PutIntoGraveFromAnywhereSourceTriggeredAbility(new UlamogTheInfiniteGyreEnterGraveyardEffect(), false)); + this.addAbility(new PutIntoGraveFromAnywhereSourceTriggeredAbility(new ShuffleIntoLibraryGraveOfSourceOwnerEffect(), false)); } public UlamogTheInfiniteGyre(final UlamogTheInfiniteGyre card) { @@ -82,64 +78,3 @@ public class UlamogTheInfiniteGyre extends CardImpl { 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); - } -} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/UlamogTheInfiniteGyreTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/UlamogTheInfiniteGyreTest.java index 44a39cd25c..dfde867688 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/UlamogTheInfiniteGyreTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/UlamogTheInfiniteGyreTest.java @@ -36,11 +36,11 @@ import org.mage.test.serverside.base.CardTestPlayerBase; * * @author LevelX2 */ - 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 public void testDisabledEffectOnChangeZone() { @@ -57,11 +57,57 @@ public class UlamogTheInfiniteGyreTest extends CardTestPlayerBase { setStopAt(1, PhaseStep.BEGIN_COMBAT); execute(); - assertHandCount(playerA, "Ulamog, the Infinite Gyre", 0); assertPermanentCount(playerA, "Ulamog, the Infinite Gyre", 0); assertGraveyardCount(playerB, "Counterspell", 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); + + } } diff --git a/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java b/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java index 26e68f0944..bc7f74a40f 100644 --- a/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java +++ b/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java @@ -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); } /** diff --git a/Mage/src/mage/abilities/effects/common/ShuffleIntoLibraryGraveOfSourceOwnerEffect.java b/Mage/src/mage/abilities/effects/common/ShuffleIntoLibraryGraveOfSourceOwnerEffect.java new file mode 100644 index 0000000000..149117f39f --- /dev/null +++ b/Mage/src/mage/abilities/effects/common/ShuffleIntoLibraryGraveOfSourceOwnerEffect.java @@ -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); + } +} diff --git a/Mage/src/mage/abilities/effects/common/turn/AddExtraTurnControllerEffect.java b/Mage/src/mage/abilities/effects/common/turn/AddExtraTurnControllerEffect.java index 9b08d1d361..82ada6f989 100644 --- a/Mage/src/mage/abilities/effects/common/turn/AddExtraTurnControllerEffect.java +++ b/Mage/src/mage/abilities/effects/common/turn/AddExtraTurnControllerEffect.java @@ -1,30 +1,30 @@ /* -* 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. -*/ + * 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.turn; import java.util.UUID; @@ -54,8 +54,8 @@ public class AddExtraTurnControllerEffect extends OneShotEffect { public AddExtraTurnControllerEffect(boolean loseGameAtEnd) { super(loseGameAtEnd ? Outcome.AIDontUseIt : Outcome.ExtraTurn); this.loseGameAtEnd = loseGameAtEnd; - staticText = "Take an extra turn after this one"; - if(loseGameAtEnd) { + staticText = "take an extra turn after this one"; + if (loseGameAtEnd) { staticText += ". At the beginning of that turn's end step, you lose the game"; } } @@ -76,7 +76,7 @@ public class AddExtraTurnControllerEffect extends OneShotEffect { if (player != null) { TurnMod extraTurn = new TurnMod(player.getId(), false); game.getState().getTurnMods().add(extraTurn); - if(loseGameAtEnd) { + if (loseGameAtEnd) { LoseGameDelayedTriggeredAbility delayedTriggeredAbility = new LoseGameDelayedTriggeredAbility(); delayedTriggeredAbility.setSourceId(source.getSourceId()); delayedTriggeredAbility.setControllerId(source.getControllerId());