diff --git a/Mage.Client/src/main/resources/card-pictures-tok.txt b/Mage.Client/src/main/resources/card-pictures-tok.txt index cdd9a2fa5cb..cb6de62e539 100644 --- a/Mage.Client/src/main/resources/card-pictures-tok.txt +++ b/Mage.Client/src/main/resources/card-pictures-tok.txt @@ -160,7 +160,7 @@ |Generate|TOK:DD3B|Elemental|| |Generate|TOK:DD3B|Elf Warrior|| -|Generate|TOK:|DD3B|Goblin|| +|Generate|TOK:DD3B|Goblin|| |Generate|TOK:DD3A|Spirit|| |Generate|TOK:DD3A|Demon|| diff --git a/Mage.Sets/src/mage/sets/apocalypse/WhirlpoolDrake.java b/Mage.Sets/src/mage/sets/apocalypse/WhirlpoolDrake.java index ea29cc684c1..f643a96561d 100644 --- a/Mage.Sets/src/mage/sets/apocalypse/WhirlpoolDrake.java +++ b/Mage.Sets/src/mage/sets/apocalypse/WhirlpoolDrake.java @@ -29,20 +29,13 @@ package mage.sets.apocalypse; import java.util.UUID; import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.common.DiesTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.ShuffleHandIntoLibraryDrawThatManySourceEffect; import mage.abilities.keyword.FlyingAbility; -import mage.cards.Card; import mage.cards.CardImpl; -import mage.cards.Cards; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.Rarity; -import mage.constants.Zone; -import mage.game.Game; -import mage.players.Player; /** * @@ -61,10 +54,10 @@ public class WhirlpoolDrake extends CardImpl { // Flying this.addAbility(FlyingAbility.getInstance()); // When Whirlpool Drake enters the battlefield, shuffle the cards from your hand into your library, then draw that many cards. - this.addAbility(new EntersBattlefieldTriggeredAbility(new WhirlpoolSDrakeTriggeredEffect(), false)); - + this.addAbility(new EntersBattlefieldTriggeredAbility(new ShuffleHandIntoLibraryDrawThatManySourceEffect(), false)); + // When Whirlpool Drake dies, shuffle the cards from your hand into your library, then draw that many cards. - this.addAbility(new DiesTriggeredAbility(new WhirlpoolSDrakeTriggeredEffect(), false)); + this.addAbility(new DiesTriggeredAbility(new ShuffleHandIntoLibraryDrawThatManySourceEffect(), false)); } public WhirlpoolDrake(final WhirlpoolDrake card) { @@ -76,40 +69,3 @@ public class WhirlpoolDrake extends CardImpl { return new WhirlpoolDrake(this); } } - -class WhirlpoolSDrakeTriggeredEffect extends OneShotEffect { - - public WhirlpoolSDrakeTriggeredEffect() { - super(Outcome.DrawCard); - this.staticText = "shuffle the cards from your hand into your library, then draw that many cards"; - } - - public WhirlpoolSDrakeTriggeredEffect(final WhirlpoolSDrakeTriggeredEffect effect) { - super(effect); - } - - @Override - public WhirlpoolSDrakeTriggeredEffect copy() { - return new WhirlpoolSDrakeTriggeredEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { - int cardsHand = controller.getHand().size(); - if (cardsHand > 0){ - for (Card card: controller.getHand().getCards(game)) { - if (card != null) { - controller.removeFromHand(card, game); - card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); - } - } - controller.shuffleLibrary(game); - controller.drawCards(cardsHand, game); - } - return true; - } - return false; - } -} diff --git a/Mage.Sets/src/mage/sets/apocalypse/WhirlpoolRider.java b/Mage.Sets/src/mage/sets/apocalypse/WhirlpoolRider.java index f407dec978b..ddaaa83c70f 100644 --- a/Mage.Sets/src/mage/sets/apocalypse/WhirlpoolRider.java +++ b/Mage.Sets/src/mage/sets/apocalypse/WhirlpoolRider.java @@ -29,18 +29,11 @@ package mage.sets.apocalypse; import java.util.UUID; import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; -import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; +import mage.abilities.effects.common.ShuffleHandIntoLibraryDrawThatManySourceEffect; import mage.cards.CardImpl; -import mage.cards.Cards; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.Rarity; -import mage.constants.Zone; -import mage.game.Game; -import mage.players.Player; /** * @@ -57,7 +50,7 @@ public class WhirlpoolRider extends CardImpl { this.toughness = new MageInt(1); // When Whirlpool Rider enters the battlefield, shuffle the cards from your hand into your library, then draw that many cards. - this.addAbility(new EntersBattlefieldTriggeredAbility(new WhirlpoolRiderTriggeredEffect())); + this.addAbility(new EntersBattlefieldTriggeredAbility(new ShuffleHandIntoLibraryDrawThatManySourceEffect())); } @@ -70,40 +63,3 @@ public class WhirlpoolRider extends CardImpl { return new WhirlpoolRider(this); } } - -class WhirlpoolRiderTriggeredEffect extends OneShotEffect { - - public WhirlpoolRiderTriggeredEffect() { - super(Outcome.DrawCard); - this.staticText = "shuffle the cards from your hand into your library, then draw that many cards"; - } - - public WhirlpoolRiderTriggeredEffect(final WhirlpoolRiderTriggeredEffect effect) { - super(effect); - } - - @Override - public WhirlpoolRiderTriggeredEffect copy() { - return new WhirlpoolRiderTriggeredEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { - int cardsHand = controller.getHand().size(); - if (cardsHand > 0) { - for (Card card: controller.getHand().getCards(game)) { - if (card != null) { - controller.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.HAND, true, false); - } - } - controller.shuffleLibrary(game); - controller.drawCards(cardsHand, game); - } - return true; - } - - return false; - } -} diff --git a/Mage.Sets/src/mage/sets/iceage/GoblinMutant.java b/Mage.Sets/src/mage/sets/iceage/GoblinMutant.java index b1b2b822430..ba9a964b64e 100644 --- a/Mage.Sets/src/mage/sets/iceage/GoblinMutant.java +++ b/Mage.Sets/src/mage/sets/iceage/GoblinMutant.java @@ -39,7 +39,6 @@ import mage.constants.CardType; import mage.constants.Rarity; import mage.constants.Zone; import mage.filter.Filter; -import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.PowerPredicate; @@ -48,18 +47,18 @@ import mage.filter.predicate.permanent.TappedPredicate; /** * * @author BursegSardaukar - + * */ public class GoblinMutant extends CardImpl { static final private FilterCreaturePermanent filter = new FilterCreaturePermanent("untapped creature with power 3 or greater"); static final private FilterCreaturePermanent filter2 = new FilterCreaturePermanent("creatures with power 3 or greater"); - + static { filter.add(Predicates.and(new PowerPredicate(Filter.ComparisonType.GreaterThan, 2), Predicates.not(new TappedPredicate()))); filter2.add(new PowerPredicate(Filter.ComparisonType.GreaterThan, 2)); } - + public GoblinMutant(UUID ownerId) { super(ownerId, 188, "Goblin Mutant", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{2}{R}{R}"); this.expansionSetCode = "ICE"; @@ -71,12 +70,12 @@ public class GoblinMutant extends CardImpl { //Trample this.addAbility(TrampleAbility.getInstance()); - + // Goblin Mutant can't attack if defending player controls an untapped creature with power 3 or greater. Effect effect = new CantAttackIfDefenderControlsPermanent(filter); effect.setText("{this} can't attack if defending player controls an untapped creature with power 3 or greater."); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect)); - + //Goblin Mutant can't block creatures with power 3 or greater. Effect effectBlock = new CantBlockCreaturesSourceEffect(filter2); effectBlock.setText("{this} can't block creatures with power 3 or greater."); diff --git a/Mage.Sets/src/mage/sets/magic2012/ChandrasPhoenix.java b/Mage.Sets/src/mage/sets/magic2012/ChandrasPhoenix.java index 1aeed25f2da..8047ded4341 100644 --- a/Mage.Sets/src/mage/sets/magic2012/ChandrasPhoenix.java +++ b/Mage.Sets/src/mage/sets/magic2012/ChandrasPhoenix.java @@ -29,11 +29,11 @@ package mage.sets.magic2012; import java.util.UUID; import mage.MageInt; +import mage.MageObject; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.common.ReturnToHandSourceEffect; import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.HasteAbility; -import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; @@ -41,6 +41,8 @@ import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; +import mage.game.stack.StackAbility; +import mage.game.stack.StackObject; /** * @@ -56,8 +58,11 @@ public class ChandrasPhoenix extends CardImpl { this.power = new MageInt(2); this.toughness = new MageInt(2); + // Flying this.addAbility(FlyingAbility.getInstance()); + // Haste (This creature can attack and as soon as it comes under your control.) this.addAbility(HasteAbility.getInstance()); + // Whenever an opponent is dealt damage by a red instant or sorcery spell you control or by a red planeswalker you control, return Chandra's Phoenix from your graveyard to your hand. this.addAbility(new ChandrasPhoenixTriggeredAbility()); } @@ -72,6 +77,7 @@ public class ChandrasPhoenix extends CardImpl { } class ChandrasPhoenixTriggeredAbility extends TriggeredAbilityImpl { + ChandrasPhoenixTriggeredAbility() { super(Zone.GRAVEYARD, new ReturnToHandSourceEffect()); } @@ -93,10 +99,21 @@ class ChandrasPhoenixTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) { - Card c = game.getCard(event.getSourceId()); - if (c != null) { - if (c.getColor(game).isRed() && (c.getCardType().contains(CardType.PLANESWALKER) || c.getCardType().contains(CardType.INSTANT) || c.getCardType().contains(CardType.SORCERY))) { - return true; + StackObject stackObject = game.getStack().getStackObject(event.getSourceId()); + if (stackObject != null) { + MageObject sourceObjectDamage; + if (stackObject instanceof StackAbility) { + sourceObjectDamage = ((StackAbility) stackObject).getSourceObject(game); + } else { + sourceObjectDamage = stackObject; + } + if (sourceObjectDamage != null) { + if (sourceObjectDamage.getColor(game).isRed() + && (sourceObjectDamage.getCardType().contains(CardType.PLANESWALKER) + || sourceObjectDamage.getCardType().contains(CardType.INSTANT) + || sourceObjectDamage.getCardType().contains(CardType.SORCERY))) { + return true; + } } } } diff --git a/Mage.Sets/src/mage/sets/mediainserts/ChandrasPhoenix.java b/Mage.Sets/src/mage/sets/mediainserts/ChandrasPhoenix.java index 4dff51b1929..9fb9364d93b 100644 --- a/Mage.Sets/src/mage/sets/mediainserts/ChandrasPhoenix.java +++ b/Mage.Sets/src/mage/sets/mediainserts/ChandrasPhoenix.java @@ -1,19 +1,46 @@ +/* + * 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.sets.mediainserts; import java.util.UUID; public class ChandrasPhoenix extends mage.sets.magic2012.ChandrasPhoenix { - + public ChandrasPhoenix(UUID ownerId) { super(ownerId); this.cardNumber = 37; this.expansionSetCode = "MBP"; } - + public ChandrasPhoenix(final ChandrasPhoenix card) { super(card); } - + @Override public ChandrasPhoenix copy() { return new ChandrasPhoenix(this); diff --git a/Mage.Sets/src/mage/sets/morningtide/Forfend.java b/Mage.Sets/src/mage/sets/morningtide/Forfend.java new file mode 100644 index 00000000000..9db502be29f --- /dev/null +++ b/Mage.Sets/src/mage/sets/morningtide/Forfend.java @@ -0,0 +1,60 @@ +/* + * 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.sets.morningtide; + +import java.util.UUID; +import mage.abilities.effects.common.PreventAllDamageToAllEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.filter.common.FilterCreaturePermanent; + +/** + * + * @author emerald000 + */ +public class Forfend extends CardImpl { + + public Forfend(UUID ownerId) { + super(ownerId, 10, "Forfend", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{W}"); + this.expansionSetCode = "MOR"; + + // Prevent all damage that would be dealt to creatures this turn. + this.getSpellAbility().addEffect(new PreventAllDamageToAllEffect(Duration.EndOfTurn, new FilterCreaturePermanent("creatures"))); + } + + public Forfend(final Forfend card) { + super(card); + } + + @Override + public Forfend copy() { + return new Forfend(this); + } +} diff --git a/Mage.Sets/src/mage/sets/morningtide/StompingSlabs.java b/Mage.Sets/src/mage/sets/morningtide/StompingSlabs.java new file mode 100644 index 00000000000..e272cd75fe6 --- /dev/null +++ b/Mage.Sets/src/mage/sets/morningtide/StompingSlabs.java @@ -0,0 +1,115 @@ +/* + * 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.sets.morningtide; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.effects.Effect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DamageTargetEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.Cards; +import mage.cards.CardsImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.game.Game; +import mage.players.Player; +import mage.target.common.TargetCreatureOrPlayer; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author emerald000 + */ +public class StompingSlabs extends CardImpl { + + public StompingSlabs(UUID ownerId) { + super(ownerId, 107, "Stomping Slabs", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{2}{R}"); + this.expansionSetCode = "MOR"; + + // Reveal the top seven cards of your library, then put those cards on the bottom of your library in any order. If a card named Stomping Slabs was revealed this way, Stomping Slabs deals 7 damage to target creature or player. + this.getSpellAbility().addEffect(new StompingSlabsEffect()); + this.getSpellAbility().addTarget(new TargetCreatureOrPlayer()); + } + + public StompingSlabs(final StompingSlabs card) { + super(card); + } + + @Override + public StompingSlabs copy() { + return new StompingSlabs(this); + } +} + +class StompingSlabsEffect extends OneShotEffect { + + StompingSlabsEffect() { + super(Outcome.Damage); + this.staticText = "Reveal the top seven cards of your library, then put those cards on the bottom of your library in any order. If a card named Stomping Slabs was revealed this way, {this} deals 7 damage to target creature or player"; + } + + StompingSlabsEffect(final StompingSlabsEffect effect) { + super(effect); + } + + @Override + public StompingSlabsEffect copy() { + return new StompingSlabsEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + Cards cards = new CardsImpl(); + cards.addAll(controller.getLibrary().getTopCards(game, 7)); + if (cards.size() > 0) { + controller.revealCards("Stomping Slabs", cards, game); + boolean stompingSlabsFound = false; + for (UUID cardId : cards) { + Card card = game.getCard(cardId); + if (card != null && card.getName().equals("Stomping Slabs")) { + stompingSlabsFound = true; + break; + } + } + controller.putCardsOnBottomOfLibrary(cards, game, source, true); + if (stompingSlabsFound) { + Effect effect = new DamageTargetEffect(7); + effect.setTargetPointer(new FixedTarget(this.getTargetPointer().getFirst(game, source))); + effect.apply(game, source); + } + } + return true; + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/planechase2012/WhirlpoolWarrior.java b/Mage.Sets/src/mage/sets/planechase2012/WhirlpoolWarrior.java index 059d5a709c2..5b32fa15d15 100644 --- a/Mage.Sets/src/mage/sets/planechase2012/WhirlpoolWarrior.java +++ b/Mage.Sets/src/mage/sets/planechase2012/WhirlpoolWarrior.java @@ -29,6 +29,7 @@ package mage.sets.planechase2012; import java.util.LinkedHashMap; import java.util.Map; +import java.util.Map.Entry; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; @@ -37,7 +38,7 @@ import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; +import mage.abilities.effects.common.ShuffleHandIntoLibraryDrawThatManySourceEffect; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Outcome; @@ -62,7 +63,7 @@ public class WhirlpoolWarrior extends CardImpl { this.toughness = new MageInt(2); // When Whirlpool Warrior enters the battlefield, shuffle the cards from your hand into your library, then draw that many cards. - this.addAbility(new EntersBattlefieldTriggeredAbility(new WhirlpoolWarriorTriggeredEffect())); + this.addAbility(new EntersBattlefieldTriggeredAbility(new ShuffleHandIntoLibraryDrawThatManySourceEffect())); // {R}, Sacrifice Whirlpool Warrior: Each player shuffles the cards from his or her hand into his or her library, then draws that many cards. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new WhirlpoolWarriorActivatedEffect(), new ManaCostsImpl("{R}")); @@ -80,51 +81,6 @@ public class WhirlpoolWarrior extends CardImpl { } } -class WhirlpoolWarriorTriggeredEffect extends OneShotEffect { - - public WhirlpoolWarriorTriggeredEffect() { - super(Outcome.DrawCard); - this.staticText = "shuffle the cards from your hand into your library, then draw that many cards"; - } - - public WhirlpoolWarriorTriggeredEffect(final WhirlpoolWarriorTriggeredEffect effect) { - super(effect); - } - - @Override - public WhirlpoolWarriorTriggeredEffect copy() { - return new WhirlpoolWarriorTriggeredEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { - Map cardsToDraw = new LinkedHashMap<>(); - for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { - Player player = game.getPlayer(playerId); - if (player != null) { - int cardsInHand = player.getHand().size(); - if (cardsInHand > 0) { - cardsToDraw.put(playerId, cardsInHand); - } - player.moveCards(player.getHand(), Zone.HAND, Zone.LIBRARY, source, game); - player.shuffleLibrary(game); - } - } - for (UUID playerId : cardsToDraw.keySet()) { - Player player = game.getPlayer(playerId); - if (player != null) { - player.drawCards(cardsToDraw.get(playerId), game); - } - } - return true; - } - - return false; - } -} - class WhirlpoolWarriorActivatedEffect extends OneShotEffect { public WhirlpoolWarriorActivatedEffect() { @@ -145,23 +101,24 @@ class WhirlpoolWarriorActivatedEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId : controller.getInRange()) { + Map playerCards = new LinkedHashMap<>(); + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { int cardsHand = player.getHand().size(); if (cardsHand > 0) { - for (Card card : player.getHand().getCards(game)) { - if (card != null) { - player.removeFromHand(card, game); - card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); - } - } - game.informPlayers(player.getLogName() + " shuffles the cards from his or her hand into his or her library"); + playerCards.put(playerId, cardsHand); + player.moveCards(player.getHand(), Zone.LIBRARY, source, game); player.shuffleLibrary(game); - player.drawCards(cardsHand, game); } } } + for (Entry entry : playerCards.entrySet()) { + Player player = game.getPlayer(entry.getKey()); + if (player != null) { + player.drawCards(entry.getValue(), game); + } + } return true; } return false; diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/damage/ChandrasPhoenixTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/damage/ChandrasPhoenixTest.java new file mode 100644 index 00000000000..80e85711cb9 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/damage/ChandrasPhoenixTest.java @@ -0,0 +1,88 @@ +/* + * 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 org.mage.test.cards.triggers.damage; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ +public class ChandrasPhoenixTest extends CardTestPlayerBase { + + @Test + public void testReturnByInstantSpell() { + // Flying + // Haste (This creature can attack and as soon as it comes under your control.) + // Whenever an opponent is dealt damage by a red instant or sorcery spell you control or by a red planeswalker you control, return Chandra's Phoenix from your graveyard to your hand. + addCard(Zone.GRAVEYARD, playerA, "Chandra's Phoenix", 1); + + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1); + addCard(Zone.HAND, playerA, "Lightning Bolt", 1); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertGraveyardCount(playerA, "Lightning Bolt", 1); + assertLife(playerA, 20); + assertLife(playerB, 17); + + assertHandCount(playerA, "Chandra's Phoenix", 1); + + } + + @Test + public void testReturnByPlaneswalkerDamage() { + // Flying + // Haste (This creature can attack and as soon as it comes under your control.) + // Whenever an opponent is dealt damage by a red instant or sorcery spell you control or by a red planeswalker you control, return Chandra's Phoenix from your graveyard to your hand. + addCard(Zone.GRAVEYARD, playerA, "Chandra's Phoenix", 1); + + // +1: Chandra Nalaar deals 1 damage to target player. + // -X: Chandra Nalaar deals X damage to target creature. + // -8: Chandra Nalaar deals 10 damage to target player and each creature he or she controls. + addCard(Zone.BATTLEFIELD, playerA, "Chandra Nalaar", 1); + + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "+1", playerB); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 19); + + assertHandCount(playerA, "Chandra's Phoenix", 1); + + } + +} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/combat/damage/GravebladeMarauderTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/damage/GravebladeMarauderTest.java similarity index 95% rename from Mage.Tests/src/test/java/org/mage/test/cards/triggers/combat/damage/GravebladeMarauderTest.java rename to Mage.Tests/src/test/java/org/mage/test/cards/triggers/damage/GravebladeMarauderTest.java index bab7f3ca404..895de68102b 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/combat/damage/GravebladeMarauderTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/damage/GravebladeMarauderTest.java @@ -25,7 +25,7 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ -package org.mage.test.cards.triggers.combat.damage; +package org.mage.test.cards.triggers.damage; import mage.constants.PhaseStep; import mage.constants.Zone; diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/combat/damage/HixusPrisonWardenTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/damage/HixusPrisonWardenTest.java similarity index 96% rename from Mage.Tests/src/test/java/org/mage/test/cards/triggers/combat/damage/HixusPrisonWardenTest.java rename to Mage.Tests/src/test/java/org/mage/test/cards/triggers/damage/HixusPrisonWardenTest.java index b5b199c856f..b26a8218516 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/combat/damage/HixusPrisonWardenTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/damage/HixusPrisonWardenTest.java @@ -25,7 +25,7 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ -package org.mage.test.cards.triggers.combat.damage; +package org.mage.test.cards.triggers.damage; import mage.constants.PhaseStep; import mage.constants.Zone; diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/combat/damage/HuntersInsightTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/damage/HuntersInsightTest.java similarity index 94% rename from Mage.Tests/src/test/java/org/mage/test/cards/triggers/combat/damage/HuntersInsightTest.java rename to Mage.Tests/src/test/java/org/mage/test/cards/triggers/damage/HuntersInsightTest.java index bc3680730b8..5ea8c51d069 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/combat/damage/HuntersInsightTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/damage/HuntersInsightTest.java @@ -1,4 +1,4 @@ -package org.mage.test.cards.triggers.combat.damage; +package org.mage.test.cards.triggers.damage; import mage.constants.PhaseStep; import mage.constants.Zone; diff --git a/Mage/src/main/java/mage/abilities/effects/common/ShuffleHandIntoLibraryDrawThatManySourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ShuffleHandIntoLibraryDrawThatManySourceEffect.java new file mode 100644 index 00000000000..ae9dd269880 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/ShuffleHandIntoLibraryDrawThatManySourceEffect.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 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 ShuffleHandIntoLibraryDrawThatManySourceEffect extends OneShotEffect { + + public ShuffleHandIntoLibraryDrawThatManySourceEffect() { + super(Outcome.DrawCard); + this.staticText = "shuffle the cards from your hand into your library, then draw that many cards"; + } + + public ShuffleHandIntoLibraryDrawThatManySourceEffect(final ShuffleHandIntoLibraryDrawThatManySourceEffect effect) { + super(effect); + } + + @Override + public ShuffleHandIntoLibraryDrawThatManySourceEffect copy() { + return new ShuffleHandIntoLibraryDrawThatManySourceEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + int cardsHand = controller.getHand().size(); + if (cardsHand > 0) { + controller.moveCards(controller.getHand(), Zone.LIBRARY, source, game); + controller.shuffleLibrary(game); + game.applyEffects(); // then + controller.drawCards(cardsHand, game); + } + return true; + } + return false; + } +}