From 7082e174eebf330c88dba98e6745a91cc297f203 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 26 May 2022 09:04:16 -0400 Subject: [PATCH] [CLB] Implemented Font of Magic --- Mage.Sets/src/mage/cards/f/FontOfMagic.java | 77 +++++++++++++++++++ .../CommanderLegendsBattleForBaldursGate.java | 1 + 2 files changed, 78 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/f/FontOfMagic.java diff --git a/Mage.Sets/src/mage/cards/f/FontOfMagic.java b/Mage.Sets/src/mage/cards/f/FontOfMagic.java new file mode 100644 index 00000000000..94f0c5931e5 --- /dev/null +++ b/Mage.Sets/src/mage/cards/f/FontOfMagic.java @@ -0,0 +1,77 @@ +package mage.cards.f; + +import mage.abilities.Ability; +import mage.abilities.SpellAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.dynamicvalue.common.CommanderCastCountValue; +import mage.abilities.effects.common.cost.CostModificationEffectImpl; +import mage.abilities.hint.Hint; +import mage.abilities.hint.ValueHint; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.CostModificationType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.game.Game; +import mage.util.CardUtil; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class FontOfMagic extends CardImpl { + + private static final Hint hint = new ValueHint( + "Commanders cast from command zone", CommanderCastCountValue.instance + ); + + public FontOfMagic(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{U}"); + + // Instant and sorcery spells you cast cost {1} less to cast for each time you've cast a commander from the command zone this game. + this.addAbility(new SimpleStaticAbility(new FontOfMagicEffect()).addHint(hint)); + } + + private FontOfMagic(final FontOfMagic card) { + super(card); + } + + @Override + public FontOfMagic copy() { + return new FontOfMagic(this); + } +} + +class FontOfMagicEffect extends CostModificationEffectImpl { + + FontOfMagicEffect() { + super(Duration.WhileOnStack, Outcome.Benefit, CostModificationType.REDUCE_COST); + staticText = "instant and sorcery spells you cast cost {1} less to cast " + + "for each time you've cast a commander from the command zone this game"; + } + + private FontOfMagicEffect(final FontOfMagicEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source, Ability abilityToModify) { + CardUtil.reduceCost(abilityToModify, Math.max(0, CommanderCastCountValue.instance.calculate(game, source, this))); + return true; + } + + @Override + public boolean applies(Ability abilityToModify, Ability source, Game game) { + return abilityToModify instanceof SpellAbility + && abilityToModify.isControlledBy(source.getControllerId()) + && ((SpellAbility) abilityToModify).getCharacteristics(game).isInstantOrSorcery(game) + && game.getCard(abilityToModify.getSourceId()) != null; + } + + @Override + public FontOfMagicEffect copy() { + return new FontOfMagicEffect(this); + } +} diff --git a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java index 9868571f423..a3ee99a84b3 100644 --- a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java +++ b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java @@ -88,6 +88,7 @@ public final class CommanderLegendsBattleForBaldursGate extends ExpansionSet { cards.add(new SetCardInfo("Fire Diamond", 313, Rarity.COMMON, mage.cards.f.FireDiamond.class)); cards.add(new SetCardInfo("Fireball", 175, Rarity.UNCOMMON, mage.cards.f.Fireball.class)); cards.add(new SetCardInfo("Flaming Fist", 18, Rarity.COMMON, mage.cards.f.FlamingFist.class)); + cards.add(new SetCardInfo("Font of Magic", 71, Rarity.MYTHIC, mage.cards.f.FontOfMagic.class)); cards.add(new SetCardInfo("Forest", 467, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Ganax, Astral Hunter", 176, Rarity.UNCOMMON, mage.cards.g.GanaxAstralHunter.class)); cards.add(new SetCardInfo("Gate Colossus", 315, Rarity.UNCOMMON, mage.cards.g.GateColossus.class));