From 10d999a3c9e0088418d4f57ed58f88a5fee6b803 Mon Sep 17 00:00:00 2001 From: theelk801 Date: Sat, 14 Jan 2023 20:36:47 -0500 Subject: [PATCH] [ONE] Implement Mindsplice Apparatus --- .../src/mage/cards/m/MindspliceApparatus.java | 94 +++++++++++++++++++ .../src/mage/sets/PhyrexiaAllWillBeOne.java | 1 + 2 files changed, 95 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/m/MindspliceApparatus.java diff --git a/Mage.Sets/src/mage/cards/m/MindspliceApparatus.java b/Mage.Sets/src/mage/cards/m/MindspliceApparatus.java new file mode 100644 index 0000000000..5e7d1317b6 --- /dev/null +++ b/Mage.Sets/src/mage/cards/m/MindspliceApparatus.java @@ -0,0 +1,94 @@ +package mage.cards.m; + +import java.util.Objects; +import java.util.Optional; +import java.util.UUID; + +import mage.abilities.Ability; +import mage.abilities.SpellAbility; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.common.cost.CostModificationEffectImpl; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.abilities.keyword.FlashAbility; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.util.CardUtil; + +/** + * @author TheElk801 + */ +public final class MindspliceApparatus extends CardImpl { + + public MindspliceApparatus(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}{U}"); + + // Flash + this.addAbility(FlashAbility.getInstance()); + + // At the beginning of your upkeep, put an oil counter on Mindsplice Apparatus. + this.addAbility(new BeginningOfUpkeepTriggeredAbility( + new AddCountersSourceEffect(CounterType.OIL.createInstance()), TargetController.YOU, false + )); + + // Instant and sorcery spells you cast cost {1} less to cast for each oil counter on Mindsplice Apparatus. + this.addAbility(new SimpleStaticAbility(new MindspliceApparatusEffect())); + } + + private MindspliceApparatus(final MindspliceApparatus card) { + super(card); + } + + @Override + public MindspliceApparatus copy() { + return new MindspliceApparatus(this); + } +} + +class MindspliceApparatusEffect extends CostModificationEffectImpl { + + MindspliceApparatusEffect() { + super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.REDUCE_COST); + staticText = "instant and sorcery spells you cast cost {1} less to cast for each oil counter on {this}"; + } + + MindspliceApparatusEffect(MindspliceApparatusEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source, Ability abilityToModify) { + int amount = Optional + .ofNullable(source.getSourcePermanentOrLKI(game)) + .filter(Objects::nonNull) + .map(permanent -> permanent.getCounters(game)) + .map(counters -> counters.getCount(CounterType.OIL)) + .orElse(0); + if (amount < 1) { + return false; + } + CardUtil.adjustCost((SpellAbility) abilityToModify, amount); + return true; + } + + @Override + public boolean applies(Ability abilityToModify, Ability source, Game game) { + if (!(abilityToModify instanceof SpellAbility)) { + return false; + } + Card sourceCard = game.getCard(abilityToModify.getSourceId()); + return sourceCard != null + && abilityToModify.isControlledBy(source.getControllerId()) + && sourceCard.isInstantOrSorcery(game); + } + + @Override + public MindspliceApparatusEffect copy() { + return new MindspliceApparatusEffect(this); + } +} diff --git a/Mage.Sets/src/mage/sets/PhyrexiaAllWillBeOne.java b/Mage.Sets/src/mage/sets/PhyrexiaAllWillBeOne.java index d0622251d8..f30f6aa7ec 100644 --- a/Mage.Sets/src/mage/sets/PhyrexiaAllWillBeOne.java +++ b/Mage.Sets/src/mage/sets/PhyrexiaAllWillBeOne.java @@ -30,6 +30,7 @@ public final class PhyrexiaAllWillBeOne extends ExpansionSet { cards.add(new SetCardInfo("Forest", 276, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Island", 273, Rarity.LAND, mage.cards.basiclands.Island.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Koth, Fire of Resistance", 138, Rarity.RARE, mage.cards.k.KothFireOfResistance.class)); + cards.add(new SetCardInfo("Mindsplice Apparatus", 63, Rarity.RARE, mage.cards.m.MindspliceApparatus.class)); cards.add(new SetCardInfo("Mirrex", 254, Rarity.RARE, mage.cards.m.Mirrex.class)); cards.add(new SetCardInfo("Mountain", 275, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Norn's Wellspring", 24, Rarity.RARE, mage.cards.n.NornsWellspring.class));