From 82f2cc1844728d44edf6721b59534b1b385e01cf Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Fri, 30 Sep 2022 09:51:44 -0400 Subject: [PATCH] [BRO] Implemented Queen Kayla bin-Kroog --- .../src/mage/cards/q/QueenKaylaBinKroog.java | 144 ++++++++++++++++++ Mage.Sets/src/mage/sets/TheBrothersWar.java | 1 + 2 files changed, 145 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/q/QueenKaylaBinKroog.java diff --git a/Mage.Sets/src/mage/cards/q/QueenKaylaBinKroog.java b/Mage.Sets/src/mage/cards/q/QueenKaylaBinKroog.java new file mode 100644 index 00000000000..3b387e00c6a --- /dev/null +++ b/Mage.Sets/src/mage/cards/q/QueenKaylaBinKroog.java @@ -0,0 +1,144 @@ +package mage.cards.q; + +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.ActivateAsSorceryActivatedAbility; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.OneShotEffect; +import mage.cards.*; +import mage.constants.*; +import mage.filter.FilterCard; +import mage.filter.predicate.Predicates; +import mage.game.Game; +import mage.players.Player; +import mage.target.TargetCard; + +import java.util.Objects; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * @author TheElk801 + */ +public final class QueenKaylaBinKroog extends CardImpl { + + public QueenKaylaBinKroog(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{R}{W}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.NOBLE); + this.power = new MageInt(2); + this.toughness = new MageInt(3); + + // {4}, {T}: Discard all the cards in your hand, then draw that many cards. You may chose an artifact or creature card with mana value 1 you discarded this way, then do the same for artifact or creature cards with mana values 2 and 3. Return those cards to the battlefield. Activate only as a sorcery. + Ability ability = new ActivateAsSorceryActivatedAbility(new QueenKaylaBinKroogEffect(), new GenericManaCost(4)); + ability.addCost(new TapSourceCost()); + this.addAbility(ability); + } + + private QueenKaylaBinKroog(final QueenKaylaBinKroog card) { + super(card); + } + + @Override + public QueenKaylaBinKroog copy() { + return new QueenKaylaBinKroog(this); + } +} + +class QueenKaylaBinKroogEffect extends OneShotEffect { + + QueenKaylaBinKroogEffect() { + super(Outcome.Benefit); + staticText = "discard all the cards in your hand, then draw that many cards. " + + "You may choose an artifact or creature card with mana value 1 you discarded this way, " + + "then do the same for artifact or creature cards with mana values 2 and 3. " + + "Return those cards to the battlefield"; + } + + private QueenKaylaBinKroogEffect(final QueenKaylaBinKroogEffect effect) { + super(effect); + } + + @Override + public QueenKaylaBinKroogEffect copy() { + return new QueenKaylaBinKroogEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null || player.getHand().isEmpty()) { + return false; + } + Cards cards = player.discard(player.getHand(), false, source, game); + player.drawCards(cards.size(), source, game); + TargetCard target = new QueenKaylaBinKroogTarget(); + player.choose(outcome, cards, target, game); + player.moveCards(new CardsImpl(target.getTargets()), Zone.BATTLEFIELD, source, game); + return true; + } +} + +class QueenKaylaBinKroogTarget extends TargetCard { + + private static final FilterCard filter = new FilterCard("artifact or creature card"); + + static { + filter.add(Predicates.or( + CardType.ARTIFACT.getPredicate(), + CardType.CREATURE.getPredicate() + )); + } + + QueenKaylaBinKroogTarget() { + super(0, 3, Zone.ALL, filter); + this.setNotTarget(true); + } + + private QueenKaylaBinKroogTarget(final QueenKaylaBinKroogTarget target) { + super(target); + } + + @Override + public QueenKaylaBinKroogTarget copy() { + return new QueenKaylaBinKroogTarget(this); + } + + @Override + public boolean canTarget(UUID playerId, UUID id, Ability ability, Game game) { + if (!super.canTarget(playerId, id, ability, game)) { + return false; + } + Card card = game.getCard(id); + return card != null && 1 <= card.getManaValue() && card.getManaValue() <= 3 && this + .getTargets() + .stream() + .map(game::getCard) + .filter(Objects::nonNull) + .mapToInt(MageObject::getManaValue) + .noneMatch(x -> card.getManaValue() == x); + } + + + @Override + public Set possibleTargets(UUID sourceControllerId, Ability source, Game game) { + Set possibleTargets = super.possibleTargets(sourceControllerId, source, game); + Set manaValues = this + .getTargets() + .stream() + .map(game::getCard) + .filter(Objects::nonNull) + .map(MageObject::getManaValue) + .collect(Collectors.toSet()); + possibleTargets.removeIf(uuid -> { + Card card = game.getCard(uuid); + return card != null && manaValues.contains(card.getManaValue()); + }); + return possibleTargets; + } +} diff --git a/Mage.Sets/src/mage/sets/TheBrothersWar.java b/Mage.Sets/src/mage/sets/TheBrothersWar.java index 293adba6743..31db5a2727e 100644 --- a/Mage.Sets/src/mage/sets/TheBrothersWar.java +++ b/Mage.Sets/src/mage/sets/TheBrothersWar.java @@ -25,6 +25,7 @@ public final class TheBrothersWar extends ExpansionSet { cards.add(new SetCardInfo("Mishra's Foundry", 265, Rarity.RARE, mage.cards.m.MishrasFoundry.class)); cards.add(new SetCardInfo("Mountain", 284, Rarity.LAND, mage.cards.basiclands.Mountain.class, FULL_ART_BFZ_VARIOUS)); cards.add(new SetCardInfo("Plains", 278, Rarity.LAND, mage.cards.basiclands.Plains.class, FULL_ART_BFZ_VARIOUS)); + cards.add(new SetCardInfo("Queen Kayla bin-Kroog", 218, Rarity.RARE, mage.cards.q.QueenKaylaBinKroog.class)); cards.add(new SetCardInfo("Recruitment Officer", 23, Rarity.UNCOMMON, mage.cards.r.RecruitmentOfficer.class)); cards.add(new SetCardInfo("Surge Engine", 81, Rarity.MYTHIC, mage.cards.s.SurgeEngine.class)); cards.add(new SetCardInfo("Swamp", 282, Rarity.LAND, mage.cards.basiclands.Swamp.class, FULL_ART_BFZ_VARIOUS));