Implement Rite of Harmony

This commit is contained in:
ciaccona007 2021-09-03 20:54:13 -04:00 committed by ciaccona007
parent 1739c96a53
commit f8314d298c
2 changed files with 88 additions and 0 deletions

View file

@ -0,0 +1,87 @@
package mage.cards.r;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.keyword.FlashbackAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.TimingRule;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.Predicates;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import java.util.UUID;
/**
*
* @author ciaccona007
*/
public final class RiteOfHarmony extends CardImpl {
public RiteOfHarmony(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{G}{W}");
// Whenever a creature or enchantment enters the battlefield under your control this turn, draw a card.
getSpellAbility().addEffect(new CreateDelayedTriggeredAbilityEffect(new RiteOfHarmonyTriggeredAbility()));
// Flashback {2}{G}{W}
this.addAbility(new FlashbackAbility(new ManaCostsImpl("{2}{G}{W}"), TimingRule.INSTANT));
}
private RiteOfHarmony(final RiteOfHarmony card) {
super(card);
}
@Override
public RiteOfHarmony copy() {
return new RiteOfHarmony(this);
}
}
class RiteOfHarmonyTriggeredAbility extends DelayedTriggeredAbility {
private static final FilterControlledPermanent filter = new FilterControlledPermanent("creature or enchantment");
static {
filter.add(Predicates.or(CardType.CREATURE.getPredicate(), CardType.ENCHANTMENT.getPredicate()));
}
public RiteOfHarmonyTriggeredAbility() {
super(new DrawCardSourceControllerEffect(1), Duration.EndOfTurn, false);
optional = false;
}
public RiteOfHarmonyTriggeredAbility(RiteOfHarmonyTriggeredAbility ability) {
super(ability);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
UUID targetId = event.getTargetId();
Permanent permanent = game.getPermanent(targetId);
return filter.match(permanent, getSourceId(), getControllerId(), game);
}
@Override
public RiteOfHarmonyTriggeredAbility copy() {
return new RiteOfHarmonyTriggeredAbility(this);
}
@Override
public String getRule() {
return "Whenever a creature or enchantment enters the battlefield under your control this turn, draw a card.";
}
}

View file

@ -56,6 +56,7 @@ public final class InnistradMidnightHunt extends ExpansionSet {
cards.add(new SetCardInfo("Pithing Needle", 257, Rarity.RARE, mage.cards.p.PithingNeedle.class));
cards.add(new SetCardInfo("Plains", 268, Rarity.LAND, mage.cards.basiclands.Plains.class, FULL_ART_BFZ_VARIOUS));
cards.add(new SetCardInfo("Play with Fire", 154, Rarity.UNCOMMON, mage.cards.p.PlayWithFire.class));
cards.add(new SetCardInfo("Rite of Harmony", 236, Rarity.RARE, mage.cards.r.RiteOfHarmony.class));
cards.add(new SetCardInfo("Rockfall Vale", 266, Rarity.RARE, mage.cards.r.RockfallVale.class));
cards.add(new SetCardInfo("Secrets of the Key", 73, Rarity.COMMON, mage.cards.s.SecretsOfTheKey.class));
cards.add(new SetCardInfo("Shipwreck Marsh", 267, Rarity.RARE, mage.cards.s.ShipwreckMarsh.class));