diff --git a/Mage.Sets/src/mage/sets/fifthedition/StoneGiant.java b/Mage.Sets/src/mage/sets/fifthedition/StoneGiant.java new file mode 100644 index 0000000000..60f05f1fb9 --- /dev/null +++ b/Mage.Sets/src/mage/sets/fifthedition/StoneGiant.java @@ -0,0 +1,52 @@ +/* + * 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.fifthedition; + +import java.util.UUID; + +/** + * + * @author North + */ +public class StoneGiant extends mage.sets.magic2010.StoneGiant { + + public StoneGiant(UUID ownerId) { + super(ownerId); + this.cardNumber = 269; + this.expansionSetCode = "5ED"; + } + + public StoneGiant(final StoneGiant card) { + super(card); + } + + @Override + public StoneGiant copy() { + return new StoneGiant(this); + } +} diff --git a/Mage.Sets/src/mage/sets/magic2010/OpenTheVaults.java b/Mage.Sets/src/mage/sets/magic2010/OpenTheVaults.java new file mode 100644 index 0000000000..b565ff46fa --- /dev/null +++ b/Mage.Sets/src/mage/sets/magic2010/OpenTheVaults.java @@ -0,0 +1,119 @@ +/* + * 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.magic2010; + +import java.util.LinkedList; +import java.util.Set; +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Outcome; +import mage.Constants.Rarity; +import mage.Constants.Zone; +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.Cards; +import mage.game.Game; +import mage.players.Player; + +/** + * + * @author North + */ +public class OpenTheVaults extends CardImpl { + + public OpenTheVaults(UUID ownerId) { + super(ownerId, 21, "Open the Vaults", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{4}{W}{W}"); + this.expansionSetCode = "M10"; + + this.color.setWhite(true); + + // Return all artifact and enchantment cards from all graveyards to the battlefield under their owners' control. + this.getSpellAbility().addEffect(new OpenTheVaultsEffect()); + } + + public OpenTheVaults(final OpenTheVaults card) { + super(card); + } + + @Override + public OpenTheVaults copy() { + return new OpenTheVaults(this); + } +} + +class OpenTheVaultsEffect extends OneShotEffect { + + public OpenTheVaultsEffect() { + super(Outcome.PutCardInPlay); + this.staticText = "Return all artifact and enchantment cards from all graveyards to the battlefield under their owners' control"; + } + + public OpenTheVaultsEffect(final OpenTheVaultsEffect effect) { + super(effect); + } + + @Override + public OpenTheVaultsEffect copy() { + return new OpenTheVaultsEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player != null) { + LinkedList enchantments = new LinkedList(); + LinkedList artifacts = new LinkedList(); + + Set playerIds = player.getInRange(); + playerIds.add(player.getId()); + + for (UUID playerId : playerIds) { + Cards graveyard = game.getPlayer(playerId).getGraveyard(); + for (UUID cardId : graveyard) { + Card card = game.getCard(cardId); + if (card != null && card.getCardType().contains(CardType.ENCHANTMENT)) { + enchantments.add(card); + } + if (card != null && card.getCardType().contains(CardType.ARTIFACT)) { + artifacts.add(card); + } + } + } + + for (Card card : enchantments) { + card.putOntoBattlefield(game, Zone.GRAVEYARD, source.getId(), card.getOwnerId()); + } + for (Card card : artifacts) { + card.putOntoBattlefield(game, Zone.GRAVEYARD, source.getId(), card.getOwnerId()); + } + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/magic2010/StoneGiant.java b/Mage.Sets/src/mage/sets/magic2010/StoneGiant.java new file mode 100644 index 0000000000..456d4fef97 --- /dev/null +++ b/Mage.Sets/src/mage/sets/magic2010/StoneGiant.java @@ -0,0 +1,140 @@ +/* + * 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.magic2010; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Duration; +import mage.Constants.Outcome; +import mage.Constants.Rarity; +import mage.Constants.Zone; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.common.delayed.AtEndOfTurnDelayedTriggeredAbility; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DestroyTargetEffect; +import mage.abilities.effects.common.continious.GainAbilityTargetEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.CardImpl; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.TargetPermanent; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author North + */ +public class StoneGiant extends CardImpl { + + public StoneGiant(UUID ownerId) { + super(ownerId, 159, "Stone Giant", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{2}{R}{R}"); + this.expansionSetCode = "M10"; + this.subtype.add("Giant"); + + this.color.setRed(true); + this.power = new MageInt(3); + this.toughness = new MageInt(4); + // {tap}: Target creature you control with toughness less than Stone Giant's power gains flying until end of turn. + SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, + new GainAbilityTargetEffect(FlyingAbility.getInstance(), Duration.EndOfTurn), + new TapSourceCost()); + ability.addTarget(new StoneGiantTarget()); + // Destroy that creature at the beginning of the next end step. + ability.addEffect(new StoneGiantEffect()); + this.addAbility(ability); + } + + public StoneGiant(final StoneGiant card) { + super(card); + } + + @Override + public StoneGiant copy() { + return new StoneGiant(this); + } +} + +class StoneGiantTarget extends TargetPermanent { + + public StoneGiantTarget() { + super(new FilterControlledCreaturePermanent("creature you control with toughness less than {this}'s power")); + } + + public StoneGiantTarget(final StoneGiantTarget target) { + super(target); + } + + @Override + public StoneGiantTarget copy() { + return new StoneGiantTarget(this); + } + + @Override + public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) { + Permanent sourceCreature = game.getPermanent(source.getSourceId()); + Permanent targetCreature = game.getPermanent(id); + + if (targetCreature != null && sourceCreature != null + && targetCreature.getToughness().getValue() < sourceCreature.getPower().getValue()) { + return super.canTarget(controllerId, id, source, game); + } + return false; + } +} + +class StoneGiantEffect extends OneShotEffect { + + public StoneGiantEffect() { + super(Outcome.Detriment); + this.staticText = "Destroy that creature at the beginning of the next end step"; + } + + public StoneGiantEffect(final StoneGiantEffect effect) { + super(effect); + } + + @Override + public StoneGiantEffect copy() { + return new StoneGiantEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + DestroyTargetEffect effect = new DestroyTargetEffect(); + effect.setTargetPointer(new FixedTarget(source.getFirstTarget())); + AtEndOfTurnDelayedTriggeredAbility delayedAbility = new AtEndOfTurnDelayedTriggeredAbility(effect); + delayedAbility.setSourceId(source.getSourceId()); + delayedAbility.setControllerId(source.getControllerId()); + game.addDelayedTriggeredAbility(delayedAbility); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/magic2010/VampireNocturnus.java b/Mage.Sets/src/mage/sets/magic2010/VampireNocturnus.java new file mode 100644 index 0000000000..49ea4c50ec --- /dev/null +++ b/Mage.Sets/src/mage/sets/magic2010/VampireNocturnus.java @@ -0,0 +1,123 @@ +/* + * 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.magic2010; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Duration; +import mage.Constants.Rarity; +import mage.Constants.Zone; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.StaticAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.condition.Condition; +import mage.abilities.decorator.ConditionalContinousEffect; +import mage.abilities.effects.common.continious.*; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.CardImpl; +import mage.filter.common.FilterCreaturePermanent; +import mage.game.Game; + +/** + * + * @author North + */ +public class VampireNocturnus extends CardImpl { + + public VampireNocturnus(UUID ownerId) { + super(ownerId, 118, "Vampire Nocturnus", Rarity.MYTHIC, new CardType[]{CardType.CREATURE}, "{1}{B}{B}{B}"); + this.expansionSetCode = "M10"; + this.subtype.add("Vampire"); + + this.color.setBlack(true); + this.power = new MageInt(3); + this.toughness = new MageInt(3); + + // Play with the top card of your library revealed. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PlayWithTheTopCardRevealedEffect())); + // As long as the top card of your library is black, Vampire Nocturnus and other Vampire creatures you control get +2/+1 and have flying. + this.addAbility(new VampireNocturnusAbility()); + } + + public VampireNocturnus(final VampireNocturnus card) { + super(card); + } + + @Override + public VampireNocturnus copy() { + return new VampireNocturnus(this); + } +} + +class VampireNocturnusAbility extends StaticAbility { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent(); + + static { + filter.getSubtype().add("Vampire"); + } + + public VampireNocturnusAbility() { + super(Zone.BATTLEFIELD, null); + this.addEffect(new ConditionalContinousEffect( + new BoostSourceEffect(2, 1, Duration.WhileOnBattlefield), + new VampireNocturnusCondition(), "")); + this.addEffect(new ConditionalContinousEffect( + new BoostControlledEffect(2, 1, Duration.WhileOnBattlefield, filter, true), + new VampireNocturnusCondition(), "")); + this.addEffect( + new ConditionalContinousEffect(new GainAbilitySourceEffect(FlyingAbility.getInstance()), + new VampireNocturnusCondition(), "")); + this.addEffect( + new ConditionalContinousEffect(new GainAbilityControlledEffect(FlyingAbility.getInstance(), Duration.WhileOnBattlefield, filter, true), + new VampireNocturnusCondition(), "")); + } + + public VampireNocturnusAbility(VampireNocturnusAbility ability) { + super(ability); + } + + @Override + public VampireNocturnusAbility copy() { + return new VampireNocturnusAbility(this); + } + + @Override + public String getRule() { + return "As long as the top card of your library is black, {this} and other Vampire creatures you control get +2/+1 and have flying."; + } +} + +class VampireNocturnusCondition implements Condition { + + @Override + public boolean apply(Game game, Ability source) { + return game.getPlayer(source.getControllerId()).getLibrary().getFromTop(game).getColor().isBlack(); + } +} diff --git a/Mage.Sets/src/mage/sets/zendikar/Electropotence.java b/Mage.Sets/src/mage/sets/zendikar/Electropotence.java new file mode 100644 index 0000000000..9cba0f9ecd --- /dev/null +++ b/Mage.Sets/src/mage/sets/zendikar/Electropotence.java @@ -0,0 +1,154 @@ +/* + * 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.zendikar; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Outcome; +import mage.Constants.Rarity; +import mage.Constants.Zone; +import mage.abilities.Ability; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.ZoneChangeEvent; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.common.TargetCreatureOrPlayer; + +/** + * + * @author North + */ +public class Electropotence extends CardImpl { + + public Electropotence(UUID ownerId) { + super(ownerId, 122, "Electropotence", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{2}{R}"); + this.expansionSetCode = "ZEN"; + + this.color.setRed(true); + + // Whenever a creature enters the battlefield under your control, you may pay {2}{R}. If you do, that creature deals damage equal to its power to target creature or player. + Ability ability = new ElectropotenceTriggeredAbility(); + ability.addTarget(new TargetCreatureOrPlayer()); + this.addAbility(ability); + } + + public Electropotence(final Electropotence card) { + super(card); + } + + @Override + public Electropotence copy() { + return new Electropotence(this); + } +} + +class ElectropotenceTriggeredAbility extends TriggeredAbilityImpl { + + public ElectropotenceTriggeredAbility() { + super(Zone.BATTLEFIELD, new ElectropotenceEffect()); + this.costs.add(new ManaCostsImpl("{2}{R}")); + } + + public ElectropotenceTriggeredAbility(ElectropotenceTriggeredAbility ability) { + super(ability); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.ZONE_CHANGE) { + Permanent permanent = game.getPermanent(event.getTargetId()); + if (((ZoneChangeEvent) event).getToZone() == Zone.BATTLEFIELD + && permanent.getCardType().contains(CardType.CREATURE) + && permanent.getControllerId().equals(this.controllerId)) { + Player player = game.getPlayer(this.getControllerId()); + Card card = game.getCard(event.getTargetId()); + if (player != null && card != null && player.chooseUse(Outcome.Damage, "Pay {2}{R}? If you do, " + card.getName() + " deals damage equal to its power to target creature or player.", game)) { + this.getEffects().get(0).setValue("damageSource", event.getTargetId()); + return true; + } + } + } + return false; + } + + @Override + public String getRule() { + return "Whenever a creature enters the battlefield under your control, you may pay {2}{R}. If you do, that creature deals damage equal to its power to target creature or player."; + } + + @Override + public ElectropotenceTriggeredAbility copy() { + return new ElectropotenceTriggeredAbility(this); + } +} + +class ElectropotenceEffect extends OneShotEffect { + + public ElectropotenceEffect() { + super(Outcome.Damage); + } + + public ElectropotenceEffect(final ElectropotenceEffect effect) { + super(effect); + } + + @Override + public ElectropotenceEffect copy() { + return new ElectropotenceEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + UUID creatureId = (UUID) getValue("damageSource"); + Permanent creature = game.getPermanent(creatureId); + if (creature == null) { + creature = (Permanent) game.getLastKnownInformation(creatureId, Zone.BATTLEFIELD); + } + if (creature != null) { + int amount = creature.getPower().getValue(); + UUID target = source.getTargets().getFirstTarget(); + Permanent targetCreature = game.getPermanent(target); + if (targetCreature != null) { + targetCreature.damage(amount, creature.getId(), game, true, false); + return true; + } + Player player = game.getPlayer(target); + if (player != null) { + player.damage(amount, creature.getId(), game, false, true); + return true; + } + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/zendikar/QuestForAncientSecrets.java b/Mage.Sets/src/mage/sets/zendikar/QuestForAncientSecrets.java new file mode 100644 index 0000000000..5cd75e8cec --- /dev/null +++ b/Mage.Sets/src/mage/sets/zendikar/QuestForAncientSecrets.java @@ -0,0 +1,143 @@ +/* + * 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.zendikar; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Outcome; +import mage.Constants.Rarity; +import mage.Constants.Zone; +import mage.abilities.Ability; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.RemoveCountersSourceCost; +import mage.abilities.costs.common.SacrificeSourceCost; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.ZoneChangeEvent; +import mage.players.Player; +import mage.target.TargetPlayer; + +/** + * + * @author North + */ +public class QuestForAncientSecrets extends CardImpl { + + public QuestForAncientSecrets(UUID ownerId) { + super(ownerId, 59, "Quest for Ancient Secrets", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{U}"); + this.expansionSetCode = "ZEN"; + + this.color.setBlue(true); + + // Whenever a card is put into your graveyard from anywhere, you may put a quest counter on Quest for Ancient Secrets. + this.addAbility(new QuestForAncientSecretsTriggeredAbility()); + // Remove five quest counters from Quest for Ancient Secrets and sacrifice it: Target player shuffles his or her graveyard into his or her library. + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, + new QuestForAncientSecretsEffect(), + new RemoveCountersSourceCost(CounterType.QUEST.createInstance(5))); + ability.addCost(new SacrificeSourceCost()); + ability.addTarget(new TargetPlayer()); + this.addAbility(ability); + } + + public QuestForAncientSecrets(final QuestForAncientSecrets card) { + super(card); + } + + @Override + public QuestForAncientSecrets copy() { + return new QuestForAncientSecrets(this); + } +} + +class QuestForAncientSecretsTriggeredAbility extends TriggeredAbilityImpl { + + public QuestForAncientSecretsTriggeredAbility() { + super(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.QUEST.createInstance()), true); + } + + public QuestForAncientSecretsTriggeredAbility(final QuestForAncientSecretsTriggeredAbility ability) { + super(ability); + } + + @Override + public QuestForAncientSecretsTriggeredAbility copy() { + return new QuestForAncientSecretsTriggeredAbility(this); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD) { + Card card = game.getCard(event.getTargetId()); + if (card != null && card.getOwnerId().equals(this.getControllerId())) { + return true; + } + } + return false; + } + + @Override + public String getRule() { + return "Whenever a card is put into your graveyard from anywhere, you may put a quest counter on {this}"; + } +} + +class QuestForAncientSecretsEffect extends OneShotEffect { + + public QuestForAncientSecretsEffect() { + super(Outcome.Neutral); + this.staticText = "Target player shuffles his or her graveyard into his or her library"; + } + + public QuestForAncientSecretsEffect(final QuestForAncientSecretsEffect effect) { + super(effect); + } + + @Override + public QuestForAncientSecretsEffect copy() { + return new QuestForAncientSecretsEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getFirstTarget()); + if (player != null) { + player.getLibrary().addAll(player.getGraveyard().getCards(game), game); + player.getGraveyard().clear(); + player.getLibrary().shuffle(); + return true; + } + return false; + } +}