diff --git a/Mage.Sets/src/mage/cards/j/JeskasWill.java b/Mage.Sets/src/mage/cards/j/JeskasWill.java new file mode 100644 index 0000000000..c2b9125716 --- /dev/null +++ b/Mage.Sets/src/mage/cards/j/JeskasWill.java @@ -0,0 +1,77 @@ +package mage.cards.j; + +import mage.Mana; +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.condition.common.ControlACommanderCondition; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.ExileTop3MayPlayUntilEndOfTurnEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.game.Game; +import mage.players.Player; +import mage.target.common.TargetOpponent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class JeskasWill extends CardImpl { + + public JeskasWill(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{R}"); + + // Choose one. If you control a commander as you cast this spell, you may choose both. + this.getSpellAbility().getModes().setChooseText( + "Choose one. If you control a commander as you cast this spell, you may choose both." + ); + this.getSpellAbility().getModes().setMoreCondition(ControlACommanderCondition.instance); + + // • Add {R} for each card in target opponent's hand. + this.getSpellAbility().addEffect(new JeskasWillEffect()); + this.getSpellAbility().addTarget(new TargetOpponent()); + + // • Exile the top three cards of your library. You may play them this turn. + this.getSpellAbility().addMode(new Mode(new ExileTop3MayPlayUntilEndOfTurnEffect())); + } + + private JeskasWill(final JeskasWill card) { + super(card); + } + + @Override + public JeskasWill copy() { + return new JeskasWill(this); + } +} + +class JeskasWillEffect extends OneShotEffect { + + JeskasWillEffect() { + super(Outcome.Benefit); + staticText = "Add {R} for each card in target opponent's hand."; + } + + private JeskasWillEffect(final JeskasWillEffect effect) { + super(effect); + } + + @Override + public JeskasWillEffect copy() { + return new JeskasWillEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Player player = game.getPlayer(source.getFirstTarget()); + if (controller == null || player == null || player.getHand().size() < 1) { + return false; + } + controller.getManaPool().addMana(Mana.RedMana(player.getHand().size()), game, source); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/CommanderLegends.java b/Mage.Sets/src/mage/sets/CommanderLegends.java index 522504e9e4..5e7d31c4db 100644 --- a/Mage.Sets/src/mage/sets/CommanderLegends.java +++ b/Mage.Sets/src/mage/sets/CommanderLegends.java @@ -109,6 +109,7 @@ public final class CommanderLegends extends ExpansionSet { cards.add(new SetCardInfo("Inspiring Roar", 23, Rarity.COMMON, mage.cards.i.InspiringRoar.class)); cards.add(new SetCardInfo("Intangible Virtue", 24, Rarity.UNCOMMON, mage.cards.i.IntangibleVirtue.class)); cards.add(new SetCardInfo("Interpret the Signs", 75, Rarity.UNCOMMON, mage.cards.i.InterpretTheSigns.class)); + cards.add(new SetCardInfo("Jeska's Will", 187, Rarity.RARE, mage.cards.j.JeskasWill.class)); cards.add(new SetCardInfo("Jeska, Thrice Reborn", 186, Rarity.MYTHIC, mage.cards.j.JeskaThriceReborn.class)); cards.add(new SetCardInfo("Jeweled Lotus", 319, Rarity.MYTHIC, mage.cards.j.JeweledLotus.class)); cards.add(new SetCardInfo("Kamahl, Heart of Krosa", 237, Rarity.MYTHIC, mage.cards.k.KamahlHeartOfKrosa.class)); diff --git a/Mage/src/main/java/mage/abilities/Modes.java b/Mage/src/main/java/mage/abilities/Modes.java index 1d3e31ecab..10a7a87aa7 100644 --- a/Mage/src/main/java/mage/abilities/Modes.java +++ b/Mage/src/main/java/mage/abilities/Modes.java @@ -1,5 +1,6 @@ package mage.abilities; +import mage.abilities.condition.Condition; import mage.abilities.costs.OptionalAdditionalModeSourceCosts; import mage.cards.Card; import mage.constants.Outcome; @@ -36,6 +37,7 @@ public class Modes extends LinkedHashMap { private boolean isRandom = false; private String chooseText = null; private boolean resetEachTurn = false; + private Condition moreCondition; public Modes() { this.currentMode = new Mode(); @@ -214,6 +216,10 @@ public class Modes extends LinkedHashMap { this.put(mode.getId(), mode); } + public void setMoreCondition(Condition moreCondition) { + this.moreCondition = moreCondition; + } + public boolean choose(Game game, Ability source) { if (this.isResetEachTurn()) { if (this.getTurnNum(game, source) != game.getTurnNum()) { @@ -279,6 +285,9 @@ public class Modes extends LinkedHashMap { // player chooses modes manually this.currentMode = null; int currentMaxModes = this.getMaxModes(); + if (moreCondition != null && moreCondition.apply(game, source)) { + currentMaxModes = Integer.MAX_VALUE; + } if (getMaxModesFilter() != null) { if (maxModesFilter instanceof FilterPlayer) { currentMaxModes = 0;