diff --git a/Mage.Sets/src/mage/cards/t/TheRavenMan.java b/Mage.Sets/src/mage/cards/t/TheRavenMan.java new file mode 100644 index 0000000000..5c4940fb93 --- /dev/null +++ b/Mage.Sets/src/mage/cards/t/TheRavenMan.java @@ -0,0 +1,59 @@ +package mage.cards.t; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.ActivateAsSorceryActivatedAbility; +import mage.abilities.common.BeginningOfEndStepTriggeredAbility; +import mage.abilities.condition.common.PlayerDiscardedThisTurnCondition; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.effects.common.discard.DiscardEachPlayerEffect; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.TargetController; +import mage.game.permanent.token.BlackBirdToken; +import mage.watchers.common.DiscardedCardWatcher; + +/** + * + * @author weirddan455 + */ +public final class TheRavenMan extends CardImpl { + + public TheRavenMan(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.WIZARD); + this.power = new MageInt(2); + this.toughness = new MageInt(1); + + // At the beginning of each end step, if a player discarded a card this turn, create a 1/1 black Bird creature token with flying and "This creature can't block." + this.addAbility(new BeginningOfEndStepTriggeredAbility( + new CreateTokenEffect(new BlackBirdToken()), + TargetController.ANY, + PlayerDiscardedThisTurnCondition.instance, + false + ), new DiscardedCardWatcher()); + + // {3}{B}, {T}: Each opponent discards a card. Activate only as a sorcery. + Ability ability = new ActivateAsSorceryActivatedAbility(new DiscardEachPlayerEffect(TargetController.OPPONENT), new ManaCostsImpl<>("{3}{B}")); + ability.addCost(new TapSourceCost()); + this.addAbility(ability); + } + + private TheRavenMan(final TheRavenMan card) { + super(card); + } + + @Override + public TheRavenMan copy() { + return new TheRavenMan(this); + } +} diff --git a/Mage.Sets/src/mage/sets/DominariaUnited.java b/Mage.Sets/src/mage/sets/DominariaUnited.java index 7953e340dd..1c49921dc2 100644 --- a/Mage.Sets/src/mage/sets/DominariaUnited.java +++ b/Mage.Sets/src/mage/sets/DominariaUnited.java @@ -97,6 +97,7 @@ public final class DominariaUnited extends ExpansionSet { cards.add(new SetCardInfo("Tattered Apparition", 111, Rarity.COMMON, mage.cards.t.TatteredApparition.class)); cards.add(new SetCardInfo("Temporal Firestorm", 147, Rarity.RARE, mage.cards.t.TemporalFirestorm.class)); cards.add(new SetCardInfo("Territorial Maro", 184, Rarity.UNCOMMON, mage.cards.t.TerritorialMaro.class)); + cards.add(new SetCardInfo("The Raven Man", 103, Rarity.RARE, mage.cards.t.TheRavenMan.class)); cards.add(new SetCardInfo("Threats Undetected", 185, Rarity.RARE, mage.cards.t.ThreatsUndetected.class)); cards.add(new SetCardInfo("Timeless Lotus", 239, Rarity.MYTHIC, mage.cards.t.TimelessLotus.class)); cards.add(new SetCardInfo("Tolarian Geyser", 71, Rarity.COMMON, mage.cards.t.TolarianGeyser.class)); diff --git a/Mage/src/main/java/mage/abilities/condition/common/PlayerDiscardedThisTurnCondition.java b/Mage/src/main/java/mage/abilities/condition/common/PlayerDiscardedThisTurnCondition.java new file mode 100644 index 0000000000..4d99ea924a --- /dev/null +++ b/Mage/src/main/java/mage/abilities/condition/common/PlayerDiscardedThisTurnCondition.java @@ -0,0 +1,24 @@ +package mage.abilities.condition.common; + +import mage.abilities.Ability; +import mage.abilities.condition.Condition; +import mage.game.Game; +import mage.watchers.common.DiscardedCardWatcher; + +/** + * + * @author weirddan455 + */ +public enum PlayerDiscardedThisTurnCondition implements Condition { + instance; + + @Override + public boolean apply(Game game, Ability source) { + return DiscardedCardWatcher.playerInRangeDiscarded(source.getControllerId(), game); + } + + @Override + public String toString() { + return "a player discarded a card this turn"; + } +} diff --git a/Mage/src/main/java/mage/game/permanent/token/BlackBirdToken.java b/Mage/src/main/java/mage/game/permanent/token/BlackBirdToken.java new file mode 100644 index 0000000000..3151beb5a3 --- /dev/null +++ b/Mage/src/main/java/mage/game/permanent/token/BlackBirdToken.java @@ -0,0 +1,35 @@ +package mage.game.permanent.token; + +import mage.MageInt; +import mage.abilities.common.CantBlockAbility; +import mage.abilities.keyword.FlyingAbility; +import mage.constants.CardType; +import mage.constants.SubType; + +/** + * + * @author weirddan455 + */ +public final class BlackBirdToken extends TokenImpl { + + public BlackBirdToken() { + super("Bird Token", "1/1 black Bird creature token with flying and \"This creature can't block.\""); + cardType.add(CardType.CREATURE); + color.setBlack(true); + subtype.add(SubType.BIRD); + power = new MageInt(1); + toughness = new MageInt(1); + + addAbility(FlyingAbility.getInstance()); + addAbility(new CantBlockAbility()); + } + + private BlackBirdToken(final BlackBirdToken token) { + super(token); + } + + @Override + public BlackBirdToken copy() { + return new BlackBirdToken(this); + } +} diff --git a/Mage/src/main/java/mage/watchers/common/DiscardedCardWatcher.java b/Mage/src/main/java/mage/watchers/common/DiscardedCardWatcher.java index 692295b655..4bf512e3a7 100644 --- a/Mage/src/main/java/mage/watchers/common/DiscardedCardWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/DiscardedCardWatcher.java @@ -43,4 +43,16 @@ public class DiscardedCardWatcher extends Watcher { DiscardedCardWatcher watcher = game.getState().getWatcher(DiscardedCardWatcher.class); return watcher == null ? 0 : watcher.playerMap.getOrDefault(playerId, 0); } + + public static boolean playerInRangeDiscarded(UUID controllerId, Game game) { + DiscardedCardWatcher watcher = game.getState().getWatcher(DiscardedCardWatcher.class); + if (watcher != null) { + for (UUID playerId : game.getState().getPlayersInRange(controllerId, game)) { + if (watcher.playerMap.getOrDefault(playerId, 0) > 0) { + return true; + } + } + } + return false; + } }