diff --git a/Mage.Sets/src/mage/cards/v/VelomachusLorehold.java b/Mage.Sets/src/mage/cards/v/VelomachusLorehold.java new file mode 100644 index 0000000000..e5444c0a9f --- /dev/null +++ b/Mage.Sets/src/mage/cards/v/VelomachusLorehold.java @@ -0,0 +1,110 @@ +package mage.cards.v; + +import mage.ApprovingObject; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.AttacksTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.abilities.keyword.HasteAbility; +import mage.abilities.keyword.VigilanceAbility; +import mage.cards.*; +import mage.constants.*; +import mage.filter.FilterCard; +import mage.filter.common.FilterInstantOrSorceryCard; +import mage.filter.predicate.mageobject.ConvertedManaCostPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetCard; +import mage.target.common.TargetCardInLibrary; + +import java.util.Set; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class VelomachusLorehold extends CardImpl { + + public VelomachusLorehold(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{R}{W}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.ELDER); + this.subtype.add(SubType.DRAGON); + this.power = new MageInt(5); + this.toughness = new MageInt(5); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // Vigilance + this.addAbility(VigilanceAbility.getInstance()); + + // Haste + this.addAbility(HasteAbility.getInstance()); + + // Whenever Velomachus Lorehold attacks, look at the top seven cards of your library. You may cast an instant or sorcery spell with mana value less than or equal to Velomachus Lorehold's power from among them without paying its mana cost. Put the rest on the bottom of your library in a random order. + this.addAbility(new AttacksTriggeredAbility(new VelomachusLoreholdEffect(), false)); + } + + private VelomachusLorehold(final VelomachusLorehold card) { + super(card); + } + + @Override + public VelomachusLorehold copy() { + return new VelomachusLorehold(this); + } +} + +class VelomachusLoreholdEffect extends OneShotEffect { + + VelomachusLoreholdEffect() { + super(Outcome.Benefit); + staticText = "look at the top seven cards of your library. You may cast an instant or sorcery spell " + + "with mana value less than or equal to {this}'s power from among them without paying its mana cost. " + + "Put the rest on the bottom of your library in a random order"; + } + + private VelomachusLoreholdEffect(final VelomachusLoreholdEffect effect) { + super(effect); + } + + @Override + public VelomachusLoreholdEffect copy() { + return new VelomachusLoreholdEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Permanent permanent = source.getSourcePermanentOrLKI(game); + if (controller == null || permanent == null) { + return false; + } + Set cardsSet = controller.getLibrary().getTopCards(game, 7); + Cards cards = new CardsImpl(cardsSet); + FilterCard filter = new FilterInstantOrSorceryCard( + "instant or sorcery card with mana value " + permanent.getPower().getValue() + " or less" + ); + filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, permanent.getPower().getValue() + 1)); + TargetCard target = new TargetCardInLibrary(0, 1, filter); + controller.choose(Outcome.PlayForFree, cards, target, game); + Card card = controller.getLibrary().getCard(target.getFirstTarget(), game); + if (card == null) { + controller.putCardsOnBottomOfLibrary(cards, game, source, false); + return true; + } + game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE); + Boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(card, game, true), + game, true, new ApprovingObject(source, game)); + game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null); + if (cardWasCast) { + cards.remove(card); + } + controller.putCardsOnBottomOfLibrary(cards, game, source, false); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java b/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java index ec73770e21..8413504d77 100644 --- a/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java +++ b/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java @@ -272,6 +272,7 @@ public final class StrixhavenSchoolOfMages extends ExpansionSet { cards.add(new SetCardInfo("Unwilling Ingredient", 90, Rarity.COMMON, mage.cards.u.UnwillingIngredient.class)); cards.add(new SetCardInfo("Valentin, Dean of the Vein", 161, Rarity.RARE, mage.cards.v.ValentinDeanOfTheVein.class)); cards.add(new SetCardInfo("Vanishing Verse", 244, Rarity.RARE, mage.cards.v.VanishingVerse.class)); + cards.add(new SetCardInfo("Velomachus Lorehold", 245, Rarity.MYTHIC, mage.cards.v.VelomachusLorehold.class)); cards.add(new SetCardInfo("Venerable Warsinger", 246, Rarity.RARE, mage.cards.v.VenerableWarsinger.class)); cards.add(new SetCardInfo("Vineglimmer Snarl", 274, Rarity.RARE, mage.cards.v.VineglimmerSnarl.class)); cards.add(new SetCardInfo("Vortex Runner", 60, Rarity.COMMON, mage.cards.v.VortexRunner.class));