diff --git a/Mage.Sets/src/mage/cards/f/FaeOffering.java b/Mage.Sets/src/mage/cards/f/FaeOffering.java new file mode 100644 index 0000000000..b9941d402a --- /dev/null +++ b/Mage.Sets/src/mage/cards/f/FaeOffering.java @@ -0,0 +1,107 @@ +package mage.cards.f; + +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfEndStepTriggeredAbility; +import mage.abilities.condition.Condition; +import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.hint.Hint; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.TargetController; +import mage.game.Game; +import mage.game.permanent.token.ClueArtifactToken; +import mage.game.permanent.token.FoodToken; +import mage.game.permanent.token.TreasureToken; +import mage.game.stack.Spell; +import mage.watchers.common.SpellsCastWatcher; + +import java.util.List; +import java.util.Objects; +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * @author TheElk801 + */ +public final class FaeOffering extends CardImpl { + + public FaeOffering(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{G}"); + + // At the beginning of each end step, if you've cast both a creature spell and a noncreature spell this turn, create a Clue token, a Food token, and a Treasure token. + Ability ability = new ConditionalInterveningIfTriggeredAbility( + new BeginningOfEndStepTriggeredAbility( + new CreateTokenEffect(new ClueArtifactToken()), TargetController.ANY, false + ), FaeOfferingCondition.instance, "At the beginning of each end step, " + + "if you've cast both a creature spell and a noncreature spell this turn, " + + "create a Clue token, a Food token, and a Treasure token." + ); + ability.addEffect(new CreateTokenEffect(new FoodToken())); + ability.addEffect(new CreateTokenEffect(new TreasureToken())); + this.addAbility(ability.addHint(FaeOfferingHint.instance), new SpellsCastWatcher()); + } + + private FaeOffering(final FaeOffering card) { + super(card); + } + + @Override + public FaeOffering copy() { + return new FaeOffering(this); + } +} + +enum FaeOfferingCondition implements Condition { + instance; + + @Override + public boolean apply(Game game, Ability source) { + SpellsCastWatcher watcher = game.getState().getWatcher(SpellsCastWatcher.class); + if (watcher == null) { + return false; + } + List spells = watcher.getSpellsCastThisTurn(source.getControllerId()); + return spells != null && spells + .stream() + .filter(Objects::nonNull) + .map(MageObject::isCreature) + .distinct() + .count() == 2; + } +} + +enum FaeOfferingHint implements Hint { + instance; + + @Override + public String getText(Game game, Ability ability) { + SpellsCastWatcher watcher = game.getState().getWatcher(SpellsCastWatcher.class); + if (watcher == null) { + return null; + } + List spells = watcher.getSpellsCastThisTurn(ability.getControllerId()); + if (spells == null) { + return null; + } + List messages = spells + .stream() + .filter(Objects::nonNull) + .map(MageObject::isCreature) + .distinct() + .map(b -> b ? "Creature spell" : "Noncreature spell") + .sorted() + .collect(Collectors.toList()); + if (messages.size() == 0) { + return "You have not cast any spells this turn"; + } + return "You have cast a " + String.join(" and a ", messages) + " this turn"; + } + + @Override + public FaeOfferingHint copy() { + return instance; + } +} diff --git a/Mage.Sets/src/mage/cards/l/Leapfrog.java b/Mage.Sets/src/mage/cards/l/Leapfrog.java index b0f2cd6f66..9ddeea02e3 100644 --- a/Mage.Sets/src/mage/cards/l/Leapfrog.java +++ b/Mage.Sets/src/mage/cards/l/Leapfrog.java @@ -65,8 +65,6 @@ enum LeapfrogCondition implements Condition { return spells != null && spells .stream() .filter(Objects::nonNull) - .filter(MageObject::isInstantOrSorcery) - .map(Spell::getSourceId) - .anyMatch(source.getSourceId()::equals); + .anyMatch(MageObject::isInstantOrSorcery); } } diff --git a/Mage.Sets/src/mage/sets/ModernHorizons2.java b/Mage.Sets/src/mage/sets/ModernHorizons2.java index ba9cdb3646..e52d73a707 100644 --- a/Mage.Sets/src/mage/sets/ModernHorizons2.java +++ b/Mage.Sets/src/mage/sets/ModernHorizons2.java @@ -66,6 +66,7 @@ public final class ModernHorizons2 extends ExpansionSet { cards.add(new SetCardInfo("Enchantress's Presence", 283, Rarity.RARE, mage.cards.e.EnchantresssPresence.class)); cards.add(new SetCardInfo("Endurance", 157, Rarity.MYTHIC, mage.cards.e.Endurance.class)); cards.add(new SetCardInfo("Extruder", 296, Rarity.UNCOMMON, mage.cards.e.Extruder.class)); + cards.add(new SetCardInfo("Fae Offering", 158, Rarity.UNCOMMON, mage.cards.f.FaeOffering.class)); cards.add(new SetCardInfo("Fast // Furious", 123, Rarity.UNCOMMON, mage.cards.f.FastFurious.class)); cards.add(new SetCardInfo("Feast of Sanity", 84, Rarity.UNCOMMON, mage.cards.f.FeastOfSanity.class)); cards.add(new SetCardInfo("Filigree Attendant", 41, Rarity.UNCOMMON, mage.cards.f.FiligreeAttendant.class));