[STX] Implemented Codie, Vociferous Codex

This commit is contained in:
Evan Kranzler 2021-04-12 17:44:46 -04:00
parent 7d3dfe5b15
commit f9a606e701
2 changed files with 177 additions and 0 deletions

View file

@ -0,0 +1,176 @@
package mage.cards.c;
import mage.MageInt;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
import mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.*;
import mage.constants.*;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.stack.Spell;
import mage.players.Player;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class CodieVociferousCodex extends CardImpl {
public CodieVociferousCodex(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{3}");
this.addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.CONSTRUCT);
this.power = new MageInt(1);
this.toughness = new MageInt(4);
// You can't cast permanent spells.
this.addAbility(new SimpleStaticAbility(new CodieVociferousCodexCantCastEffect()));
// {4}, {T}: Add {W}{U}{B}{R}{G}. When you cast your next spell this turn, exile cards from the top of your library until you exile an instant or sorcery card with lesser mana value. Until end of turn, you may cast that card without paying its mana cost. Put each other card exiled this way on the bottom of your library in a random order.
Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new Mana(
1, 1, 1, 1, 1, 0, 0, 0
), new GenericManaCost(4));
ability.addEffect(new CreateDelayedTriggeredAbilityEffect(new CodieVociferousCodexDelayedTriggeredAbility()));
ability.addCost(new TapSourceCost());
this.addAbility(ability);
}
private CodieVociferousCodex(final CodieVociferousCodex card) {
super(card);
}
@Override
public CodieVociferousCodex copy() {
return new CodieVociferousCodex(this);
}
}
class CodieVociferousCodexCantCastEffect extends ContinuousRuleModifyingEffectImpl {
CodieVociferousCodexCantCastEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
staticText = "you can't cast permanent spells";
}
private CodieVociferousCodexCantCastEffect(final CodieVociferousCodexCantCastEffect effect) {
super(effect);
}
@Override
public CodieVociferousCodexCantCastEffect copy() {
return new CodieVociferousCodexCantCastEffect(this);
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CAST_SPELL;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (!source.isControlledBy(event.getPlayerId())) {
return false;
}
Card card = game.getCard(event.getSourceId());
return card != null && card.isPermanent();
}
}
class CodieVociferousCodexDelayedTriggeredAbility extends DelayedTriggeredAbility {
CodieVociferousCodexDelayedTriggeredAbility() {
super(new CodieVociferousCodexEffect(), Duration.EndOfTurn, true, false);
}
private CodieVociferousCodexDelayedTriggeredAbility(final CodieVociferousCodexDelayedTriggeredAbility ability) {
super(ability);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.SPELL_CAST;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!isControlledBy(event.getPlayerId())) {
return false;
}
Spell spell = game.getStack().getSpell(event.getTargetId());
if (spell == null) {
return false;
}
this.getEffects().setValue("spellCast", spell);
return true;
}
@Override
public CodieVociferousCodexDelayedTriggeredAbility copy() {
return new CodieVociferousCodexDelayedTriggeredAbility(this);
}
@Override
public String getRule() {
return "When you cast your next spell this turn, exile cards from the top of your library " +
"until you exile an instant or sorcery card with lesser mana value. Until end of turn, " +
"you may cast that card without paying its mana cost. Put each other card exiled this way " +
"on the bottom of your library in a random order.";
}
}
class CodieVociferousCodexEffect extends OneShotEffect {
CodieVociferousCodexEffect() {
super(Outcome.Benefit);
}
private CodieVociferousCodexEffect(final CodieVociferousCodexEffect effect) {
super(effect);
}
@Override
public CodieVociferousCodexEffect copy() {
return new CodieVociferousCodexEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Spell spell = (Spell) getValue("spellCast");
if (player == null || spell == null) {
return false;
}
Cards toExile = new CardsImpl();
Card toCast = null;
for (Card card : player.getLibrary().getCards(game)) {
toExile.add(card);
if (card.isInstantOrSorcery() && card.getConvertedManaCost() < spell.getConvertedManaCost()) {
toCast = card;
break;
}
}
if (toCast == null) {
player.moveCards(toExile, Zone.EXILED, source, game);
player.putCardsOnBottomOfLibrary(toExile, game, source, false);
return true;
}
PlayFromNotOwnHandZoneTargetEffect.exileAndPlayFromExile(
game, source, toExile.getCards(game), TargetController.YOU,
Duration.EndOfTurn, true, true
);
toExile.remove(toCast);
player.putCardsOnBottomOfLibrary(toExile, game, source, false);
return true;
}
}

View file

@ -67,6 +67,7 @@ public final class StrixhavenSchoolOfMages extends ExpansionSet {
cards.add(new SetCardInfo("Charge Through", 124, Rarity.COMMON, mage.cards.c.ChargeThrough.class));
cards.add(new SetCardInfo("Clever Lumimancer", 10, Rarity.UNCOMMON, mage.cards.c.CleverLumimancer.class));
cards.add(new SetCardInfo("Closing Statement", 169, Rarity.UNCOMMON, mage.cards.c.ClosingStatement.class));
cards.add(new SetCardInfo("Codie, Vociferous Codex", 253, Rarity.RARE, mage.cards.c.CodieVociferousCodex.class));
cards.add(new SetCardInfo("Cogwork Archivist", 254, Rarity.COMMON, mage.cards.c.CogworkArchivist.class));
cards.add(new SetCardInfo("Combat Professor", 11, Rarity.COMMON, mage.cards.c.CombatProfessor.class));
cards.add(new SetCardInfo("Confront the Past", 67, Rarity.RARE, mage.cards.c.ConfrontThePast.class));