From 98f26e5b3de3bd53b12ada1f41bc43f885e4e3c6 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Mon, 9 Sep 2019 21:04:05 -0400 Subject: [PATCH] Implemented Wicked Guardian --- .../src/mage/cards/w/WickedGuardian.java | 92 +++++++++++++++++++ Mage.Sets/src/mage/sets/ThroneOfEldraine.java | 1 + 2 files changed, 93 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/w/WickedGuardian.java diff --git a/Mage.Sets/src/mage/cards/w/WickedGuardian.java b/Mage.Sets/src/mage/cards/w/WickedGuardian.java new file mode 100644 index 0000000000..3309300daa --- /dev/null +++ b/Mage.Sets/src/mage/cards/w/WickedGuardian.java @@ -0,0 +1,92 @@ +package mage.cards.w; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.predicate.permanent.AnotherPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class WickedGuardian extends CardImpl { + + public WickedGuardian(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{B}"); + + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.NOBLE); + this.power = new MageInt(4); + this.toughness = new MageInt(2); + + // When Wicked Guardian enters the battlefield, you may have it deal 2 damage to another creature you control. If you do, draw a card. + this.addAbility(new EntersBattlefieldTriggeredAbility(new WickedGuardianEffect(), true)); + } + + private WickedGuardian(final WickedGuardian card) { + super(card); + } + + @Override + public WickedGuardian copy() { + return new WickedGuardian(this); + } +} + +class WickedGuardianEffect extends OneShotEffect { + + private static final FilterPermanent filter + = new FilterControlledCreaturePermanent("another creature you control"); + + static { + filter.add(AnotherPredicate.instance); + } + + WickedGuardianEffect() { + super(Outcome.Benefit); + staticText = "have it deal 2 damage to another creature you control. If you do, draw a card"; + } + + private WickedGuardianEffect(final WickedGuardianEffect effect) { + super(effect); + } + + @Override + public WickedGuardianEffect copy() { + return new WickedGuardianEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + if (game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) == 0) { + return false; + } + TargetPermanent target = new TargetPermanent(0, 1, filter, true); + if (!player.choose(outcome, target, source.getSourceId(), game)) { + return false; + } + Permanent permanent = game.getPermanent(target.getFirstTarget()); + if (permanent == null) { + return false; + } + permanent.damage(2, source.getSourceId(), game); + return player.drawCards(2, game) > 0; + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/ThroneOfEldraine.java b/Mage.Sets/src/mage/sets/ThroneOfEldraine.java index 64377bfebf..b464470748 100644 --- a/Mage.Sets/src/mage/sets/ThroneOfEldraine.java +++ b/Mage.Sets/src/mage/sets/ThroneOfEldraine.java @@ -111,6 +111,7 @@ public final class ThroneOfEldraine extends ExpansionSet { cards.add(new SetCardInfo("Tome of Legends", 332, Rarity.RARE, mage.cards.t.TomeOfLegends.class)); cards.add(new SetCardInfo("Tournament Grounds", 248, Rarity.UNCOMMON, mage.cards.t.TournamentGrounds.class)); cards.add(new SetCardInfo("Turn into a Pumpkin", 69, Rarity.UNCOMMON, mage.cards.t.TurnIntoAPumpkin.class)); + cards.add(new SetCardInfo("Wicked Guardian", 109, Rarity.COMMON, mage.cards.w.WickedGuardian.class)); cards.add(new SetCardInfo("Wicked Wolf", 181, Rarity.RARE, mage.cards.w.WickedWolf.class)); cards.add(new SetCardInfo("Wind-Scarred Crag", 308, Rarity.COMMON, mage.cards.w.WindScarredCrag.class)); cards.add(new SetCardInfo("Wintermoor Commander", 205, Rarity.UNCOMMON, mage.cards.w.WintermoorCommander.class));