diff --git a/Mage.Sets/src/mage/cards/i/ImposingGrandeur.java b/Mage.Sets/src/mage/cards/i/ImposingGrandeur.java new file mode 100644 index 0000000000..d46bcf7e76 --- /dev/null +++ b/Mage.Sets/src/mage/cards/i/ImposingGrandeur.java @@ -0,0 +1,90 @@ +package mage.cards.i; + +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.CommanderCardType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.game.Game; +import mage.players.Player; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class ImposingGrandeur extends CardImpl { + + public ImposingGrandeur(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{R}"); + + // Each player may discard their hand and draw cards equal to the greatest mana value of a commander they own on the battlefield or in the command zone. + this.getSpellAbility().addEffect(new ImposingGrandeurEffect()); + } + + private ImposingGrandeur(final ImposingGrandeur card) { + super(card); + } + + @Override + public ImposingGrandeur copy() { + return new ImposingGrandeur(this); + } +} + +class ImposingGrandeurEffect extends OneShotEffect { + + ImposingGrandeurEffect() { + super(Outcome.DrawCard); + staticText = "each player may discard their hand and draw cards equal to " + + "the greatest mana value of a commander they own on the battlefield or in the command zone"; + } + + private ImposingGrandeurEffect(final ImposingGrandeurEffect effect) { + super(effect); + } + + @Override + public ImposingGrandeurEffect copy() { + return new ImposingGrandeurEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Map map = new HashMap<>(); + for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { + Player player = game.getPlayer(playerId); + if (player == null) { + continue; + } + int maxValue = game + .getCommanderCardsFromAnyZones( + player, CommanderCardType.ANY, + Zone.BATTLEFIELD, Zone.COMMAND + ) + .stream() + .mapToInt(MageObject::getManaValue) + .max() + .orElse(0); + map.put(playerId, maxValue); + } + for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { + Player player = game.getPlayer(playerId); + int amount = map.getOrDefault(playerId, 0); + if (player != null && player.chooseUse( + outcome, "Discard your hand and draw " + + amount + " cards?", source, game + )) { + player.discard(player.getHand(), false, source, game); + player.drawCards(amount, source, game); + } + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/CrimsonVowCommander.java b/Mage.Sets/src/mage/sets/CrimsonVowCommander.java index 7896dfbd4c..cb2471e70e 100644 --- a/Mage.Sets/src/mage/sets/CrimsonVowCommander.java +++ b/Mage.Sets/src/mage/sets/CrimsonVowCommander.java @@ -73,6 +73,7 @@ public final class CrimsonVowCommander extends ExpansionSet { cards.add(new SetCardInfo("Hanged Executioner", 89, Rarity.RARE, mage.cards.h.HangedExecutioner.class)); cards.add(new SetCardInfo("Haunted Library", 6, Rarity.RARE, mage.cards.h.HauntedLibrary.class)); cards.add(new SetCardInfo("Hollowhenge Overlord", 36, Rarity.RARE, mage.cards.h.HollowhengeOverlord.class)); + cards.add(new SetCardInfo("Imposing Grandeur", 24, Rarity.RARE, mage.cards.i.ImposingGrandeur.class)); cards.add(new SetCardInfo("Imprisoned in the Moon", 106, Rarity.RARE, mage.cards.i.ImprisonedInTheMoon.class)); cards.add(new SetCardInfo("Indulgent Aristocrat", 130, Rarity.UNCOMMON, mage.cards.i.IndulgentAristocrat.class)); cards.add(new SetCardInfo("Kamber, the Plunderer", 19, Rarity.RARE, mage.cards.k.KamberThePlunderer.class));