Implemented One with the Machine

This commit is contained in:
Evan Kranzler 2018-06-20 16:26:55 -04:00
parent 9de8536e8e
commit 9c7fc43737
3 changed files with 53 additions and 10 deletions

View file

@ -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);
}
}

View file

@ -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));

View file

@ -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;
}