Implemented Cavalier of Dawn

This commit is contained in:
Evan Kranzler 2019-06-23 09:37:30 -04:00
parent 075d7498a7
commit afcd626dd1
2 changed files with 102 additions and 0 deletions

View file

@ -0,0 +1,101 @@
package mage.cards.c;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.DiesTriggeredAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateTokenTargetEffect;
import mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect;
import mage.abilities.keyword.VigilanceAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.filter.FilterCard;
import mage.filter.common.FilterArtifactOrEnchantmentCard;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.GolemToken;
import mage.players.Player;
import mage.target.common.TargetCardInYourGraveyard;
import mage.target.common.TargetNonlandPermanent;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class CavalierOfDawn extends CardImpl {
private static final FilterCard filter
= new FilterArtifactOrEnchantmentCard("artifact or enchantment card from your graveyard");
public CavalierOfDawn(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}{W}{W}");
this.subtype.add(SubType.ELEMENTAL);
this.subtype.add(SubType.KNIGHT);
this.power = new MageInt(4);
this.toughness = new MageInt(6);
// Vigilance
this.addAbility(VigilanceAbility.getInstance());
// When Cavalier of Dawn enters the battlefield, destroy up to one target nonland permanent. Its controller creates a 3/3 colorless Golem artifact creature token.
Ability ability = new EntersBattlefieldTriggeredAbility(new CavalierOfDawnEffect());
ability.addTarget(new TargetNonlandPermanent(0, 1, false));
this.addAbility(ability);
// When Cavalier of Dawn dies, return target artifact or enchantment card from your graveyard to your hand.
ability = new DiesTriggeredAbility(new ReturnFromGraveyardToHandTargetEffect());
ability.addTarget(new TargetCardInYourGraveyard(filter));
this.addAbility(ability);
}
private CavalierOfDawn(final CavalierOfDawn card) {
super(card);
}
@Override
public CavalierOfDawn copy() {
return new CavalierOfDawn(this);
}
}
class CavalierOfDawnEffect extends OneShotEffect {
CavalierOfDawnEffect() {
super(Outcome.Benefit);
staticText = "destroy up to one target nonland permanent. " +
"Its controller creates a 3/3 colorless Golem artifact creature token.";
}
private CavalierOfDawnEffect(final CavalierOfDawnEffect effect) {
super(effect);
}
@Override
public CavalierOfDawnEffect copy() {
return new CavalierOfDawnEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent == null) {
return false;
}
Player player = game.getPlayer(permanent.getControllerId());
permanent.destroy(source.getSourceId(), game, false);
if (player == null) {
return false;
}
Effect effect = new CreateTokenTargetEffect(new GolemToken());
effect.setTargetPointer(new FixedTarget(player.getId(), game));
return effect.apply(game, source);
}
}

View file

@ -61,6 +61,7 @@ public final class CoreSet2020 extends ExpansionSet {
cards.add(new SetCardInfo("Bone Splinters", 92, Rarity.COMMON, mage.cards.b.BoneSplinters.class));
cards.add(new SetCardInfo("Boneclad Necromancer", 93, Rarity.COMMON, mage.cards.b.BonecladNecromancer.class));
cards.add(new SetCardInfo("Captivating Gyre", 51, Rarity.UNCOMMON, mage.cards.c.CaptivatingGyre.class));
cards.add(new SetCardInfo("Cavalier of Dawn", 10, Rarity.MYTHIC, mage.cards.c.CavalierOfDawn.class));
cards.add(new SetCardInfo("Cavalier of Night", 94, Rarity.MYTHIC, mage.cards.c.CavalierOfNight.class));
cards.add(new SetCardInfo("Cerulean Drake", 53, Rarity.UNCOMMON, mage.cards.c.CeruleanDrake.class));
cards.add(new SetCardInfo("Chandra's Embercat", 129, Rarity.COMMON, mage.cards.c.ChandrasEmbercat.class));