Fix Booby Trap

This commit is contained in:
Noah Gleason 2018-06-30 16:13:15 -04:00
parent ad0b4659bb
commit a7cbd54f6e
No known key found for this signature in database
GPG key ID: EC030EC6B0650A40

View file

@ -1,15 +1,12 @@
package mage.cards.b; package mage.cards.b;
import java.util.UUID;
import mage.abilities.TriggeredAbility;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.AsEntersBattlefieldAbility; import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.EntersBattlefieldAllTriggeredAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.effects.Effect; import mage.abilities.effects.common.ChooseACardNameEffect;
import mage.abilities.effects.common.*; import mage.abilities.effects.common.ChooseOpponentEffect;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.DoIfCostPaid;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
@ -20,13 +17,11 @@ import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.players.Player; import mage.players.Player;
import mage.target.Target;
import mage.target.TargetImpl;
import mage.target.common.TargetOpponent;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/** /**
*
* @author noahg * @author noahg
*/ */
public final class BoobyTrap extends CardImpl { public final class BoobyTrap extends CardImpl {
@ -34,7 +29,6 @@ public final class BoobyTrap extends CardImpl {
public BoobyTrap(UUID ownerId, CardSetInfo setInfo) { public BoobyTrap(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{6}"); 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. // 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)); AsEntersBattlefieldAbility etbAbility = new AsEntersBattlefieldAbility(new ChooseACardNameEffect(ChooseACardNameEffect.TypeOfName.NOT_BASIC_LAND_NAME));
etbAbility.addEffect(new ChooseOpponentEffect(Outcome.Damage)); etbAbility.addEffect(new ChooseOpponentEffect(Outcome.Damage));
@ -58,7 +52,7 @@ public final class BoobyTrap extends CardImpl {
class BoobyTrapTriggeredAbility extends TriggeredAbilityImpl { class BoobyTrapTriggeredAbility extends TriggeredAbilityImpl {
public BoobyTrapTriggeredAbility() { public BoobyTrapTriggeredAbility() {
super(Zone.BATTLEFIELD, new DoIfCostPaid(new DamageTargetEffect(10), new SacrificeSourceCost()), false); super(Zone.BATTLEFIELD, new DoIfCostPaid(new DamageTargetEffect(10, true, "that player"), new SacrificeSourceCost(), "", false), false);
} }
public BoobyTrapTriggeredAbility(BoobyTrapTriggeredAbility ability) { public BoobyTrapTriggeredAbility(BoobyTrapTriggeredAbility ability) {
@ -72,15 +66,15 @@ class BoobyTrapTriggeredAbility extends TriggeredAbilityImpl {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
Player controller = game.getPlayer(sourceId); Player controller = game.getPlayer(getControllerId());
if (event.getPlayerId() == null || game.getState() == null || controller == null) { if (event.getPlayerId() == null || game.getState() == null || controller == null) {
return false; return false;
} }
if (event.getPlayerId().equals(game.getState().getValue(getSourceId()+ChooseOpponentEffect.VALUE_KEY))){ if (event.getPlayerId().equals(game.getState().getValue(getSourceId().toString() + ChooseOpponentEffect.VALUE_KEY))) {
Card drawn = game.getCard(event.getTargetId()); Card drawn = game.getCard(event.getTargetId());
if (drawn != null) { if (drawn != null) {
controller.revealCards(this, new CardsImpl(drawn), game); controller.revealCards(this, new CardsImpl(drawn), game);
if(drawn.getName().equals(game.getState().getValue(getSourceId() + ChooseACardNameEffect.INFO_KEY))){ if (drawn.getName().equals(game.getState().getValue(getSourceId().toString() + ChooseACardNameEffect.INFO_KEY))) {
//Set target //Set target
this.getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId())); this.getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId()));
return true; return true;
@ -94,4 +88,10 @@ class BoobyTrapTriggeredAbility extends TriggeredAbilityImpl {
public BoobyTrapTriggeredAbility copy() { public BoobyTrapTriggeredAbility copy() {
return new BoobyTrapTriggeredAbility(this); return new BoobyTrapTriggeredAbility(this);
} }
@Override
public String getRule() {
return "The chosen player reveals each card he or she draws.\n" +
"When the chosen player draws the named card, sacrifice {this}. If you do, {this} deals 10 damage to that player.";
}
} }