From 07a8cc6bc9f4d0b865a6e5fb9b4ad048e0be9c7b Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 2 Jun 2022 07:57:16 -0400 Subject: [PATCH] [CLB] Implemented Vexing Puzzlebox --- .../src/mage/cards/v/VexingPuzzlebox.java | 78 +++++++++++++++++++ .../CommanderLegendsBattleForBaldursGate.java | 1 + .../OneOrMoreDiceRolledTriggeredAbility.java | 8 ++ 3 files changed, 87 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/v/VexingPuzzlebox.java diff --git a/Mage.Sets/src/mage/cards/v/VexingPuzzlebox.java b/Mage.Sets/src/mage/cards/v/VexingPuzzlebox.java new file mode 100644 index 00000000000..a368ea57f29 --- /dev/null +++ b/Mage.Sets/src/mage/cards/v/VexingPuzzlebox.java @@ -0,0 +1,78 @@ +package mage.cards.v; + +import mage.abilities.Ability; +import mage.abilities.common.OneOrMoreDiceRolledTriggeredAbility; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.RemoveCountersSourceCost; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.RollDiceEffect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect; +import mage.abilities.mana.AnyColorManaAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.counters.CounterType; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.target.common.TargetCardInLibrary; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class VexingPuzzlebox extends CardImpl { + + public VexingPuzzlebox(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}"); + + // Whenever you roll one or more dice, put a number of charge counters on Vexing Puzzlebox equal to the result. + this.addAbility(new OneOrMoreDiceRolledTriggeredAbility(new AddCountersSourceEffect( + CounterType.CHARGE.createInstance(), VexingPuzzleboxValue.instance, true + ).setText("put a number of charge counters on {this} equal to the result"))); + + // {T}: Add one mana of any color. Roll a d20. + AnyColorManaAbility manaAbility = new AnyColorManaAbility(); + manaAbility.addEffect(new RollDiceEffect(null, 20).setText("Roll a d20")); + manaAbility.setUndoPossible(false); + this.addAbility(manaAbility); + + // {T}, Remove 100 charge counters from Vexing Puzzlebox: Search your library for an artifact card, put that card onto the battlefield, then shuffle. + Ability ability = new SimpleActivatedAbility(new SearchLibraryPutInPlayEffect( + new TargetCardInLibrary(StaticFilters.FILTER_CARD_ARTIFACT_AN) + ), new TapSourceCost()); + ability.addCost(new RemoveCountersSourceCost(CounterType.CHARGE.createInstance(100))); + this.addAbility(ability); + } + + private VexingPuzzlebox(final VexingPuzzlebox card) { + super(card); + } + + @Override + public VexingPuzzlebox copy() { + return new VexingPuzzlebox(this); + } +} + +enum VexingPuzzleboxValue implements DynamicValue { + instance; + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + return (Integer) effect.getValue("totalDieRoll"); + } + + @Override + public VexingPuzzleboxValue copy() { + return this; + } + + @Override + public String getMessage() { + return ""; + } +} diff --git a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java index 798acdfd514..97536ffb3d1 100644 --- a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java +++ b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java @@ -551,6 +551,7 @@ public final class CommanderLegendsBattleForBaldursGate extends ExpansionSet { cards.add(new SetCardInfo("Vault of the Archangel", 927, Rarity.RARE, mage.cards.v.VaultOfTheArchangel.class)); cards.add(new SetCardInfo("Vengeful Ancestor", 812, Rarity.RARE, mage.cards.v.VengefulAncestor.class)); cards.add(new SetCardInfo("Veteran Soldier", 48, Rarity.UNCOMMON, mage.cards.v.VeteranSoldier.class)); + cards.add(new SetCardInfo("Vexing Puzzlebox", 343, Rarity.MYTHIC, mage.cards.v.VexingPuzzlebox.class)); cards.add(new SetCardInfo("Vicious Battlerager", 155, Rarity.COMMON, mage.cards.v.ViciousBattlerager.class)); cards.add(new SetCardInfo("Viconia, Drow Apostate", 156, Rarity.UNCOMMON, mage.cards.v.ViconiaDrowApostate.class)); cards.add(new SetCardInfo("Vivien, Champion of the Wilds", 838, Rarity.RARE, mage.cards.v.VivienChampionOfTheWilds.class)); diff --git a/Mage/src/main/java/mage/abilities/common/OneOrMoreDiceRolledTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/OneOrMoreDiceRolledTriggeredAbility.java index 53ba37e8903..28b0aa6b99c 100644 --- a/Mage/src/main/java/mage/abilities/common/OneOrMoreDiceRolledTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/OneOrMoreDiceRolledTriggeredAbility.java @@ -47,7 +47,15 @@ public class OneOrMoreDiceRolledTriggeredAbility extends TriggeredAbilityImpl { .mapToInt(Integer::intValue) .max() .orElse(0); + int totalRoll = ((DiceRolledEvent) event) + .getResults() + .stream() + .filter(Integer.class::isInstance) // only numerical die result can be masured + .map(Integer.class::cast) + .mapToInt(Integer::intValue) + .sum(); this.getEffects().setValue("maxDieRoll", maxRoll); + this.getEffects().setValue("totalDieRoll", totalRoll); return true; }