[AFR] Implemented Check for Traps

This commit is contained in:
Daniel Bomar 2021-07-06 09:02:04 -05:00
parent bb4f36fddf
commit 4ed302b21d
No known key found for this signature in database
GPG key ID: C86C8658F4023918
2 changed files with 90 additions and 0 deletions

View file

@ -0,0 +1,89 @@
package mage.cards.c;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.FlashAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetOpponent;
/**
*
* @author weirddan455
*/
public final class CheckForTraps extends CardImpl {
public CheckForTraps(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{B}");
// Target opponent reveals their hand. You choose a nonland card from it. Exile that card.
// If an instant or a card with flash is exiled this way, they lose 1 life. Otherwise, you lose 1 life.
this.getSpellAbility().addTarget(new TargetOpponent());
this.getSpellAbility().addEffect(new CheckForTrapsEffect());
}
private CheckForTraps(final CheckForTraps card) {
super(card);
}
@Override
public CheckForTraps copy() {
return new CheckForTraps(this);
}
}
class CheckForTrapsEffect extends OneShotEffect {
public CheckForTrapsEffect() {
super(Outcome.Discard);
this.staticText = "Target opponent reveals their hand. You choose a nonland card from it. Exile that card. " +
"If an instant or a card with flash is exiled this way, they lose 1 life. Otherwise, you lose 1 life";
}
private CheckForTrapsEffect(final CheckForTrapsEffect effect) {
super(effect);
}
@Override
public CheckForTrapsEffect copy() {
return new CheckForTrapsEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
if (controller == null || opponent == null) {
return false;
}
opponent.revealCards(source, opponent.getHand(), game);
TargetCard target = new TargetCard(Zone.HAND, StaticFilters.FILTER_CARD_NON_LAND);
target.setNotTarget(true);
boolean opponentLoseLife = false;
if (controller.choose(outcome, opponent.getHand(), target, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
controller.moveCards(card, Zone.EXILED, source, game);
if (card.isInstant() || card.hasAbility(FlashAbility.getInstance(), game)) {
opponentLoseLife = true;
}
}
}
if (opponentLoseLife) {
opponent.loseLife(1, game, source, false);
} else {
controller.loseLife(1, game, source, false);
}
return true;
}
}

View file

@ -42,6 +42,7 @@ public final class AdventuresInTheForgottenRealms extends ExpansionSet {
cards.add(new SetCardInfo("Cave of the Frost Dragon", 253, Rarity.RARE, mage.cards.c.CaveOfTheFrostDragon.class));
cards.add(new SetCardInfo("Celestial Unicorn", 5, Rarity.COMMON, mage.cards.c.CelestialUnicorn.class));
cards.add(new SetCardInfo("Charmed Sleep", 50, Rarity.COMMON, mage.cards.c.CharmedSleep.class));
cards.add(new SetCardInfo("Check for Traps", 92, Rarity.UNCOMMON, mage.cards.c.CheckForTraps.class));
cards.add(new SetCardInfo("Choose Your Weapon", 175, Rarity.UNCOMMON, mage.cards.c.ChooseYourWeapon.class));
cards.add(new SetCardInfo("Circle of Dreams Druid", 176, Rarity.RARE, mage.cards.c.CircleOfDreamsDruid.class));
cards.add(new SetCardInfo("Clattering Skeletons", 93, Rarity.COMMON, mage.cards.c.ClatteringSkeletons.class));