[C21] Implemented Geometric Nexus

This commit is contained in:
Evan Kranzler 2021-04-18 14:51:54 -04:00
parent 5238d7a50e
commit 9a40ea0335
3 changed files with 117 additions and 17 deletions

View file

@ -0,0 +1,104 @@
package mage.cards.g;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SpellCastAllTriggeredAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.RemoveAllCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.counters.CounterType;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.token.QuandrixToken;
import mage.game.stack.Spell;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class GeometricNexus extends CardImpl {
public GeometricNexus(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}");
// Whenever a player casts an instant or sorcery spell, put a number of charge counters on Geometric Nexus equal to that spell's mana value.
this.addAbility(new SpellCastAllTriggeredAbility(
new AddCountersSourceEffect(
CounterType.CHARGE.createInstance(0),
GeometricNexusMVValue.instance, false
).setText("put a number of charge counters on {this} equal to that spell's mana value"),
StaticFilters.FILTER_SPELL_AN_INSTANT_OR_SORCERY, false
));
// {6}, {T}, Remove all charge counters from Geometric Nexus: Create a 0/0 green and blue Fractal creature token. Put X +1/+1 counters on it, where X is the number of charge counters removed this way.
Ability ability = new SimpleActivatedAbility(QuandrixToken.getEffect(
GeometricNexusRemovedCounterValue.instance, "Put X +1/+1 counters on it, " +
"where X is the number of charge counters removed this way"
), new GenericManaCost(6));
ability.addCost(new TapSourceCost());
ability.addCost(new RemoveAllCountersSourceCost(CounterType.CHARGE));
this.addAbility(ability);
}
private GeometricNexus(final GeometricNexus card) {
super(card);
}
@Override
public GeometricNexus copy() {
return new GeometricNexus(this);
}
}
enum GeometricNexusMVValue implements DynamicValue {
instance;
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
Spell spell = (Spell) effect.getValue("spellCast");
return spell != null ? spell.getManaValue() : 0;
}
@Override
public GeometricNexusMVValue copy() {
return instance;
}
@Override
public String getMessage() {
return "";
}
}
enum GeometricNexusRemovedCounterValue implements DynamicValue {
instance;
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
int countersRemoved = 0;
for (Cost cost : sourceAbility.getCosts()) {
if (cost instanceof RemoveAllCountersSourceCost) {
countersRemoved = ((RemoveAllCountersSourceCost) cost).getRemovedCounters();
}
}
return countersRemoved;
}
@Override
public GeometricNexusRemovedCounterValue copy() {
return instance;
}
@Override
public String getMessage() {
return "";
}
}

View file

@ -126,6 +126,7 @@ public final class Commander2021Edition extends ExpansionSet {
cards.add(new SetCardInfo("Forgotten Cave", 289, Rarity.COMMON, mage.cards.f.ForgottenCave.class));
cards.add(new SetCardInfo("Garruk, Primal Hunter", 190, Rarity.MYTHIC, mage.cards.g.GarrukPrimalHunter.class));
cards.add(new SetCardInfo("Gaze of Granite", 217, Rarity.RARE, mage.cards.g.GazeOfGranite.class));
cards.add(new SetCardInfo("Geometric Nexus", 77, Rarity.RARE, mage.cards.g.GeometricNexus.class));
cards.add(new SetCardInfo("Ghostly Prison", 92, Rarity.UNCOMMON, mage.cards.g.GhostlyPrison.class));
cards.add(new SetCardInfo("Gideon, Champion of Justice", 93, Rarity.MYTHIC, mage.cards.g.GideonChampionOfJustice.class));
cards.add(new SetCardInfo("Gift of Paradise", 191, Rarity.COMMON, mage.cards.g.GiftOfParadise.class));

View file

@ -12,7 +12,6 @@ import mage.game.stack.Spell;
import mage.target.targetpointer.FixedTarget;
/**
*
* @author LevelX2
*/
public class SpellCastAllTriggeredAbility extends TriggeredAbilityImpl {
@ -59,23 +58,19 @@ public class SpellCastAllTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Spell spell = game.getStack().getSpell(event.getTargetId());
if (spell != null && filter.match(spell, getSourceId(), getControllerId(), game)) {
if (setTargetPointer != SetTargetPointer.NONE) {
for (Effect effect : this.getEffects()) {
switch (setTargetPointer) {
case SPELL:
effect.setTargetPointer(new FixedTarget(spell.getId()));
break;
case PLAYER:
effect.setTargetPointer(new FixedTarget(spell.getControllerId()));
break;
}
}
}
return true;
if (spell == null || !filter.match(spell, getSourceId(), getControllerId(), game)) {
return false;
}
return false;
getEffects().setValue("spellCast", spell);
switch (setTargetPointer) {
case SPELL:
getEffects().setTargetPointer(new FixedTarget(spell.getId()));
break;
case PLAYER:
getEffects().setTargetPointer(new FixedTarget(spell.getControllerId()));
break;
}
return true;
}
@Override