diff --git a/Mage.Sets/src/mage/cards/w/WitchKingBringerOfRuin.java b/Mage.Sets/src/mage/cards/w/WitchKingBringerOfRuin.java new file mode 100644 index 0000000000..8a84c800ad --- /dev/null +++ b/Mage.Sets/src/mage/cards/w/WitchKingBringerOfRuin.java @@ -0,0 +1,88 @@ +package mage.cards.w; + +import mage.MageInt; +import mage.MageObject; +import mage.abilities.common.AttacksTriggeredAbility; +import mage.abilities.effects.common.SacrificeEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SetTargetPointer; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.filter.FilterPermanent; +import mage.filter.StaticFilters; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.predicate.ObjectSourcePlayer; +import mage.filter.predicate.ObjectSourcePlayerPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class WitchKingBringerOfRuin extends CardImpl { + + private static final FilterPermanent filter + = new FilterControlledCreaturePermanent("creature with the least power among creatures you control"); + + static { + filter.add(WitchKingBringerOfRuinPredicate.instance); + } + + public WitchKingBringerOfRuin(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{B}{B}"); + + this.supertype.add(SuperType.LEGENDARY); + this.subtype.add(SubType.WRAITH); + this.subtype.add(SubType.NOBLE); + this.power = new MageInt(5); + this.toughness = new MageInt(3); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // Whenever Witch-king, Bringer of Ruin attacks, defending player sacrifices a creature with the least power among creatures they control. + this.addAbility(new AttacksTriggeredAbility( + new SacrificeEffect(filter, 1, "") + .setText("defending player sacrifices a creature " + + "with the least power among creatures they control"), + false, null, SetTargetPointer.PLAYER + )); + } + + private WitchKingBringerOfRuin(final WitchKingBringerOfRuin card) { + super(card); + } + + @Override + public WitchKingBringerOfRuin copy() { + return new WitchKingBringerOfRuin(this); + } +} + +enum WitchKingBringerOfRuinPredicate implements ObjectSourcePlayerPredicate { + instance; + + @Override + public boolean apply(ObjectSourcePlayer input, Game game) { + return input + .getObject() + .getPower() + .getValue() + <= game + .getBattlefield() + .getActivePermanents( + StaticFilters.FILTER_CONTROLLED_CREATURE, + input.getPlayerId(), input.getSource(), game + ) + .stream() + .map(MageObject::getPower) + .mapToInt(MageInt::getValue) + .min() + .orElse(0); + } +} diff --git a/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java b/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java index 8abc48de18..3baf1ed2ab 100644 --- a/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java +++ b/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java @@ -215,6 +215,7 @@ public final class TheLordOfTheRingsTalesOfMiddleEarth extends ExpansionSet { cards.add(new SetCardInfo("Warbeast of Gorgoroth", 152, Rarity.COMMON, mage.cards.w.WarbeastOfGorgoroth.class)); cards.add(new SetCardInfo("Westfold Rider", 37, Rarity.COMMON, mage.cards.w.WestfoldRider.class)); cards.add(new SetCardInfo("Willow-Wind", 76, Rarity.COMMON, mage.cards.w.WillowWind.class)); + cards.add(new SetCardInfo("Witch-king, Bringer of Ruin", 293, Rarity.RARE, mage.cards.w.WitchKingBringerOfRuin.class)); cards.add(new SetCardInfo("Wizard's Rockets", 252, Rarity.COMMON, mage.cards.w.WizardsRockets.class)); cards.add(new SetCardInfo("Wose Pathfinder", 190, Rarity.COMMON, mage.cards.w.WosePathfinder.class)); cards.add(new SetCardInfo("You Cannot Pass!", 38, Rarity.UNCOMMON, mage.cards.y.YouCannotPass.class));