From 93d014a50273773b7a4bd3904c9edac5b21f1260 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sat, 26 May 2018 15:50:30 -0400 Subject: [PATCH] Implemented Azra Bladeseeker --- .../src/mage/cards/a/AzraBladeseeker.java | 137 ++++++++++++++++++ Mage.Sets/src/mage/sets/Battlebond.java | 1 + .../mage/target/common/TargetDiscard.java | 6 +- 3 files changed, 141 insertions(+), 3 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/a/AzraBladeseeker.java diff --git a/Mage.Sets/src/mage/cards/a/AzraBladeseeker.java b/Mage.Sets/src/mage/cards/a/AzraBladeseeker.java new file mode 100644 index 0000000000..c87274ea8c --- /dev/null +++ b/Mage.Sets/src/mage/cards/a/AzraBladeseeker.java @@ -0,0 +1,137 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.cards.a; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; +import mage.constants.SubType; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.game.Game; +import mage.players.Player; +import mage.target.Target; +import mage.target.common.TargetDiscard; + +/** + * + * @author TheElk801 + */ +public class AzraBladeseeker extends CardImpl { + + public AzraBladeseeker(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{R}"); + + this.subtype.add(SubType.AZRA); + this.subtype.add(SubType.WARRIOR); + this.power = new MageInt(3); + this.toughness = new MageInt(2); + + // When Azra Bladeseeker enters the battlefield, each player on your team may discard a card, then each player who discarded a card this way draws a card. + this.addAbility(new EntersBattlefieldTriggeredAbility(new AzraBladeseekerEffect(), false)); + } + + public AzraBladeseeker(final AzraBladeseeker card) { + super(card); + } + + @Override + public AzraBladeseeker copy() { + return new AzraBladeseeker(this); + } +} + +class AzraBladeseekerEffect extends OneShotEffect { + + AzraBladeseekerEffect() { + super(Outcome.Benefit); + this.staticText = "each player on your team may discard a card, then each player who discarded a card this way draws a card"; + } + + AzraBladeseekerEffect(final AzraBladeseekerEffect effect) { + super(effect); + } + + @Override + public AzraBladeseekerEffect copy() { + return new AzraBladeseekerEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + List playerCardList = new ArrayList<>(); + for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { + Player player = game.getPlayer(playerId); + if (player == null + || player.hasOpponent(source.getControllerId(), game) + || player.getHand().isEmpty() + || !player.chooseUse(Outcome.DrawCard, "Discard a card?", source, game)) { + continue; + } + Target target = new TargetDiscard(playerId); + if (target.choose(Outcome.DrawCard, playerId, source.getSourceId(), game)) { + Card card = game.getCard(target.getFirstTarget()); + if (card != null) { + playerCardList.add(new PlayerCard(player, card)); + } + } + } + for (PlayerCard playerCard : playerCardList) { + if (playerCard.getPlayer().discard(playerCard.getCard(), source, game)) { + playerCard.getPlayer().drawCards(1, game); + } + } + return true; + } + + class PlayerCard { + + private final Player player; + private final Card card; + + private PlayerCard(Player player, Card card) { + this.player = player; + this.card = card; + } + + public Player getPlayer() { + return player; + } + + public Card getCard() { + return card; + } + } +} diff --git a/Mage.Sets/src/mage/sets/Battlebond.java b/Mage.Sets/src/mage/sets/Battlebond.java index befa0b26ed..ad0c83dce3 100644 --- a/Mage.Sets/src/mage/sets/Battlebond.java +++ b/Mage.Sets/src/mage/sets/Battlebond.java @@ -65,6 +65,7 @@ public class Battlebond extends ExpansionSet { cards.add(new SetCardInfo("Assassinate", 139, Rarity.COMMON, mage.cards.a.Assassinate.class)); cards.add(new SetCardInfo("Auger Spree", 218, Rarity.COMMON, mage.cards.a.AugerSpree.class)); cards.add(new SetCardInfo("Aurora Champion", 24, Rarity.COMMON, mage.cards.a.AuroraChampion.class)); + cards.add(new SetCardInfo("Azra Bladeseeker", 55, Rarity.COMMON, mage.cards.a.AzraBladeseeker.class)); cards.add(new SetCardInfo("Azra Oddsmaker", 75, Rarity.UNCOMMON, mage.cards.a.AzraOddsmaker.class)); cards.add(new SetCardInfo("Bathe in Dragonfire", 164, Rarity.COMMON, mage.cards.b.BatheInDragonfire.class)); cards.add(new SetCardInfo("Battle Mastery", 89, Rarity.UNCOMMON, mage.cards.b.BattleMastery.class)); diff --git a/Mage/src/main/java/mage/target/common/TargetDiscard.java b/Mage/src/main/java/mage/target/common/TargetDiscard.java index 51a3071b7c..a6068bc7f9 100644 --- a/Mage/src/main/java/mage/target/common/TargetDiscard.java +++ b/Mage/src/main/java/mage/target/common/TargetDiscard.java @@ -24,8 +24,7 @@ * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. -*/ - + */ package mage.target.common; import mage.constants.Zone; @@ -36,6 +35,7 @@ import mage.game.Game; import mage.target.TargetCard; import java.util.UUID; +import mage.filter.StaticFilters; import mage.filter.predicate.other.OwnerIdPredicate; /** @@ -47,7 +47,7 @@ public class TargetDiscard extends TargetCard { private final UUID playerId; public TargetDiscard(UUID playerId) { - this(1, 1, new FilterCard(), playerId); + this(1, 1, StaticFilters.FILTER_CARD, playerId); } public TargetDiscard(FilterCard filter, UUID playerId) {