From ad0b4659bb774080422f4f52fca7fcc15e59cf18 Mon Sep 17 00:00:00 2001 From: Noah Gleason Date: Sat, 30 Jun 2018 13:54:39 -0400 Subject: [PATCH] Implement Booby Trap --- Mage.Sets/src/mage/cards/b/BoobyTrap.java | 97 +++++++++++++++++++++++ Mage.Sets/src/mage/sets/NinthEdition.java | 1 + Mage.Sets/src/mage/sets/Tempest.java | 1 + 3 files changed, 99 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/b/BoobyTrap.java diff --git a/Mage.Sets/src/mage/cards/b/BoobyTrap.java b/Mage.Sets/src/mage/cards/b/BoobyTrap.java new file mode 100644 index 0000000000..b14cc765dc --- /dev/null +++ b/Mage.Sets/src/mage/cards/b/BoobyTrap.java @@ -0,0 +1,97 @@ +package mage.cards.b; + +import java.util.UUID; + +import mage.abilities.TriggeredAbility; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.AsEntersBattlefieldAbility; +import mage.abilities.common.EntersBattlefieldAllTriggeredAbility; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.costs.common.SacrificeSourceCost; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.*; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.cards.CardsImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.players.Player; +import mage.target.Target; +import mage.target.TargetImpl; +import mage.target.common.TargetOpponent; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author noahg + */ +public final class BoobyTrap extends CardImpl { + + public BoobyTrap(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{6}"); + + + // As Booby Trap enters the battlefield, name a card other than a basic land card and choose an opponent. + AsEntersBattlefieldAbility etbAbility = new AsEntersBattlefieldAbility(new ChooseACardNameEffect(ChooseACardNameEffect.TypeOfName.NOT_BASIC_LAND_NAME)); + etbAbility.addEffect(new ChooseOpponentEffect(Outcome.Damage)); + this.addAbility(etbAbility); + + // The chosen player reveals each card he or she draws. + // When the chosen player draws the named card, sacrifice Booby Trap. If you do, Booby Trap deals 10 damage to that player. + this.addAbility(new BoobyTrapTriggeredAbility()); + } + + public BoobyTrap(final BoobyTrap card) { + super(card); + } + + @Override + public BoobyTrap copy() { + return new BoobyTrap(this); + } +} + +class BoobyTrapTriggeredAbility extends TriggeredAbilityImpl { + + public BoobyTrapTriggeredAbility() { + super(Zone.BATTLEFIELD, new DoIfCostPaid(new DamageTargetEffect(10), new SacrificeSourceCost()), false); + } + + public BoobyTrapTriggeredAbility(BoobyTrapTriggeredAbility ability) { + super(ability); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.DREW_CARD; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + Player controller = game.getPlayer(sourceId); + if (event.getPlayerId() == null || game.getState() == null || controller == null){ + return false; + } + if (event.getPlayerId().equals(game.getState().getValue(getSourceId()+ChooseOpponentEffect.VALUE_KEY))){ + Card drawn = game.getCard(event.getTargetId()); + if (drawn != null){ + controller.revealCards(this, new CardsImpl(drawn), game); + if(drawn.getName().equals(game.getState().getValue(getSourceId() + ChooseACardNameEffect.INFO_KEY))){ + //Set target + this.getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId())); + return true; + } + } + } + return false; + } + + @Override + public BoobyTrapTriggeredAbility copy() { + return new BoobyTrapTriggeredAbility(this); + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/NinthEdition.java b/Mage.Sets/src/mage/sets/NinthEdition.java index eac43b9eba..2996fb9c07 100644 --- a/Mage.Sets/src/mage/sets/NinthEdition.java +++ b/Mage.Sets/src/mage/sets/NinthEdition.java @@ -57,6 +57,7 @@ public final class NinthEdition extends ExpansionSet { cards.add(new SetCardInfo("Bog Imp", 116, Rarity.COMMON, mage.cards.b.BogImp.class)); cards.add(new SetCardInfo("Bog Wraith", 117, Rarity.UNCOMMON, mage.cards.b.BogWraith.class)); cards.add(new SetCardInfo("Boiling Seas", 178, Rarity.UNCOMMON, mage.cards.b.BoilingSeas.class)); + cards.add(new SetCardInfo("Booby Trap", 289, Rarity.RARE, mage.cards.b.BoobyTrap.class)); cards.add(new SetCardInfo("Boomerang", 66, Rarity.COMMON, mage.cards.b.Boomerang.class)); cards.add(new SetCardInfo("Bottle Gnomes", 290, Rarity.UNCOMMON, mage.cards.b.BottleGnomes.class)); cards.add(new SetCardInfo("Brushland", 319, Rarity.RARE, mage.cards.b.Brushland.class)); diff --git a/Mage.Sets/src/mage/sets/Tempest.java b/Mage.Sets/src/mage/sets/Tempest.java index bcb715359d..26f984eaf3 100644 --- a/Mage.Sets/src/mage/sets/Tempest.java +++ b/Mage.Sets/src/mage/sets/Tempest.java @@ -43,6 +43,7 @@ public final class Tempest extends ExpansionSet { cards.add(new SetCardInfo("Blood Frenzy", 164, Rarity.COMMON, mage.cards.b.BloodFrenzy.class)); cards.add(new SetCardInfo("Blood Pet", 109, Rarity.COMMON, mage.cards.b.BloodPet.class)); cards.add(new SetCardInfo("Boil", 165, Rarity.UNCOMMON, mage.cards.b.Boil.class)); + cards.add(new SetCardInfo("Booby Trap", 267, Rarity.RARE, mage.cards.b.BoobyTrap.class)); cards.add(new SetCardInfo("Bottle Gnomes", 278, Rarity.UNCOMMON, mage.cards.b.BottleGnomes.class)); cards.add(new SetCardInfo("Bounty Hunter", 110, Rarity.RARE, mage.cards.b.BountyHunter.class)); cards.add(new SetCardInfo("Broken Fall", 216, Rarity.COMMON, mage.cards.b.BrokenFall.class));