From db8102a94c7d922a8515ef3ea92ef65b5234a394 Mon Sep 17 00:00:00 2001 From: androosss <101566943+androosss@users.noreply.github.com> Date: Wed, 9 Apr 2025 03:18:55 +0200 Subject: [PATCH] [TDM] Implement Betor, Kin to All (#13508) * Implemented Betor, Kin to All * intervenening if in ability * update betor * reduce ident --- Mage.Sets/src/mage/cards/b/BetorKinToAll.java | 165 ++++++++++++++++++ .../src/mage/sets/TarkirDragonstorm.java | 9 +- 2 files changed, 171 insertions(+), 3 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/b/BetorKinToAll.java diff --git a/Mage.Sets/src/mage/cards/b/BetorKinToAll.java b/Mage.Sets/src/mage/cards/b/BetorKinToAll.java new file mode 100644 index 00000000000..923f3db7a30 --- /dev/null +++ b/Mage.Sets/src/mage/cards/b/BetorKinToAll.java @@ -0,0 +1,165 @@ +package mage.cards.b; + +import java.util.UUID; + +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.condition.Condition; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.effects.Effect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.hint.Hint; +import mage.abilities.hint.ValueHint; +import mage.abilities.keyword.FlyingAbility; +import mage.abilities.triggers.BeginningOfEndStepTriggeredAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.filter.StaticFilters; +import mage.filter.common.FilterCreaturePermanent; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; + +/** + * + * @author androosss + */ +public final class BetorKinToAll extends CardImpl { + + private static final Hint hint = new ValueHint( + "Total toughness of creatures you control", ControlledCreaturesToughnessValue.instance); + + public BetorKinToAll(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[] { CardType.CREATURE }, "{2}{W}{B}{G}"); + + this.supertype.add(SuperType.LEGENDARY); + this.subtype.add(SubType.SPIRIT); + this.subtype.add(SubType.DRAGON); + this.power = new MageInt(5); + this.toughness = new MageInt(7); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // At the beginning of your end step, if creatures you control have total + // toughness 10 or greater, draw a card. Then if creatures you control have + // total toughness 20 or greater, untap each creature you control. Then if + // creatures you control have total toughness 40 or greater, each opponent loses + // half their life, rounded up. + Ability betorAbility = new BeginningOfEndStepTriggeredAbility(new DrawCardSourceControllerEffect(1)) + .withInterveningIf(BetorKinToAllCondition.instance).addHint(hint); + betorAbility.addEffect(new BetorKinToAllEffect()); + this.addAbility(betorAbility); + } + + private BetorKinToAll(final BetorKinToAll card) { + super(card); + } + + @Override + public BetorKinToAll copy() { + return new BetorKinToAll(this); + } +} + +enum BetorKinToAllCondition implements Condition { + instance; + + @Override + public boolean apply(Game game, Ability source) { + return ControlledCreaturesToughnessValue.instance.calculate(game, source, null) >= 10; + } + +} + +class BetorKinToAllEffect extends OneShotEffect { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent(); + + BetorKinToAllEffect() { + super(Outcome.Benefit); + this.staticText = "Then if creatures you control have total toughness 20 or greater, untap each creature you control. Then if creatures you control have total toughness 40 or greater, each opponent loses half their life, rounded up."; + } + + private BetorKinToAllEffect(final BetorKinToAllEffect effect) { + super(effect); + } + + @Override + public BetorKinToAllEffect copy() { + return new BetorKinToAllEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { + return false; + } + + int sumToughness = ControlledCreaturesToughnessValue.instance.calculate(game, source, null); + + if (sumToughness < 20) { + return true; + } + for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), + game)) { + permanent.untap(game); + } + + if (sumToughness < 40) { + return true; + } + + for (UUID playerId : game.getOpponents(controller.getId())) { + Player opponent = game.getPlayer(playerId); + if (opponent == null) { + continue; + } + int amount = (int) Math.ceil(opponent.getLife() / 2f); + if (amount > 0) { + opponent.loseLife(amount, game, source, false); + } + } + + return true; + } +} + +enum ControlledCreaturesToughnessValue implements DynamicValue { + instance; + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + return game + .getBattlefield() + .getActivePermanents( + StaticFilters.FILTER_CONTROLLED_CREATURE, + sourceAbility.getControllerId(), sourceAbility, game) + .stream() + .map(MageObject::getToughness) + .mapToInt(MageInt::getValue) + .sum(); + } + + @Override + public ControlledCreaturesToughnessValue copy() { + return this; + } + + @Override + public String getMessage() { + return "total toughness of creatures you control"; + } + + @Override + public String toString() { + return "X"; + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/TarkirDragonstorm.java b/Mage.Sets/src/mage/sets/TarkirDragonstorm.java index 5ae3005a566..e9e25436f1b 100644 --- a/Mage.Sets/src/mage/sets/TarkirDragonstorm.java +++ b/Mage.Sets/src/mage/sets/TarkirDragonstorm.java @@ -1,12 +1,12 @@ package mage.sets; +import java.util.Arrays; +import java.util.List; + import mage.cards.ExpansionSet; import mage.constants.Rarity; import mage.constants.SetType; -import java.util.Arrays; -import java.util.List; - /** * @author TheElk801 */ @@ -43,6 +43,9 @@ public final class TarkirDragonstorm extends ExpansionSet { cards.add(new SetCardInfo("Awaken the Honored Dead", 170, Rarity.RARE, mage.cards.a.AwakenTheHonoredDead.class)); cards.add(new SetCardInfo("Barrensteppe Siege", 171, Rarity.RARE, mage.cards.b.BarrensteppeSiege.class)); cards.add(new SetCardInfo("Bearer of Glory", 4, Rarity.COMMON, mage.cards.b.BearerOfGlory.class)); + cards.add(new SetCardInfo("Betor, Kin to All", 172, Rarity.MYTHIC, mage.cards.b.BetorKinToAll.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Betor, Kin to All", 308, Rarity.MYTHIC, mage.cards.b.BetorKinToAll.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Betor, Kin to All", 353, Rarity.MYTHIC, mage.cards.b.BetorKinToAll.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Bewildering Blizzard", 38, Rarity.UNCOMMON, mage.cards.b.BewilderingBlizzard.class)); cards.add(new SetCardInfo("Bloodfell Caves", 250, Rarity.COMMON, mage.cards.b.BloodfellCaves.class)); cards.add(new SetCardInfo("Bloomvine Regent", 136, Rarity.RARE, mage.cards.b.BloomvineRegent.class));