From 59746cca01a4b5fc5358bc86fc1d719637c48f23 Mon Sep 17 00:00:00 2001 From: Jeff Date: Wed, 26 Jul 2017 16:55:41 -0500 Subject: [PATCH] - Added a requested card Katabatic Winds. --- .../src/mage/cards/k/KatabaticWinds.java | 165 ++++++++++++++++++ Mage.Sets/src/mage/sets/Visions.java | 3 +- 2 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 Mage.Sets/src/mage/cards/k/KatabaticWinds.java diff --git a/Mage.Sets/src/mage/cards/k/KatabaticWinds.java b/Mage.Sets/src/mage/cards/k/KatabaticWinds.java new file mode 100644 index 0000000000..f61aeda5c3 --- /dev/null +++ b/Mage.Sets/src/mage/cards/k/KatabaticWinds.java @@ -0,0 +1,165 @@ +/* + * 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.k; + +import java.util.Optional; +import java.util.UUID; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; +import mage.abilities.effects.RestrictionEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.abilities.keyword.PhasingAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.mageobject.AbilityPredicate; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; + +/** + * + * @author jeffwadsworth + */ +public class KatabaticWinds extends CardImpl { + + public KatabaticWinds(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{G}"); + + // Phasing + this.addAbility(PhasingAbility.getInstance()); + + // Creatures with flying can't attack or block, and their activated abilities with {tap} in their costs can't be activated. + Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new KatabaticWindsRestrictionEffect()); + ability.addEffect(new KatabaticWindsRuleModifyingEffect()); + this.addAbility(ability); + + } + + public KatabaticWinds(final KatabaticWinds card) { + super(card); + } + + @Override + public KatabaticWinds copy() { + return new KatabaticWinds(this); + } +} + +class KatabaticWindsRestrictionEffect extends RestrictionEffect { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent(); + + static { + filter.add(new AbilityPredicate(FlyingAbility.class)); + } + + public KatabaticWindsRestrictionEffect() { + super(Duration.WhileOnBattlefield); + staticText = "Creatures with flying can't attack or block"; + } + + public KatabaticWindsRestrictionEffect(final KatabaticWindsRestrictionEffect effect) { + super(effect); + } + + @Override + public KatabaticWindsRestrictionEffect copy() { + return new KatabaticWindsRestrictionEffect(this); + } + + @Override + public boolean canAttack(Game game) { + return false; + } + + @Override + public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) { + return false; + } + + @Override + public boolean applies(Permanent permanent, Ability source, Game game) { + return filter.match(permanent, source.getSourceId(), source.getControllerId(), game); + } +} + +class KatabaticWindsRuleModifyingEffect extends ContinuousRuleModifyingEffectImpl { + + public KatabaticWindsRuleModifyingEffect() { + super(Duration.WhileOnBattlefield, Outcome.Detriment); + staticText = ", and their activated abilities with {tap} in their costs can't be activated"; + } + + public KatabaticWindsRuleModifyingEffect(final KatabaticWindsRuleModifyingEffect effect) { + super(effect); + } + + @Override + public KatabaticWindsRuleModifyingEffect copy() { + return new KatabaticWindsRuleModifyingEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ACTIVATE_ABILITY; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + MageObject object = game.getObject(event.getSourceId()); + Optional ability = game.getAbility(event.getTargetId(), event.getSourceId()); + if (ability.isPresent() + && object != null + && object.isCreature() + && object.getAbilities().contains(FlyingAbility.getInstance()) + && game.getState().getPlayersInRange(source.getControllerId(), game).contains(event.getPlayerId())) { + if (ability.get().getCosts().stream().anyMatch((cost) -> (cost instanceof TapSourceCost))) { + return true; + } + } + return false; + } + + @Override + public String getInfoMessage(Ability source, GameEvent event, Game game) { + return "Creatures with flying can't use their activated abilities that use {tap} in their costs."; + } +} diff --git a/Mage.Sets/src/mage/sets/Visions.java b/Mage.Sets/src/mage/sets/Visions.java index 8a7d95848c..f4f5d16e3b 100644 --- a/Mage.Sets/src/mage/sets/Visions.java +++ b/Mage.Sets/src/mage/sets/Visions.java @@ -70,7 +70,7 @@ public class Visions extends ExpansionSet { cards.add(new SetCardInfo("Creeping Mold", 53, Rarity.UNCOMMON, mage.cards.c.CreepingMold.class)); cards.add(new SetCardInfo("Crypt Rats", 5, Rarity.COMMON, mage.cards.c.CryptRats.class)); cards.add(new SetCardInfo("Daraja Griffin", 102, Rarity.UNCOMMON, mage.cards.d.DarajaGriffin.class)); - cards.add(new SetCardInfo("Dark Privilege", 6, Rarity.COMMON, mage.cards.d.DarkPrivilege.class)); + cards.add(new SetCardInfo("Dark Privilege", 6, Rarity.COMMON, mage.cards.d.DarkPrivilege.class)); cards.add(new SetCardInfo("Death Watch", 7, Rarity.COMMON, mage.cards.d.DeathWatch.class)); cards.add(new SetCardInfo("Desertion", 30, Rarity.RARE, mage.cards.d.Desertion.class)); cards.add(new SetCardInfo("Diamond Kaleidoscope", 143, Rarity.RARE, mage.cards.d.DiamondKaleidoscope.class)); @@ -107,6 +107,7 @@ public class Visions extends ExpansionSet { cards.add(new SetCardInfo("Jungle Basin", 164, Rarity.UNCOMMON, mage.cards.j.JungleBasin.class)); cards.add(new SetCardInfo("Kaervek's Spite", 13, Rarity.RARE, mage.cards.k.KaerveksSpite.class)); cards.add(new SetCardInfo("Karoo", 165, Rarity.UNCOMMON, mage.cards.k.Karoo.class)); + cards.add(new SetCardInfo("Katabatic Winds", 59, Rarity.RARE, mage.cards.k.KatabaticWinds.class)); cards.add(new SetCardInfo("Keeper of Kookus", 85, Rarity.COMMON, mage.cards.k.KeeperOfKookus.class)); cards.add(new SetCardInfo("King Cheetah", 60, Rarity.COMMON, mage.cards.k.KingCheetah.class)); cards.add(new SetCardInfo("Knight of Valor", 111, Rarity.COMMON, mage.cards.k.KnightOfValor.class));