[ONE] Implement Mindsplice Apparatus

This commit is contained in:
theelk801 2023-01-14 20:36:47 -05:00
parent f520d7de2f
commit 10d999a3c9
2 changed files with 95 additions and 0 deletions

View file

@ -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);
}
}

View file

@ -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));