From 57fc5043190f65a9d673b983a2ee88c73d019a10 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Tue, 7 Jan 2020 08:19:42 -0500 Subject: [PATCH] Implemented Callaphe, Beloved of the Sea --- .../mage/cards/c/CallapheBelovedOfTheSea.java | 111 ++++++++++++++++++ .../src/mage/sets/TherosBeyondDeath.java | 1 + 2 files changed, 112 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/c/CallapheBelovedOfTheSea.java diff --git a/Mage.Sets/src/mage/cards/c/CallapheBelovedOfTheSea.java b/Mage.Sets/src/mage/cards/c/CallapheBelovedOfTheSea.java new file mode 100644 index 00000000000..447db9f811f --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/CallapheBelovedOfTheSea.java @@ -0,0 +1,111 @@ +package mage.cards.c; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.SpellAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.dynamicvalue.common.DevotionCount; +import mage.abilities.effects.common.continuous.GainAbilityControlledEffect; +import mage.abilities.effects.common.continuous.SetPowerSourceEffect; +import mage.abilities.effects.common.cost.CostModificationEffectImpl; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.FilterPermanent; +import mage.filter.predicate.Predicates; +import mage.game.Game; +import mage.target.Target; +import mage.util.CardUtil; + +import java.util.Collection; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class CallapheBelovedOfTheSea extends CardImpl { + + private static final FilterPermanent filter + = new FilterPermanent("creatures and enchantments"); + + static { + filter.add(Predicates.or( + CardType.CREATURE.getPredicate(), + CardType.ENCHANTMENT.getPredicate() + )); + } + + public CallapheBelovedOfTheSea(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT, CardType.CREATURE}, "{1}{U}{U}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.DEMIGOD); + this.power = new MageInt(0); + this.toughness = new MageInt(3); + + // Callaphe's power is equal to your to devotion to blue. + this.addAbility(new SimpleStaticAbility( + Zone.ALL, new SetPowerSourceEffect(DevotionCount.U, Duration.EndOfGame) + .setText("{this}'s power is equal to your devotion to blue") + ).addHint(DevotionCount.U.getHint())); + + // Creatures and enchantments you control have "Spells your opponents cast that target this permanent cost {1} more to cast". + this.addAbility(new SimpleStaticAbility(new GainAbilityControlledEffect( + new SimpleStaticAbility( + new CallapheBelovedOfTheSeaEffect() + ), Duration.WhileOnBattlefield, filter + ))); + } + + private CallapheBelovedOfTheSea(final CallapheBelovedOfTheSea card) { + super(card); + } + + @Override + public CallapheBelovedOfTheSea copy() { + return new CallapheBelovedOfTheSea(this); + } +} + +class CallapheBelovedOfTheSeaEffect extends CostModificationEffectImpl { + + CallapheBelovedOfTheSeaEffect() { + super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.INCREASE_COST); + staticText = "Spells your opponents cast that target this permanent cost {1} more to cast"; + } + + private CallapheBelovedOfTheSeaEffect(CallapheBelovedOfTheSeaEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source, Ability abilityToModify) { + SpellAbility spellAbility = (SpellAbility) abilityToModify; + CardUtil.adjustCost(spellAbility, -1); + return true; + } + + @Override + public boolean applies(Ability abilityToModify, Ability source, Game game) { + if (!(abilityToModify instanceof SpellAbility) + || !game.getOpponents(source.getControllerId()).contains(abilityToModify.getControllerId())) { + return false; + } + return abilityToModify + .getModes() + .getSelectedModes() + .stream() + .map(uuid -> abilityToModify.getModes().get(uuid)) + .map(Mode::getTargets) + .flatMap(Collection::stream) + .map(Target::getTargets) + .flatMap(Collection::stream) + .anyMatch(uuid -> uuid.equals(source.getSourceId())); + } + + @Override + public CallapheBelovedOfTheSeaEffect copy() { + return new CallapheBelovedOfTheSeaEffect(this); + } +} diff --git a/Mage.Sets/src/mage/sets/TherosBeyondDeath.java b/Mage.Sets/src/mage/sets/TherosBeyondDeath.java index ea49d14fbc2..83c62988751 100644 --- a/Mage.Sets/src/mage/sets/TherosBeyondDeath.java +++ b/Mage.Sets/src/mage/sets/TherosBeyondDeath.java @@ -41,6 +41,7 @@ public final class TherosBeyondDeath extends ExpansionSet { cards.add(new SetCardInfo("Banishing Light", 4, Rarity.UNCOMMON, mage.cards.b.BanishingLight.class)); cards.add(new SetCardInfo("Blood Aspirant", 128, Rarity.UNCOMMON, mage.cards.b.BloodAspirant.class)); cards.add(new SetCardInfo("Brine Giant", 44, Rarity.COMMON, mage.cards.b.BrineGiant.class)); + cards.add(new SetCardInfo("Callaphe, Beloved of the Sea", 45, Rarity.UNCOMMON, mage.cards.c.CallapheBelovedOfTheSea.class)); cards.add(new SetCardInfo("Careless Celebrant", 129, Rarity.UNCOMMON, mage.cards.c.CarelessCelebrant.class)); cards.add(new SetCardInfo("Chainweb Aracnir", 167, Rarity.UNCOMMON, mage.cards.c.ChainwebAracnir.class)); cards.add(new SetCardInfo("Cling to Dust", 87, Rarity.UNCOMMON, mage.cards.c.ClingToDust.class));