From 9c7fc4373756405d935c27eec648928957dba5b2 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 20 Jun 2018 16:26:55 -0400 Subject: [PATCH] Implemented One with the Machine --- .../src/mage/cards/o/OneWithTheMachine.java | 33 +++++++++++++++++++ Mage.Sets/src/mage/sets/CoreSet2019.java | 1 + .../common/HighestConvertedManaCostValue.java | 29 ++++++++++------ 3 files changed, 53 insertions(+), 10 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/o/OneWithTheMachine.java diff --git a/Mage.Sets/src/mage/cards/o/OneWithTheMachine.java b/Mage.Sets/src/mage/cards/o/OneWithTheMachine.java new file mode 100644 index 0000000000..3827e58217 --- /dev/null +++ b/Mage.Sets/src/mage/cards/o/OneWithTheMachine.java @@ -0,0 +1,33 @@ +package mage.cards.o; + +import java.util.UUID; +import mage.abilities.dynamicvalue.common.HighestConvertedManaCostValue; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; + +/** + * + * @author TheElk801 + */ +public final class OneWithTheMachine extends CardImpl { + + public OneWithTheMachine(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{U}"); + + // Draw cards equal to the highest converted mana cost among artifacts you control. + this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect( + new HighestConvertedManaCostValue() + ).setText("Draw cards equal to the highest converted mana cost among artifacts you control")); + } + + public OneWithTheMachine(final OneWithTheMachine card) { + super(card); + } + + @Override + public OneWithTheMachine copy() { + return new OneWithTheMachine(this); + } +} diff --git a/Mage.Sets/src/mage/sets/CoreSet2019.java b/Mage.Sets/src/mage/sets/CoreSet2019.java index 78271a4b22..49a402ad8b 100644 --- a/Mage.Sets/src/mage/sets/CoreSet2019.java +++ b/Mage.Sets/src/mage/sets/CoreSet2019.java @@ -145,6 +145,7 @@ public final class CoreSet2019 extends ExpansionSet { cards.add(new SetCardInfo("Omenspeaker", 64, Rarity.COMMON, mage.cards.o.Omenspeaker.class)); cards.add(new SetCardInfo("Omniscience", 65, Rarity.MYTHIC, mage.cards.o.Omniscience.class)); cards.add(new SetCardInfo("Onakke Ogre", 153, Rarity.COMMON, mage.cards.o.OnakkeOgre.class)); + cards.add(new SetCardInfo("One with the Machine", 66, Rarity.RARE, mage.cards.o.OneWithTheMachine.class)); cards.add(new SetCardInfo("Open the Graves", 112, Rarity.RARE, mage.cards.o.OpenTheGraves.class)); cards.add(new SetCardInfo("Oreskos Swiftclaw", 31, Rarity.COMMON, mage.cards.o.OreskosSwiftclaw.class)); cards.add(new SetCardInfo("Palladia-Mors, the Ruiner", 219, Rarity.MYTHIC, mage.cards.p.PalladiaMorsTheRuiner.class)); diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/HighestConvertedManaCostValue.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/HighestConvertedManaCostValue.java index 0acf8d10df..d879b439e7 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/HighestConvertedManaCostValue.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/HighestConvertedManaCostValue.java @@ -3,6 +3,8 @@ package mage.abilities.dynamicvalue.common; import mage.abilities.Ability; import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.effects.Effect; +import mage.filter.FilterPermanent; +import mage.filter.StaticFilters; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -13,19 +15,26 @@ import mage.players.Player; */ public class HighestConvertedManaCostValue implements DynamicValue { + private final FilterPermanent filter; + + public HighestConvertedManaCostValue() { + this(StaticFilters.FILTER_PERMANENTS); + } + + public HighestConvertedManaCostValue(FilterPermanent filter) { + this.filter = filter; + } + @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - int highCMC = 0; Player controller = game.getPlayer(sourceAbility.getControllerId()); - if (controller != null) { - for (Permanent permanent : game.getBattlefield().getAllActivePermanents(controller.getId())) { - if (permanent.getSpellAbility() != null) { - int cmc = permanent.getSpellAbility().getManaCosts().convertedManaCost(); - if (cmc > highCMC) { - highCMC = cmc; - } - } - } + if (controller == null) { + return 0; + } + int highCMC = 0; + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, controller.getId(), game)) { + int cmc = permanent.getConvertedManaCost(); + highCMC = Math.max(highCMC, cmc); } return highCMC; }