From f91a3f44646b45bbd421c9928b69c90dc24e90cd Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 19 May 2022 09:27:19 -0400 Subject: [PATCH] [CLB] Implemented Battle Angels of Tyr --- .../src/mage/cards/b/BattleAngelsOfTyr.java | 129 ++++++++++++++++++ .../CommanderLegendsBattleForBaldursGate.java | 1 + 2 files changed, 130 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/b/BattleAngelsOfTyr.java diff --git a/Mage.Sets/src/mage/cards/b/BattleAngelsOfTyr.java b/Mage.Sets/src/mage/cards/b/BattleAngelsOfTyr.java new file mode 100644 index 0000000000..06fec1cd74 --- /dev/null +++ b/Mage.Sets/src/mage/cards/b/BattleAngelsOfTyr.java @@ -0,0 +1,129 @@ +package mage.cards.b; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.abilities.keyword.MyriadAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.filter.StaticFilters; +import mage.game.Controllable; +import mage.game.Game; +import mage.game.permanent.token.TreasureToken; +import mage.players.Player; +import mage.util.CardUtil; + +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.UUID; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * @author TheElk801 + */ +public final class BattleAngelsOfTyr extends CardImpl { + + public BattleAngelsOfTyr(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}{W}"); + + this.subtype.add(SubType.ANGEL); + this.subtype.add(SubType.KNIGHT); + this.power = new MageInt(4); + this.toughness = new MageInt(4); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // Myriad + this.addAbility(new MyriadAbility()); + + // Whenever Battle Angels of Tyr deals combat damage to a player, draw a card if that player has more cards in hand than each other player. Then you create a Treasure token if that player controls more lands than each other player. Then you gain 3 life if that player has more life than each other player. + this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility( + new BattleAngelsOfTyrEffect(), false, true + )); + } + + private BattleAngelsOfTyr(final BattleAngelsOfTyr card) { + super(card); + } + + @Override + public BattleAngelsOfTyr copy() { + return new BattleAngelsOfTyr(this); + } +} + +class BattleAngelsOfTyrEffect extends OneShotEffect { + + BattleAngelsOfTyrEffect() { + super(Outcome.Benefit); + staticText = "draw a card if that player has more cards in hand than each other player. " + + "Then you create a Treasure token if that player controls more lands than each other player. " + + "Then you gain 3 life if that player has more life than each other player"; + } + + private BattleAngelsOfTyrEffect(final BattleAngelsOfTyrEffect effect) { + super(effect); + } + + @Override + public BattleAngelsOfTyrEffect copy() { + return new BattleAngelsOfTyrEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Player player = game.getPlayer(getTargetPointer().getFirst(game, source)); + if (controller == null || player == null) { + return false; + } + Set players = game + .getState() + .getPlayersInRange(source.getControllerId(), game) + .stream() + .filter(uuid -> !player.getId().equals(uuid)) + .map(game::getPlayer) + .filter(Objects::nonNull) + .collect(Collectors.toSet()); + if (players + .stream() + .map(Player::getHand) + .mapToInt(Set::size) + .allMatch(x -> player.getHand().size() > x)) { + controller.drawCards(1, source, game); + } + Map map = game + .getBattlefield() + .getActivePermanents(StaticFilters.FILTER_LAND, source.getControllerId(), game) + .stream() + .map(Controllable::getControllerId) + .collect(Collectors.toMap( + Function.identity(), x -> 1, + CardUtil::setOrIncrementValue + )); + if (map.getOrDefault(player.getId(), 0) > + map.entrySet() + .stream() + .filter(e -> !player.getId().equals(e.getKey())) + .mapToInt(Map.Entry::getValue) + .max() + .orElse(0)) { + new TreasureToken().putOntoBattlefield(1, game, source); + } + if (players + .stream() + .mapToInt(Player::getLife) + .allMatch(x -> player.getLife() > x)) { + controller.gainLife(3, game, source); + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java index 1cfe323b4d..ec2ebd25df 100644 --- a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java +++ b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java @@ -29,6 +29,7 @@ public final class CommanderLegendsBattleForBaldursGate extends ExpansionSet { cards.add(new SetCardInfo("Baldur's Gate", 345, Rarity.RARE, mage.cards.b.BaldursGate.class)); cards.add(new SetCardInfo("Bane's Invoker", 7, Rarity.COMMON, mage.cards.b.BanesInvoker.class)); cards.add(new SetCardInfo("Basilisk Collar", 595, Rarity.RARE, mage.cards.b.BasiliskCollar.class)); + cards.add(new SetCardInfo("Battle Angels of Tyr", 9, Rarity.MYTHIC, mage.cards.b.BattleAngelsOfTyr.class)); cards.add(new SetCardInfo("Bhaal's Invoker", 163, Rarity.COMMON, mage.cards.b.BhaalsInvoker.class)); cards.add(new SetCardInfo("Bountiful Promenade", 348, Rarity.RARE, mage.cards.b.BountifulPromenade.class)); cards.add(new SetCardInfo("Bramble Sovereign", 218, Rarity.MYTHIC, mage.cards.b.BrambleSovereign.class));