Implement Booby Trap

This commit is contained in:
Noah Gleason 2018-06-30 13:54:39 -04:00
parent dcb1affb9d
commit ad0b4659bb
No known key found for this signature in database
GPG key ID: 38D5F989A472EC21
3 changed files with 99 additions and 0 deletions

View file

@ -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);
}
}

View file

@ -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));

View file

@ -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));