From 37577a8a4ae74cd769ba79dc8f93c883cde792a5 Mon Sep 17 00:00:00 2001 From: Loki Date: Wed, 1 Aug 2012 09:49:28 +1200 Subject: [PATCH] [PLC] Calciderm --- .../src/mage/sets/planarchaos/Calciderm.java | 71 +++++++++++++++++++ .../abilities/keyword/VanishingAbility.java | 60 ++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 Mage.Sets/src/mage/sets/planarchaos/Calciderm.java create mode 100644 Mage/src/mage/abilities/keyword/VanishingAbility.java diff --git a/Mage.Sets/src/mage/sets/planarchaos/Calciderm.java b/Mage.Sets/src/mage/sets/planarchaos/Calciderm.java new file mode 100644 index 0000000000..9f95a78843 --- /dev/null +++ b/Mage.Sets/src/mage/sets/planarchaos/Calciderm.java @@ -0,0 +1,71 @@ +/* + * 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.planarchaos; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.MageInt; +import mage.abilities.common.EntersBattlefieldAbility; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.abilities.keyword.ShroudAbility; +import mage.abilities.keyword.VanishingAbility; +import mage.cards.CardImpl; +import mage.counters.CounterType; + +/** + * + * @author Loki + */ +public class Calciderm extends CardImpl { + + public Calciderm(UUID ownerId) { + super(ownerId, 23, "Calciderm", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{2}{W}{W}"); + this.expansionSetCode = "PLC"; + this.subtype.add("Beast"); + + this.color.setWhite(true); + this.power = new MageInt(5); + this.toughness = new MageInt(5); + + // Shroud + this.addAbility(ShroudAbility.getInstance()); + // Vanishing 4 + this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.TIME.createInstance(4)))); + this.addAbility(new VanishingAbility()); + } + + public Calciderm(final Calciderm card) { + super(card); + } + + @Override + public Calciderm copy() { + return new Calciderm(this); + } +} diff --git a/Mage/src/mage/abilities/keyword/VanishingAbility.java b/Mage/src/mage/abilities/keyword/VanishingAbility.java new file mode 100644 index 0000000000..b7db9bd872 --- /dev/null +++ b/Mage/src/mage/abilities/keyword/VanishingAbility.java @@ -0,0 +1,60 @@ +package mage.abilities.keyword; + +import mage.Constants; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.permanent.Permanent; + +public class VanishingAbility extends BeginningOfUpkeepTriggeredAbility { + public VanishingAbility() { + super(new VanishingEffect(), Constants.TargetController.YOU, false); + } + + public VanishingAbility(final VanishingAbility ability) { + super(ability); + } + + @Override + public BeginningOfUpkeepTriggeredAbility copy() { + return new VanishingAbility(this); + } + + @Override + public String getRule() { + return "Vanishing (This permanent enters the battlefield with time counters on it. At the beginning of your upkeep, remove a time counter from it. When the last is removed, sacrifice it.)"; + } +} + +class VanishingEffect extends OneShotEffect { + VanishingEffect() { + super(Constants.Outcome.Sacrifice); + } + + VanishingEffect(final VanishingEffect effect) { + super(effect); + } + + + @Override + public boolean apply(Game game, Ability source) { + Permanent p = game.getPermanent(source.getSourceId()); + if (p != null) { + int amount = p.getCounters().getCount(CounterType.TIME); + if (amount > 0) { + p.getCounters().removeCounter(CounterType.TIME, 1); + } else { + p.sacrifice(source.getSourceId(), game); + } + return true; + } + return false; + } + + @Override + public VanishingEffect copy() { + return new VanishingEffect(this); + } +} \ No newline at end of file