From 90e620452d9104636ba56f916896ea339a8da62d Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Tue, 27 Apr 2021 20:07:36 -0400 Subject: [PATCH] [C21] Implemented Breena, the Demagogue --- .../src/mage/cards/b/BreenaTheDemagogue.java | 141 ++++++++++++++++++ .../src/mage/sets/Commander2021Edition.java | 1 + 2 files changed, 142 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/b/BreenaTheDemagogue.java diff --git a/Mage.Sets/src/mage/cards/b/BreenaTheDemagogue.java b/Mage.Sets/src/mage/cards/b/BreenaTheDemagogue.java new file mode 100644 index 0000000000..fe2dcbeadb --- /dev/null +++ b/Mage.Sets/src/mage/cards/b/BreenaTheDemagogue.java @@ -0,0 +1,141 @@ +package mage.cards.b; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DrawCardTargetEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.counters.CounterType; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; +import mage.target.common.TargetControlledCreaturePermanent; +import mage.target.targetpointer.FixedTarget; + +import java.util.Objects; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class BreenaTheDemagogue extends CardImpl { + + public BreenaTheDemagogue(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}{B}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.BIRD); + this.subtype.add(SubType.WARLOCK); + this.power = new MageInt(1); + this.toughness = new MageInt(3); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // Whenever a player attacks one of your opponents, if that opponent has more life than another of your opponents, that attacking player draws a card and you put two +1/+1 counters on a creature you control. + this.addAbility(new BreenaTheDemagogueTriggeredAbility()); + } + + private BreenaTheDemagogue(final BreenaTheDemagogue card) { + super(card); + } + + @Override + public BreenaTheDemagogue copy() { + return new BreenaTheDemagogue(this); + } +} + +class BreenaTheDemagogueTriggeredAbility extends TriggeredAbilityImpl { + + BreenaTheDemagogueTriggeredAbility() { + super(Zone.BATTLEFIELD, new DrawCardTargetEffect(1), false); + this.addEffect(new BreenaTheDemagogueEffect()); + } + + private BreenaTheDemagogueTriggeredAbility(final BreenaTheDemagogueTriggeredAbility ability) { + super(ability); + } + + @Override + public BreenaTheDemagogueTriggeredAbility copy() { + return new BreenaTheDemagogueTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.DEFENDER_ATTACKED; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (!game.getOpponents(getControllerId()).contains(event.getTargetId())) { + return false; + } + getEffects().setTargetPointer(new FixedTarget(event.getPlayerId())); + getEffects().setValue("attackedPlayer", event.getTargetId()); + return true; + } + + @Override + public boolean checkInterveningIfClause(Game game) { + Player player = game.getPlayer((UUID) getEffects().get(0).getValue("attackedPlayer")); + return player != null + && player.getLife() > game.getOpponents(getControllerId()) + .stream() + .map(game::getPlayer) + .filter(Objects::nonNull) + .mapToInt(Player::getLife) + .min() + .orElse(0); + } + + @Override + public String getRule() { + return "Whenever a player attacks one of your opponents, " + + "if that opponent has more life than another of your opponents, " + + "that attacking player draws a card and you put two +1/+1 counters on a creature you control."; + } +} + +class BreenaTheDemagogueEffect extends OneShotEffect { + + BreenaTheDemagogueEffect() { + super(Outcome.Benefit); + } + + private BreenaTheDemagogueEffect(final BreenaTheDemagogueEffect effect) { + super(effect); + } + + @Override + public BreenaTheDemagogueEffect copy() { + return new BreenaTheDemagogueEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null || game.getBattlefield().count( + StaticFilters.FILTER_CONTROLLED_CREATURE, + source.getSourceId(), source.getControllerId(), game + ) < 1) { + return false; + } + TargetPermanent target = new TargetControlledCreaturePermanent(); + target.setNotTarget(true); + player.choose(outcome, target, source.getSourceId(), game); + Permanent permanent = game.getPermanent(source.getSourceId()); + return permanent != null && permanent.addCounters( + CounterType.P1P1.createInstance(2), + source.getControllerId(), source, game + ); + } +} diff --git a/Mage.Sets/src/mage/sets/Commander2021Edition.java b/Mage.Sets/src/mage/sets/Commander2021Edition.java index 764f06439b..928f3516dd 100644 --- a/Mage.Sets/src/mage/sets/Commander2021Edition.java +++ b/Mage.Sets/src/mage/sets/Commander2021Edition.java @@ -59,6 +59,7 @@ public final class Commander2021Edition extends ExpansionSet { cards.add(new SetCardInfo("Bosh, Iron Golem", 237, Rarity.RARE, mage.cards.b.BoshIronGolem.class)); cards.add(new SetCardInfo("Brainstorm", 115, Rarity.COMMON, mage.cards.b.Brainstorm.class)); cards.add(new SetCardInfo("Brass's Bounty", 160, Rarity.RARE, mage.cards.b.BrasssBounty.class)); + cards.add(new SetCardInfo("Breena, the Demagogue", 1, Rarity.MYTHIC, mage.cards.b.BreenaTheDemagogue.class)); cards.add(new SetCardInfo("Bronze Guardian", 13, Rarity.RARE, mage.cards.b.BronzeGuardian.class)); cards.add(new SetCardInfo("Burnished Hart", 238, Rarity.UNCOMMON, mage.cards.b.BurnishedHart.class)); cards.add(new SetCardInfo("Call the Skybreaker", 211, Rarity.RARE, mage.cards.c.CallTheSkybreaker.class));