From 7dcbc0f44129e7b9dd94b1a770f6269907149d3f Mon Sep 17 00:00:00 2001 From: spjspj Date: Thu, 8 Feb 2018 01:14:25 +1100 Subject: [PATCH] Implementing Snow Mercy (HHO) - Christmas Special Occasion card --- Mage.Sets/src/mage/cards/s/SnowMercy.java | 173 ++++++++++++++++++ Mage.Sets/src/mage/sets/HappyHolidays.java | 24 +++ .../main/java/mage/counters/CounterType.java | 1 + Utils/known-sets.txt | 3 +- Utils/mtg-cards-data.txt | 1 + Utils/mtg-sets-data.txt | 1 + 6 files changed, 202 insertions(+), 1 deletion(-) create mode 100644 Mage.Sets/src/mage/cards/s/SnowMercy.java create mode 100644 Mage.Sets/src/mage/sets/HappyHolidays.java diff --git a/Mage.Sets/src/mage/cards/s/SnowMercy.java b/Mage.Sets/src/mage/cards/s/SnowMercy.java new file mode 100644 index 0000000000..9aed747317 --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/SnowMercy.java @@ -0,0 +1,173 @@ +/* + * 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.s; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.Cost; +import mage.abilities.costs.CostImpl; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.TapAllEffect; +import mage.abilities.effects.common.counter.AddCountersTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SuperType; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.CounterPredicate; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author spjspj + */ +public class SnowMercy extends CardImpl { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures with globe counters on them"); + + static { + filter.add(new CounterPredicate(CounterType.GLOBE)); + } + + public SnowMercy(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}{W}"); + + addSuperType(SuperType.SNOW); + + // Whenever a creature deals damage to you, put a globe counter on it. + this.addAbility(new AddGlobeCountersAbility()); + + // {t},{q},{t},{q},{t}: Tap all creatures with globe counters on them. + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new TapAllEffect(filter), new SnowMercyCost()); + this.addAbility(ability); + } + + public SnowMercy(final SnowMercy card) { + super(card); + } + + @Override + public SnowMercy copy() { + return new SnowMercy(this); + } +} + +class AddGlobeCountersAbility extends TriggeredAbilityImpl { + + public AddGlobeCountersAbility() { + super(Zone.BATTLEFIELD, new AddCountersTargetEffect(CounterType.GLOBE.createInstance())); + } + + public AddGlobeCountersAbility(final AddGlobeCountersAbility ability) { + super(ability); + } + + @Override + public AddGlobeCountersAbility copy() { + return new AddGlobeCountersAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.DAMAGED_PLAYER; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getPlayerId().equals(this.getControllerId())) { + Permanent permanent = game.getPermanent(event.getSourceId()); + if (permanent != null && permanent.isCreature()) { + for (Effect effect : this.getEffects()) { + effect.setTargetPointer(new FixedTarget(event.getSourceId())); + } + return true; + } + } + return false; + } + + @Override + public String getRule() { + return "Whenever a creature deals damage to you, put a globe counter on it."; + } + +} + +class SnowMercyCost extends CostImpl { + + SnowMercyCost() { + this.text = "{t}, {q}, {t}, {q}, {t}"; + } + + SnowMercyCost(final SnowMercyCost cost) { + super(cost); + } + + @Override + public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { + Player controller = game.getPlayer(controllerId); + Permanent permanent = game.getPermanent(sourceId); + if (controller != null && permanent != null) { + // Tap, Untap, Tap, Untap, Tap: + if (!permanent.isTapped() && permanent.tap(game)) { + if (permanent.isTapped() && permanent.untap(game)) { + if (!permanent.isTapped() && permanent.tap(game)) { + if (permanent.isTapped() && permanent.untap(game)) { + if (!permanent.isTapped() && permanent.tap(game)) { + paid = true; + } + } + } + } + } + } + return paid; + } + + @Override + public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) { + Permanent permanent = game.getPermanent(sourceId); + if (permanent != null) { + return !permanent.isTapped(); + } + return false; + } + + @Override + public SnowMercyCost copy() { + return new SnowMercyCost(this); + } +} diff --git a/Mage.Sets/src/mage/sets/HappyHolidays.java b/Mage.Sets/src/mage/sets/HappyHolidays.java new file mode 100644 index 0000000000..25a465b3dd --- /dev/null +++ b/Mage.Sets/src/mage/sets/HappyHolidays.java @@ -0,0 +1,24 @@ +package mage.sets; + +import mage.cards.ExpansionSet; +import mage.constants.Rarity; +import mage.constants.SetType; + +/** + * + * @author spjspj + */ +public class HappyHolidays extends ExpansionSet { + + private static final HappyHolidays instance = new HappyHolidays(); + + public static HappyHolidays getInstance() { + return instance; + } + + private HappyHolidays() { + super("Happy Holidays", "HHO", ExpansionSet.buildDate(2006, 12, 31), SetType.JOKESET); + + cards.add(new SetCardInfo("Snow Mercy", 10, Rarity.RARE, mage.cards.s.SnowMercy.class)); + } +} diff --git a/Mage/src/main/java/mage/counters/CounterType.java b/Mage/src/main/java/mage/counters/CounterType.java index 7bb68a95c7..b35d19ce2a 100644 --- a/Mage/src/main/java/mage/counters/CounterType.java +++ b/Mage/src/main/java/mage/counters/CounterType.java @@ -70,6 +70,7 @@ public enum CounterType { FURY("fury"), FUNGUS("fungus"), FUSE("fuse"), + GLOBE("globe"), GOLD("gold"), GROWTH("growth"), HATCHLING("hatchling"), diff --git a/Utils/known-sets.txt b/Utils/known-sets.txt index f16d61f439..5523793b48 100644 --- a/Utils/known-sets.txt +++ b/Utils/known-sets.txt @@ -89,6 +89,7 @@ Gatecrash|Gatecrash| Grand Prix|GrandPrix| Guildpact|Guildpact| Guru|Guru| +Happy Holidays|HappyHolidays| HASCON Promo 2017|HasconPromo2017| Heroes of the Realm|HeroesOfTheRealm| Homelands|Homelands| @@ -196,4 +197,4 @@ World Magic Cup Qualifier|WorldMagicCupQualifier| Worldwake|Worldwake| WPN Gateway|WPNGateway| Zendikar|Zendikar| -Zendikar Expeditions|ZendikarExpeditions| \ No newline at end of file +Zendikar Expeditions|ZendikarExpeditions| diff --git a/Utils/mtg-cards-data.txt b/Utils/mtg-cards-data.txt index 1eb98fc23c..ac578a8c98 100644 --- a/Utils/mtg-cards-data.txt +++ b/Utils/mtg-cards-data.txt @@ -33074,3 +33074,4 @@ Rock Lobster|Unglued|79|C|{4}|Artifact Creature - Lobster|4|3| Creatures named S Scissors Lizard|Unglued|80|C|{4}|Artifact Creature - Lizard|4|3| Creatures named Paper Tiger can't attack or block.| Spatula of the Ages|Unglued|81|U|{4}|Artifact|||{4}, {T}, Sacrifice Spatula of the Ages: You may put a silver-bordered permanent card from your hand onto the battlefield.| Urza's Science Fair Project|Unglued|83|U|{6}|Artifact Creature - Construct|4|4| {2}: Roll a six-sided die. Urza's Science Fair Project gets the indicated result. 1 - It gets -2/-2 until end of turn. 2 - Prevent all combat damage it would deal this turn. 3 - It gains vigilance until end of turn. 4 - It gains first strike until end of turn. 5 - It gains flying until end of turn. 6 - It gets +2/+2 until end of turn.| +Snow Mercy|Happy Holidays|10|R|{2}{W}{W}|Snow Enchantment|||Whenever a creature deals damage to you, put a globe counter on it.${t},{untap},{t},{untap},{t}: Tap all creatures with globe counters on them.| diff --git a/Utils/mtg-sets-data.txt b/Utils/mtg-sets-data.txt index e5bd417a30..9a6faa767d 100644 --- a/Utils/mtg-sets-data.txt +++ b/Utils/mtg-sets-data.txt @@ -206,3 +206,4 @@ Worldwake|WWK| Ixalan|XLN| Zendikar|ZEN| Star Wars|SWS| +Happy Holidays|HHO|