diff --git a/Mage.Sets/src/mage/cards/f/FaithfulDisciple.java b/Mage.Sets/src/mage/cards/f/FaithfulDisciple.java new file mode 100644 index 0000000000..fa1c59eeed --- /dev/null +++ b/Mage.Sets/src/mage/cards/f/FaithfulDisciple.java @@ -0,0 +1,63 @@ +package mage.cards.f; + +import mage.MageInt; +import mage.abilities.common.DiesSourceTriggeredAbility; +import mage.abilities.effects.common.DraftFromSpellbookEffect; +import mage.abilities.keyword.VigilanceAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class FaithfulDisciple extends CardImpl { + + private static final List spellbook = Collections.unmodifiableList(Arrays.asList( + "All That Glitters", + "Angelic Exaltation", + "Angelic Gift", + "Anointed Procession", + "Authority of the Consuls", + "Banishing Light", + "Cathars' Crusade", + "Cleric Class", + "Divine Visitation", + "Duelist's Heritage", + "Gauntlets of Light", + "Glorious Anthem", + "Sigil of the Empty Throne", + "Spectral Steel", + "Teleportation Circle" + )); + + public FaithfulDisciple(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}"); + + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.CLERIC); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // Vigilance + this.addAbility(VigilanceAbility.getInstance()); + + // When Faithful Disciple dies, draft a card from Faithful Disciple's spellbook. + this.addAbility(new DiesSourceTriggeredAbility(new DraftFromSpellbookEffect(spellbook))); + } + + private FaithfulDisciple(final FaithfulDisciple card) { + super(card); + } + + @Override + public FaithfulDisciple copy() { + return new FaithfulDisciple(this); + } +} diff --git a/Mage.Sets/src/mage/sets/AlchemyInnistrad.java b/Mage.Sets/src/mage/sets/AlchemyInnistrad.java index 6ac7bf1e9e..536dd665bb 100644 --- a/Mage.Sets/src/mage/sets/AlchemyInnistrad.java +++ b/Mage.Sets/src/mage/sets/AlchemyInnistrad.java @@ -19,5 +19,7 @@ public final class AlchemyInnistrad extends ExpansionSet { super("Alchemy: Innistrad", "Y22", ExpansionSet.buildDate(2021, 12, 9), SetType.MAGIC_ARENA); this.blockName = "Alchemy"; this.hasBoosters = false; + + cards.add(new SetCardInfo("Faithful Disciple", 7, Rarity.UNCOMMON, mage.cards.f.FaithfulDisciple.class)); } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/DraftFromSpellbookEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DraftFromSpellbookEffect.java new file mode 100644 index 0000000000..fdc4a0d286 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/DraftFromSpellbookEffect.java @@ -0,0 +1,78 @@ +package mage.abilities.effects.common; + +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; +import mage.cards.repository.CardCriteria; +import mage.cards.repository.CardInfo; +import mage.cards.repository.CardRepository; +import mage.choices.Choice; +import mage.choices.ChoiceHintType; +import mage.choices.ChoiceImpl; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.game.Game; +import mage.players.Player; +import mage.util.RandomUtil; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * @author TheElk801 + */ +public class DraftFromSpellbookEffect extends OneShotEffect { + + private final List spellbook; + + public DraftFromSpellbookEffect(List spellbook) { + super(Outcome.DrawCard); + this.spellbook = spellbook; + staticText = "draft a card from {this}'s spellbook"; + } + + private DraftFromSpellbookEffect(final DraftFromSpellbookEffect effect) { + super(effect); + this.spellbook = effect.spellbook; + } + + @Override + public DraftFromSpellbookEffect copy() { + return new DraftFromSpellbookEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + Set toSelect = new HashSet<>(); + while (toSelect.size() < 3) { + toSelect.add(RandomUtil.randomFromCollection(spellbook)); + } + Choice choice = new ChoiceImpl(true, ChoiceHintType.CARD); + choice.setMessage("Choose a card to draft"); + choice.setChoices(toSelect); + player.choose(outcome, choice, game); + String cardName = choice.getChoice(); + if (cardName == null) { + return false; + } + CardInfo cardInfo = CardRepository + .instance + .findCards(new CardCriteria().nameExact(cardName)) + .stream() + .findFirst() + .orElse(null); + if (cardInfo == null) { + return false; + } + Set cards = new HashSet<>(); + cards.add(cardInfo.getCard()); + game.loadCards(cards, player.getId()); + player.moveCards(cards, Zone.HAND, source, game); + return true; + } +}