From ce2f166c53d7f7efe6034827c2e431364da075a7 Mon Sep 17 00:00:00 2001 From: jeffwadsworth <jeff@delmarus.com> Date: Mon, 13 Sep 2021 15:59:46 -0500 Subject: [PATCH] - Fixed #8185 --- Mage.Sets/src/mage/cards/s/ScreechingBat.java | 13 +-- .../src/mage/cards/s/StalkingVampire.java | 80 +++++++++++++++++-- 2 files changed, 79 insertions(+), 14 deletions(-) diff --git a/Mage.Sets/src/mage/cards/s/ScreechingBat.java b/Mage.Sets/src/mage/cards/s/ScreechingBat.java index 63b29ed5ce..8c1c31fd8b 100644 --- a/Mage.Sets/src/mage/cards/s/ScreechingBat.java +++ b/Mage.Sets/src/mage/cards/s/ScreechingBat.java @@ -1,15 +1,13 @@ - package mage.cards.s; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; -import mage.abilities.condition.common.TransformedCondition; import mage.abilities.costs.Cost; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.decorator.ConditionalTriggeredAbility; import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.TransformSourceEffect; import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.TransformAbility; import mage.cards.CardImpl; @@ -20,7 +18,6 @@ import mage.constants.Outcome; import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; /** @@ -29,7 +26,7 @@ import mage.game.permanent.Permanent; public final class ScreechingBat extends CardImpl { public ScreechingBat(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{B}"); this.subtype.add(SubType.BAT); this.transformable = true; @@ -42,7 +39,7 @@ public final class ScreechingBat extends CardImpl { // At the beginning of your upkeep, you may pay {2}{B}{B}. If you do, transform Screeching Bat. this.addAbility(new TransformAbility()); - this.addAbility(new ConditionalTriggeredAbility(new ScreechingBatBeginningOfUpkeepTriggeredAbility(), new TransformedCondition(true), "")); + this.addAbility(new ScreechingBatBeginningOfUpkeepTriggeredAbility()); } private ScreechingBat(final ScreechingBat card) { @@ -108,9 +105,7 @@ class ScreechingBatTransformSourceEffect extends OneShotEffect { if (permanent != null) { Cost cost = new ManaCostsImpl("{2}{B}{B}"); if (cost.pay(source, game, source, permanent.getControllerId(), false, null)) { - if (permanent.isTransformable()) { - permanent.setTransformed(!permanent.isTransformed()); - } + new TransformSourceEffect(true).apply(game, source); } return true; } diff --git a/Mage.Sets/src/mage/cards/s/StalkingVampire.java b/Mage.Sets/src/mage/cards/s/StalkingVampire.java index 888b456785..66065d0fba 100644 --- a/Mage.Sets/src/mage/cards/s/StalkingVampire.java +++ b/Mage.Sets/src/mage/cards/s/StalkingVampire.java @@ -1,15 +1,23 @@ - package mage.cards.s; import mage.MageInt; -import mage.abilities.condition.common.TransformedCondition; -import mage.abilities.decorator.ConditionalTriggeredAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.costs.Cost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.TransformSourceEffect; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; /** * @author nantuko @@ -17,7 +25,7 @@ import java.util.UUID; public final class StalkingVampire extends CardImpl { public StalkingVampire(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},""); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, ""); this.subtype.add(SubType.VAMPIRE); this.color.setBlack(true); @@ -28,7 +36,7 @@ public final class StalkingVampire extends CardImpl { this.toughness = new MageInt(5); // At the beginning of your upkeep, you may pay {2}{B}{B}. If you do, transform Stalking Vampire. - this.addAbility(new ConditionalTriggeredAbility(new ScreechingBatBeginningOfUpkeepTriggeredAbility(), new TransformedCondition(), "")); + this.addAbility(new StalkingVampireBeginningOfUpkeepTriggeredAbility()); } private StalkingVampire(final StalkingVampire card) { @@ -40,3 +48,65 @@ public final class StalkingVampire extends CardImpl { return new StalkingVampire(this); } } + +class StalkingVampireBeginningOfUpkeepTriggeredAbility extends TriggeredAbilityImpl { + + public StalkingVampireBeginningOfUpkeepTriggeredAbility() { + super(Zone.BATTLEFIELD, new StalkingVampireTransformSourceEffect(), true); + } + + public StalkingVampireBeginningOfUpkeepTriggeredAbility(final StalkingVampireBeginningOfUpkeepTriggeredAbility ability) { + super(ability); + } + + @Override + public StalkingVampireBeginningOfUpkeepTriggeredAbility copy() { + return new StalkingVampireBeginningOfUpkeepTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + return event.getPlayerId().equals(this.controllerId); + } + + @Override + public String getRule() { + return "At the beginning of your upkeep, you may pay {2}{B}{B}. If you do, transform {this}."; + } +} + +class StalkingVampireTransformSourceEffect extends OneShotEffect { + + public StalkingVampireTransformSourceEffect() { + super(Outcome.Transform); + staticText = "transform {this}"; + } + + public StalkingVampireTransformSourceEffect(final StalkingVampireTransformSourceEffect effect) { + super(effect); + } + + @Override + public StalkingVampireTransformSourceEffect copy() { + return new StalkingVampireTransformSourceEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = game.getPermanent(source.getSourceId()); + if (permanent != null) { + Cost cost = new ManaCostsImpl("{2}{B}{B}"); + if (cost.pay(source, game, source, permanent.getControllerId(), false, null)) { + new TransformSourceEffect(false).apply(game, source); + } + return true; + } + return false; + } + +}