From 270951bf89a35a2f5f18e8353a9ac063dfe5a301 Mon Sep 17 00:00:00 2001 From: Jeff Date: Wed, 21 Mar 2018 17:19:01 -0500 Subject: [PATCH] - Added Dwarven Shrine. --- Mage.Sets/src/mage/cards/d/DwarvenShrine.java | 146 ++++++++++++++++++ Mage.Sets/src/mage/sets/Odyssey.java | 1 + 2 files changed, 147 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/d/DwarvenShrine.java diff --git a/Mage.Sets/src/mage/cards/d/DwarvenShrine.java b/Mage.Sets/src/mage/cards/d/DwarvenShrine.java new file mode 100644 index 00000000000..7cb9e59e6ca --- /dev/null +++ b/Mage.Sets/src/mage/cards/d/DwarvenShrine.java @@ -0,0 +1,146 @@ +/* + * 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.cards.d; + +import java.util.UUID; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.FilterCard; +import mage.filter.predicate.mageobject.NamePredicate; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.GameEvent.EventType; +import mage.game.stack.Spell; +import mage.players.Player; + +/** + * + * @author jeffwadsworth + */ +public class DwarvenShrine extends CardImpl { + + public DwarvenShrine(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{R}{R}"); + + + // Whenever a player casts a spell, Dwarven Shrine deals X damage to that player, where X is twice the number of cards in all graveyards with the same name as that spell. + this.addAbility(new DwarvenShrineTriggeredAbility()); + } + + public DwarvenShrine(final DwarvenShrine card) { + super(card); + } + + @Override + public DwarvenShrine copy() { + return new DwarvenShrine(this); + } +} + +class DwarvenShrineTriggeredAbility extends TriggeredAbilityImpl { + + public DwarvenShrineTriggeredAbility() { + super(Zone.BATTLEFIELD, new DwarvenShrineEffect(), false); + } + + public DwarvenShrineTriggeredAbility(final DwarvenShrineTriggeredAbility ability) { + super(ability); + } + + @Override + public DwarvenShrineTriggeredAbility copy() { + return new DwarvenShrineTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == EventType.SPELL_CAST; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + Spell spell = game.getStack().getSpell(event.getTargetId()); + MageObject mageObject = game.getObject(sourceId); + if (spell != null + && !spell.isCopy() + && spell.getCard() != null + && !spell.getCard().isCopy()) { + game.getState().setValue("dwarvenShrine" + mageObject, spell); + return true; + } + return false; + } +} + +class DwarvenShrineEffect extends OneShotEffect { + + public DwarvenShrineEffect() { + super(Outcome.Detriment); + staticText = "Whenever a player casts a spell, {this} deals X damage to that player, where X is twice the number of cards in all graveyards with the same name as that spell."; + } + + public DwarvenShrineEffect(final DwarvenShrineEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + int count = 0; + MageObject mageObject = game.getObject(source.getSourceId()); + Spell spell = (Spell) game.getState().getValue("dwarvenShrine" + mageObject); + if (spell != null) { + Player controller = game.getPlayer(spell.getControllerId()); + if (controller != null) { + String name = spell.getName(); + FilterCard filterCardName = new FilterCard(); + filterCardName.add(new NamePredicate(name)); + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { + Player player = game.getPlayer(playerId); + if (player != null) { + count += player.getGraveyard().count(filterCardName, game); + } + } + controller.damage(count * 2, mageObject.getId(), game, false, true); + return true; + } + } + return false; + } + + @Override + public DwarvenShrineEffect copy() { + return new DwarvenShrineEffect(this); + } +} diff --git a/Mage.Sets/src/mage/sets/Odyssey.java b/Mage.Sets/src/mage/sets/Odyssey.java index d5e1694f1c4..23e6e8578a9 100644 --- a/Mage.Sets/src/mage/sets/Odyssey.java +++ b/Mage.Sets/src/mage/sets/Odyssey.java @@ -153,6 +153,7 @@ public class Odyssey extends ExpansionSet { cards.add(new SetCardInfo("Dusk Imp", 131, Rarity.COMMON, mage.cards.d.DuskImp.class)); cards.add(new SetCardInfo("Dwarven Grunt", 185, Rarity.COMMON, mage.cards.d.DwarvenGrunt.class)); cards.add(new SetCardInfo("Dwarven Recruiter", 186, Rarity.UNCOMMON, mage.cards.d.DwarvenRecruiter.class)); + cards.add(new SetCardInfo("Dwarven Shrine", 187, Rarity.RARE, mage.cards.d.DwarvenShrine.class)); cards.add(new SetCardInfo("Dwarven Strike Force", 188, Rarity.UNCOMMON, mage.cards.d.DwarvenStrikeForce.class)); cards.add(new SetCardInfo("Earnest Fellowship", 21, Rarity.RARE, mage.cards.e.EarnestFellowship.class)); cards.add(new SetCardInfo("Earth Rift", 189, Rarity.COMMON, mage.cards.e.EarthRift.class));