[LCI] Implement Hurl into History

This commit is contained in:
Susucre 2023-10-28 17:47:27 +02:00
parent f6617c03de
commit 139e06665a
2 changed files with 86 additions and 0 deletions

View file

@ -0,0 +1,85 @@
package mage.cards.h;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.keyword.DiscoverEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.filter.FilterSpell;
import mage.filter.predicate.Predicates;
import mage.game.Game;
import mage.game.stack.StackObject;
import mage.players.Player;
import mage.target.TargetSpell;
import java.util.UUID;
/**
* @author Susucr
*/
public final class HurlIntoHistory extends CardImpl {
private static final FilterSpell filter = new FilterSpell("artifact or creature spell");
static {
filter.add(Predicates.or(
CardType.CREATURE.getPredicate(),
CardType.ARTIFACT.getPredicate()
));
}
public HurlIntoHistory(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{U}{U}");
// Counter target artifact or creature spell. Discover X, where X is that spell's mana value.
this.getSpellAbility().addEffect(new HurlIntoHistoryEffect());
this.getSpellAbility().addTarget(new TargetSpell(filter));
}
private HurlIntoHistory(final HurlIntoHistory card) {
super(card);
}
@Override
public HurlIntoHistory copy() {
return new HurlIntoHistory(this);
}
}
/**
* Inspired by {@link mage.cards.s.SpellSwindle}
*/
class HurlIntoHistoryEffect extends OneShotEffect {
public HurlIntoHistoryEffect() {
super(Outcome.Detriment);
staticText = "Counter target artifact or creature spell. Discover X, where X is that spell's mana value.";
}
private HurlIntoHistoryEffect(final HurlIntoHistoryEffect effect) {
super(effect);
}
@Override
public HurlIntoHistoryEffect copy() {
return new HurlIntoHistoryEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
StackObject stackObject = game.getStack().getStackObject(targetPointer.getFirst(game, source));
if (stackObject == null) {
return false;
}
game.getStack().counter(source.getFirstTarget(), source, game);
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
DiscoverEffect.doDiscover(player, stackObject.getManaValue(), game, source);
}
return true;
}
}

View file

@ -62,6 +62,7 @@ public final class TheLostCavernsOfIxalan extends ExpansionSet {
cards.add(new SetCardInfo("Hidden Volcano", 277, Rarity.COMMON, mage.cards.h.HiddenVolcano.class));
cards.add(new SetCardInfo("Hit the Mother Lode", 153, Rarity.RARE, mage.cards.h.HitTheMotherLode.class));
cards.add(new SetCardInfo("Huatli, Poet of Unity", 189, Rarity.MYTHIC, mage.cards.h.HuatliPoetOfUnity.class));
cards.add(new SetCardInfo("Hurl into History", 59, Rarity.UNCOMMON, mage.cards.h.HurlIntoHistory.class));
cards.add(new SetCardInfo("Idol of the Deep King", 155, Rarity.COMMON, mage.cards.i.IdolOfTheDeepKing.class));
cards.add(new SetCardInfo("Island", 395, Rarity.LAND, mage.cards.basiclands.Island.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Itlimoc, Cradle of the Sun", 188, Rarity.RARE, mage.cards.i.ItlimocCradleOfTheSun.class));