From 9e587ca05d6e73c72bf500fb3a567aca388a7d5a Mon Sep 17 00:00:00 2001 From: Cameron Merkel <44722506+Cguy7777@users.noreply.github.com> Date: Tue, 27 Feb 2024 16:30:17 -0600 Subject: [PATCH] [MKM] Implement Blood Spatter Analysis (#11863) --- .../mage/cards/b/BloodSpatterAnalysis.java | 105 ++++++++++++++++++ .../src/mage/sets/MurdersAtKarlovManor.java | 2 + .../main/java/mage/counters/CounterType.java | 1 + 3 files changed, 108 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/b/BloodSpatterAnalysis.java diff --git a/Mage.Sets/src/mage/cards/b/BloodSpatterAnalysis.java b/Mage.Sets/src/mage/cards/b/BloodSpatterAnalysis.java new file mode 100644 index 00000000000..764b63a052d --- /dev/null +++ b/Mage.Sets/src/mage/cards/b/BloodSpatterAnalysis.java @@ -0,0 +1,105 @@ +package mage.cards.b; + +import mage.abilities.Ability; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.delayed.ReflexiveTriggeredAbility; +import mage.abilities.condition.common.SourceHasCounterCondition; +import mage.abilities.costs.common.SacrificeSourceCost; +import mage.abilities.decorator.ConditionalOneShotEffect; +import mage.abilities.effects.common.DamageTargetEffect; +import mage.abilities.effects.common.DoWhenCostPaid; +import mage.abilities.effects.common.MillCardsControllerEffect; +import mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.ZoneChangeBatchEvent; +import mage.game.events.ZoneChangeEvent; +import mage.game.permanent.Permanent; +import mage.target.common.TargetCardInYourGraveyard; +import mage.target.common.TargetOpponentsCreaturePermanent; + +import java.util.UUID; + +/** + * @author Cguy7777 + */ +public final class BloodSpatterAnalysis extends CardImpl { + + public BloodSpatterAnalysis(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{B}{R}"); + + // When Blood Spatter Analysis enters the battlefield, it deals 3 damage to target creature an opponent controls. + Ability ability = new EntersBattlefieldTriggeredAbility(new DamageTargetEffect(3)); + ability.addTarget(new TargetOpponentsCreaturePermanent()); + this.addAbility(ability); + + // Whenever one or more creatures die, mill a card and put a bloodstain counter on Blood Spatter Analysis. + // Then sacrifice it if it has five or more bloodstain counters on it. + // When you do, return target creature card from your graveyard to your hand. + this.addAbility(new BloodSpatterAnalysisTriggeredAbility()); + } + + private BloodSpatterAnalysis(final BloodSpatterAnalysis card) { + super(card); + } + + @Override + public BloodSpatterAnalysis copy() { + return new BloodSpatterAnalysis(this); + } +} + +class BloodSpatterAnalysisTriggeredAbility extends TriggeredAbilityImpl { + + BloodSpatterAnalysisTriggeredAbility() { + super(Zone.BATTLEFIELD, new MillCardsControllerEffect(1)); + this.addEffect(new AddCountersSourceEffect(CounterType.BLOODSTAIN.createInstance()).concatBy("and")); + + ReflexiveTriggeredAbility returnAbility = new ReflexiveTriggeredAbility(new ReturnFromGraveyardToHandTargetEffect(), false); + returnAbility.addTarget(new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD)); + + this.addEffect(new ConditionalOneShotEffect( + new DoWhenCostPaid(returnAbility, new SacrificeSourceCost(), null, false), + new SourceHasCounterCondition(CounterType.BLOODSTAIN, 5)) + .setText("Then sacrifice it if it has five or more bloodstain counters on it. When you do, return target creature card from your graveyard to your hand")); + + setTriggerPhrase("Whenever one or more creatures die, "); + } + + private BloodSpatterAnalysisTriggeredAbility(final BloodSpatterAnalysisTriggeredAbility ability) { + super(ability); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ZONE_CHANGE_BATCH; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + ZoneChangeBatchEvent zBatchEvent = (ZoneChangeBatchEvent) event; + + for (ZoneChangeEvent zEvent : zBatchEvent.getEvents()) { + if (zEvent.isDiesEvent()) { + Permanent permanent = game.getPermanentOrLKIBattlefield(zEvent.getTargetId()); + if (permanent != null && permanent.isCreature(game)) { + return true; + } + } + } + return false; + } + + @Override + public BloodSpatterAnalysisTriggeredAbility copy() { + return new BloodSpatterAnalysisTriggeredAbility(this); + } +} diff --git a/Mage.Sets/src/mage/sets/MurdersAtKarlovManor.java b/Mage.Sets/src/mage/sets/MurdersAtKarlovManor.java index 3feabca7833..be0f1d2a92a 100644 --- a/Mage.Sets/src/mage/sets/MurdersAtKarlovManor.java +++ b/Mage.Sets/src/mage/sets/MurdersAtKarlovManor.java @@ -47,6 +47,8 @@ public final class MurdersAtKarlovManor extends ExpansionSet { cards.add(new SetCardInfo("Basilica Stalker", 78, Rarity.COMMON, mage.cards.b.BasilicaStalker.class)); cards.add(new SetCardInfo("Behind the Mask", 39, Rarity.COMMON, mage.cards.b.BehindTheMask.class)); cards.add(new SetCardInfo("Benthic Criminologists", 40, Rarity.COMMON, mage.cards.b.BenthicCriminologists.class)); + cards.add(new SetCardInfo("Blood Spatter Analysis", 189, Rarity.RARE, mage.cards.b.BloodSpatterAnalysis.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Blood Spatter Analysis", 413, Rarity.RARE, mage.cards.b.BloodSpatterAnalysis.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Bolrac-Clan Basher", 112, Rarity.UNCOMMON, mage.cards.b.BolracClanBasher.class)); cards.add(new SetCardInfo("Branch of Vitu-Ghazi", 258, Rarity.UNCOMMON, mage.cards.b.BranchOfVituGhazi.class)); cards.add(new SetCardInfo("Burden of Proof", 42, Rarity.UNCOMMON, mage.cards.b.BurdenOfProof.class)); diff --git a/Mage/src/main/java/mage/counters/CounterType.java b/Mage/src/main/java/mage/counters/CounterType.java index 98be15ed96d..4acfdb94ded 100644 --- a/Mage/src/main/java/mage/counters/CounterType.java +++ b/Mage/src/main/java/mage/counters/CounterType.java @@ -26,6 +26,7 @@ public enum CounterType { BLESSING("blessing"), BLOOD("blood"), BLOODLINE("bloodline"), + BLOODSTAIN("bloodstain"), BOOK("book"), BORE("bore"), BOUNTY("bounty"),