[Y22] Implemented Faithful Disciple

This commit is contained in:
Evan Kranzler 2022-03-01 17:47:28 -05:00
parent d21913c316
commit f4b95d8e2c
3 changed files with 143 additions and 0 deletions

View file

@ -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<String> 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);
}
}

View file

@ -19,5 +19,7 @@ public final class AlchemyInnistrad extends ExpansionSet {
super("Alchemy: Innistrad", "Y22", ExpansionSet.buildDate(2021, 12, 9), SetType.MAGIC_ARENA); super("Alchemy: Innistrad", "Y22", ExpansionSet.buildDate(2021, 12, 9), SetType.MAGIC_ARENA);
this.blockName = "Alchemy"; this.blockName = "Alchemy";
this.hasBoosters = false; this.hasBoosters = false;
cards.add(new SetCardInfo("Faithful Disciple", 7, Rarity.UNCOMMON, mage.cards.f.FaithfulDisciple.class));
} }
} }

View file

@ -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<String> spellbook;
public DraftFromSpellbookEffect(List<String> 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<String> 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<Card> cards = new HashSet<>();
cards.add(cardInfo.getCard());
game.loadCards(cards, player.getId());
player.moveCards(cards, Zone.HAND, source, game);
return true;
}
}