diff --git a/Mage.Sets/src/mage/cards/p/PublicEnemy.java b/Mage.Sets/src/mage/cards/p/PublicEnemy.java new file mode 100644 index 00000000000..ae9bbf15c89 --- /dev/null +++ b/Mage.Sets/src/mage/cards/p/PublicEnemy.java @@ -0,0 +1,99 @@ +package mage.cards.p; + +import mage.abilities.Ability; +import mage.abilities.common.DiesAttachedTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.RequirementEffect; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.keyword.EnchantAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.TargetPermanent; +import mage.target.common.TargetCreaturePermanent; + +import java.util.Objects; +import java.util.Optional; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class PublicEnemy extends CardImpl { + + public PublicEnemy(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{U}"); + + this.subtype.add(SubType.AURA); + + // Enchant creature + TargetPermanent auraTarget = new TargetCreaturePermanent(); + this.getSpellAbility().addTarget(auraTarget); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature)); + this.addAbility(new EnchantAbility(auraTarget.getTargetName())); + + // All creatures attack enchanted creature's controller each combat if able. + this.addAbility(new SimpleStaticAbility(new PublicEnemyEffect())); + + // When enchanted creature dies, draw a card. + this.addAbility(new DiesAttachedTriggeredAbility( + new DrawCardSourceControllerEffect(1), "enchanted creature" + )); + } + + private PublicEnemy(final PublicEnemy card) { + super(card); + } + + @Override + public PublicEnemy copy() { + return new PublicEnemy(this); + } +} + +class PublicEnemyEffect extends RequirementEffect { + + PublicEnemyEffect() { + super(Duration.WhileOnBattlefield); + staticText = "all creatures attack enchanted creature's controller each combat if able"; + } + + private PublicEnemyEffect(final PublicEnemyEffect effect) { + super(effect); + } + + @Override + public PublicEnemyEffect copy() { + return new PublicEnemyEffect(this); + } + + @Override + public boolean applies(Permanent permanent, Ability source, Game game) { + return true; + } + + @Override + public UUID mustAttackDefender(Ability source, Game game) { + return Optional.of(source.getSourcePermanentIfItStillExists(game)) + .filter(Objects::nonNull) + .map(Permanent::getAttachedTo) + .map(game::getControllerId) + .orElse(null); + } + + @Override + public boolean mustAttack(Game game) { + return true; + } + + @Override + public boolean mustBlock(Game game) { + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java b/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java index 81f7b813252..31c3f4fafc7 100644 --- a/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java +++ b/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java @@ -182,6 +182,7 @@ public final class StreetsOfNewCapenna extends ExpansionSet { cards.add(new SetCardInfo("Professional Face-Breaker", 116, Rarity.RARE, mage.cards.p.ProfessionalFaceBreaker.class)); cards.add(new SetCardInfo("Psionic Snoop", 53, Rarity.COMMON, mage.cards.p.PsionicSnoop.class)); cards.add(new SetCardInfo("Psychic Pickpocket", 54, Rarity.UNCOMMON, mage.cards.p.PsychicPickpocket.class)); + cards.add(new SetCardInfo("Public Enemy", 55, Rarity.UNCOMMON, mage.cards.p.PublicEnemy.class)); cards.add(new SetCardInfo("Pugnacious Pugilist", 117, Rarity.UNCOMMON, mage.cards.p.PugnaciousPugilist.class)); cards.add(new SetCardInfo("Pyre-Sledge Arsonist", 118, Rarity.UNCOMMON, mage.cards.p.PyreSledgeArsonist.class)); cards.add(new SetCardInfo("Queza, Augur of Agonies", 212, Rarity.UNCOMMON, mage.cards.q.QuezaAugurOfAgonies.class));