[MOM] Implement Inga and Esika

This commit is contained in:
theelk801 2023-04-17 19:13:25 -04:00
parent 0f46bf32b7
commit d94e699d0e
3 changed files with 109 additions and 0 deletions

View file

@ -0,0 +1,98 @@
package mage.cards.i;
import mage.ConditionalMana;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
import mage.abilities.keyword.VigilanceAbility;
import mage.abilities.mana.ConditionalAnyColorManaAbility;
import mage.abilities.mana.builder.ConditionalManaBuilder;
import mage.abilities.mana.conditional.CreatureCastConditionalMana;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.filter.FilterSpell;
import mage.filter.StaticFilters;
import mage.filter.common.FilterCreatureSpell;
import mage.filter.predicate.Predicate;
import mage.game.Game;
import mage.game.stack.StackObject;
import mage.watchers.common.ManaPaidSourceWatcher;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class IngaAndEsika extends CardImpl {
private static final FilterSpell filter
= new FilterCreatureSpell("creature spell, if three or more mana from creatures was spent to cast it");
static {
filter.add(IngaAndEsikaPredicate.instance);
}
public IngaAndEsika(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}{U}");
this.addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.GOD);
this.power = new MageInt(4);
this.toughness = new MageInt(4);
// Creatures you control have vigilance and "{T}: Add one mana of any color. Spend this mana only to cast a creature spell."
Ability ability = new SimpleStaticAbility(new GainAbilityControlledEffect(
VigilanceAbility.getInstance(), Duration.WhileOnBattlefield,
StaticFilters.FILTER_PERMANENT_CREATURES
));
ability.addEffect(new GainAbilityControlledEffect(
new ConditionalAnyColorManaAbility(1, new IngaAndEsikaManaBuilder()),
Duration.WhileOnBattlefield, StaticFilters.FILTER_PERMANENT_CREATURE
).setText("and \"{T}: Add one mana of any color. Spend this mana only to cast a creature spell.\""));
this.addAbility(ability);
// Whenever you cast a creature spell, if three or more mana from creatures was spent to cast it, draw a card.
this.addAbility(new SpellCastControllerTriggeredAbility(
new DrawCardSourceControllerEffect(1), filter, false
));
}
private IngaAndEsika(final IngaAndEsika card) {
super(card);
}
@Override
public IngaAndEsika copy() {
return new IngaAndEsika(this);
}
}
class IngaAndEsikaManaBuilder extends ConditionalManaBuilder {
@Override
public ConditionalMana build(Object... options) {
return new CreatureCastConditionalMana(this.mana);
}
@Override
public String getRule() {
return "Spend this mana only to cast a creature spell";
}
}
enum IngaAndEsikaPredicate implements Predicate<StackObject> {
instance;
@Override
public boolean apply(StackObject input, Game game) {
return ManaPaidSourceWatcher.getCreaturePaid(input.getId(), game) >= 3;
}
}

View file

@ -157,6 +157,7 @@ public final class MarchOfTheMachine extends ExpansionSet {
cards.add(new SetCardInfo("Ichor Drinker", 111, Rarity.COMMON, mage.cards.i.IchorDrinker.class));
cards.add(new SetCardInfo("Ichor Shade", 112, Rarity.COMMON, mage.cards.i.IchorShade.class));
cards.add(new SetCardInfo("Infected Defector", 18, Rarity.COMMON, mage.cards.i.InfectedDefector.class));
cards.add(new SetCardInfo("Inga and Esika", 229, Rarity.RARE, mage.cards.i.IngaAndEsika.class));
cards.add(new SetCardInfo("Injector Crocodile", 329, Rarity.COMMON, mage.cards.i.InjectorCrocodile.class));
cards.add(new SetCardInfo("Inspired Charge", 19, Rarity.COMMON, mage.cards.i.InspiredCharge.class));
cards.add(new SetCardInfo("Interdisciplinary Mascot", 326, Rarity.RARE, mage.cards.i.InterdisciplinaryMascot.class));

View file

@ -36,6 +36,7 @@ public class ManaPaidSourceWatcher extends Watcher {
private int greenSnow = 0;
private int colorlessSnow = 0;
private int treasure = 0;
private int creature = 0;
private ManaPaidTracker() {
super();
@ -50,6 +51,7 @@ public class ManaPaidSourceWatcher extends Watcher {
this.greenSnow = tracker.greenSnow;
this.colorlessSnow = tracker.colorlessSnow;
this.treasure = tracker.treasure;
this.creature = tracker.creature;
}
@Override
@ -62,6 +64,9 @@ public class ManaPaidSourceWatcher extends Watcher {
if (sourceObject != null && sourceObject.hasSubtype(SubType.TREASURE, game)) {
treasure++;
}
if (sourceObject != null && sourceObject.isCreature(game)) {
creature++;
}
if (sourceObject != null && !sourceObject.isSnow()) {
return;
}
@ -144,6 +149,11 @@ public class ManaPaidSourceWatcher extends Watcher {
return watcher == null ? 0 : watcher.manaMap.getOrDefault(sourceId, emptyTracker).treasure;
}
public static int getCreaturePaid(UUID sourceId, Game game) {
ManaPaidSourceWatcher watcher = game.getState().getWatcher(ManaPaidSourceWatcher.class);
return watcher == null ? 0 : watcher.manaMap.getOrDefault(sourceId, emptyTracker).creature;
}
public static int getSnowPaid(UUID sourceId, Game game) {
ManaPaidSourceWatcher watcher = game.getState().getWatcher(ManaPaidSourceWatcher.class);
return watcher == null ? 0 : watcher.manaMap.getOrDefault(sourceId, emptyTracker).getSnow();