diff --git a/Mage.Sets/src/mage/cards/d/DescentIntoAvernus.java b/Mage.Sets/src/mage/cards/d/DescentIntoAvernus.java new file mode 100644 index 00000000000..135284f3807 --- /dev/null +++ b/Mage.Sets/src/mage/cards/d/DescentIntoAvernus.java @@ -0,0 +1,87 @@ +package mage.cards.d; + +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.dynamicvalue.common.CountersSourceCount; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DamagePlayersEffect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.TargetController; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.permanent.token.TreasureToken; + +import java.util.Objects; +import java.util.Optional; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class DescentIntoAvernus extends CardImpl { + + private static final DynamicValue xValue = new CountersSourceCount(CounterType.DESCENT); + + public DescentIntoAvernus(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{R}"); + + // At the beginning of your upkeep, put two descent counters on Descent into Avernus. Then each player creates X Treasure tokens and Descent into Avernus deals X damage to each player, where X is the number of descent counters on Descent into Avernus. + Ability ability = new BeginningOfUpkeepTriggeredAbility( + new AddCountersSourceEffect(CounterType.DESCENT.createInstance(2)), + TargetController.YOU, false + ); + ability.addEffect(new DescentIntoAvernusEffect()); + ability.addEffect(new DamagePlayersEffect( + Outcome.Damage, xValue, TargetController.ANY + ).concatBy("and")); + this.addAbility(ability); + } + + private DescentIntoAvernus(final DescentIntoAvernus card) { + super(card); + } + + @Override + public DescentIntoAvernus copy() { + return new DescentIntoAvernus(this); + } +} + +class DescentIntoAvernusEffect extends OneShotEffect { + + DescentIntoAvernusEffect() { + super(Outcome.Benefit); + staticText = "Then each player creates X Treasure tokens"; + } + + private DescentIntoAvernusEffect(final DescentIntoAvernusEffect effect) { + super(effect); + } + + @Override + public DescentIntoAvernusEffect copy() { + return new DescentIntoAvernusEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + int count = Optional + .of(source.getSourcePermanentOrLKI(game)) + .filter(Objects::nonNull) + .map(permanent -> permanent.getCounters(game)) + .map(counters -> counters.getCount(CounterType.DESCENT)) + .orElse(0); + if (count < 1) { + return false; + } + for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { + new TreasureToken().putOntoBattlefield(count, game, source); + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java index 9d3635a5d6b..6563b2818cd 100644 --- a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java +++ b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java @@ -158,6 +158,7 @@ public final class CommanderLegendsBattleForBaldursGate extends ExpansionSet { cards.add(new SetCardInfo("Deadly Dispute", 124, Rarity.COMMON, mage.cards.d.DeadlyDispute.class)); cards.add(new SetCardInfo("Decanter of Endless Water", 309, Rarity.COMMON, mage.cards.d.DecanterOfEndlessWater.class)); cards.add(new SetCardInfo("Demon Bolt", 787, Rarity.COMMON, mage.cards.d.DemonBolt.class)); + cards.add(new SetCardInfo("Descent into Avernus", 169, Rarity.RARE, mage.cards.d.DescentIntoAvernus.class)); cards.add(new SetCardInfo("Desolate Lighthouse", 890, Rarity.RARE, mage.cards.d.DesolateLighthouse.class)); cards.add(new SetCardInfo("Despark", 841, Rarity.UNCOMMON, mage.cards.d.Despark.class)); cards.add(new SetCardInfo("Dimir Aqueduct", 891, Rarity.UNCOMMON, mage.cards.d.DimirAqueduct.class)); diff --git a/Mage/src/main/java/mage/counters/CounterType.java b/Mage/src/main/java/mage/counters/CounterType.java index dfbc922f8e7..860ae153df8 100644 --- a/Mage/src/main/java/mage/counters/CounterType.java +++ b/Mage/src/main/java/mage/counters/CounterType.java @@ -44,6 +44,7 @@ public enum CounterType { DEATHTOUCH("deathtouch"), DELAY("delay"), DEPLETION("depletion"), + DESCENT("descent"), DESPAIR("despair"), DEVOTION("devotion"), DIVINITY("divinity"),