From 9b68e0860b2844d73f7bc7b15d0de94c5df2b747 Mon Sep 17 00:00:00 2001 From: Noah Gleason Date: Thu, 21 Jun 2018 15:29:17 -0400 Subject: [PATCH] Implement Neurok Transmuter --- .../src/mage/cards/d/DarksteelGarrison.java | 49 +----------- .../src/mage/cards/n/NeurokTransmuter.java | 71 +++++++++++++++++ Mage.Sets/src/mage/sets/Darksteel.java | 1 + .../LoseArtifactTypeTargetEffect.java | 77 +++++++++++++++++++ .../mage/abilities/keyword/EquipAbility.java | 12 ++- .../abilities/keyword/FortifyAbility.java | 42 +++++++++- .../src/main/java/mage/constants/SubType.java | 10 +++ 7 files changed, 204 insertions(+), 58 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/n/NeurokTransmuter.java create mode 100644 Mage/src/main/java/mage/abilities/effects/common/continuous/LoseArtifactTypeTargetEffect.java diff --git a/Mage.Sets/src/mage/cards/d/DarksteelGarrison.java b/Mage.Sets/src/mage/cards/d/DarksteelGarrison.java index dfdba117cd..78c63b2bfc 100644 --- a/Mage.Sets/src/mage/cards/d/DarksteelGarrison.java +++ b/Mage.Sets/src/mage/cards/d/DarksteelGarrison.java @@ -12,6 +12,7 @@ import mage.abilities.effects.Effect; import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.continuous.BoostTargetEffect; import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect; +import mage.abilities.keyword.FortifyAbility; import mage.abilities.keyword.IndestructibleAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; @@ -53,7 +54,7 @@ public final class DarksteelGarrison extends CardImpl { this.addAbility(ability); // Fortify {3} - this.addAbility(new FortifyAbility(Outcome.AddAbility, new GenericManaCost(3))); + this.addAbility(new FortifyAbility(3)); } @@ -66,49 +67,3 @@ public final class DarksteelGarrison extends CardImpl { return new DarksteelGarrison(this); } } - -class FortifyAbility extends ActivatedAbilityImpl { - - private static final FilterControlledPermanent filter = new FilterControlledPermanent("land you control"); - - static { - filter.add(new CardTypePredicate(CardType.LAND)); - } - - public FortifyAbility(Outcome outcome, Cost cost) { - this(outcome, cost, new TargetControlledPermanent(filter)); - } - - public FortifyAbility(Outcome outcome, Cost cost, Target target) { - super(Zone.BATTLEFIELD, new AttachEffect(outcome, "Fortify"), cost); - this.addTarget(target); - this.timing = TimingRule.SORCERY; - } - - @Override - public ActivationStatus canActivate(UUID playerId, Game game) { - ActivationStatus activationStatus = super.canActivate(playerId, game); - if (activationStatus.canActivate()) { - Permanent permanent = game.getPermanent(sourceId); - if (permanent != null && permanent.hasSubtype(SubType.FORTIFICATION, game)) { - return activationStatus; - } - } - return ActivationStatus.getFalse(); - } - - public FortifyAbility(final FortifyAbility ability) { - super(ability); - } - - @Override - public FortifyAbility copy() { - return new FortifyAbility(this); - } - - @Override - public String getRule() { - return "Fortify " + costs.getText() + manaCosts.getText() + " (" + manaCosts.getText() + ": Attach to target land you control. Fortify only as a sorcery.)"; - } - -} diff --git a/Mage.Sets/src/mage/cards/n/NeurokTransmuter.java b/Mage.Sets/src/mage/cards/n/NeurokTransmuter.java new file mode 100644 index 0000000000..886d089c0b --- /dev/null +++ b/Mage.Sets/src/mage/cards/n/NeurokTransmuter.java @@ -0,0 +1,71 @@ +package mage.cards.n; + +import java.util.UUID; +import mage.MageInt; +import mage.ObjectColor; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.ColoredManaCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.continuous.AddCardTypeTargetEffect; +import mage.abilities.effects.common.continuous.BecomesColorTargetEffect; +import mage.abilities.effects.common.continuous.LoseArtifactTypeTargetEffect; +import mage.abilities.effects.common.continuous.LoseCreatureTypeSourceEffect; +import mage.constants.Duration; +import mage.constants.SubType; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Zone; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.target.TargetPermanent; +import mage.target.common.TargetArtifactPermanent; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author noahg + */ +public final class NeurokTransmuter extends CardImpl { + + final static FilterCreaturePermanent filter = new FilterCreaturePermanent("artifact creature"); + + static { + filter.add(new CardTypePredicate(CardType.ARTIFACT)); + } + + public NeurokTransmuter(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{U}"); + + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.WIZARD); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // {U}: Target creature becomes an artifact in addition to its other types until end of turn. + Ability becomeArtifactAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddCardTypeTargetEffect(Duration.EndOfTurn, CardType.ARTIFACT), new ManaCostsImpl("{U}")); + becomeArtifactAbility.addTarget(new TargetCreaturePermanent()); + this.addAbility(becomeArtifactAbility); + // {U}: Until end of turn, target artifact creature becomes blue and isn't an artifact. + Effect blueEffect = new BecomesColorTargetEffect(ObjectColor.BLUE, Duration.EndOfTurn); + blueEffect.setText("Until end of turn, target artifact creature becomes blue and "); + Ability becomeBlueAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, blueEffect, new ManaCostsImpl("{U}")); + becomeBlueAbility.addTarget(new TargetCreaturePermanent(filter)); + Effect loseArtifactEffect = new LoseArtifactTypeTargetEffect(Duration.EndOfTurn); + loseArtifactEffect.setText("isn't an artifact"); + becomeBlueAbility.addEffect(loseArtifactEffect); + this.addAbility(becomeBlueAbility); + } + + public NeurokTransmuter(final NeurokTransmuter card) { + super(card); + } + + @Override + public NeurokTransmuter copy() { + return new NeurokTransmuter(this); + } +} diff --git a/Mage.Sets/src/mage/sets/Darksteel.java b/Mage.Sets/src/mage/sets/Darksteel.java index 7624752521..7a443fd887 100644 --- a/Mage.Sets/src/mage/sets/Darksteel.java +++ b/Mage.Sets/src/mage/sets/Darksteel.java @@ -114,6 +114,7 @@ public final class Darksteel extends ExpansionSet { cards.add(new SetCardInfo("Myr Moonvessel", 133, Rarity.COMMON, mage.cards.m.MyrMoonvessel.class)); cards.add(new SetCardInfo("Nemesis Mask", 134, Rarity.UNCOMMON, mage.cards.n.NemesisMask.class)); cards.add(new SetCardInfo("Neurok Prodigy", 26, Rarity.COMMON, mage.cards.n.NeurokProdigy.class)); + cards.add(new SetCardInfo("Neurok Transmuter", 27, Rarity.UNCOMMON, mage.cards.n.NeurokTransmuter.class)); cards.add(new SetCardInfo("Nim Abomination", 49, Rarity.UNCOMMON, mage.cards.n.NimAbomination.class)); cards.add(new SetCardInfo("Nourish", 78, Rarity.COMMON, mage.cards.n.Nourish.class)); cards.add(new SetCardInfo("Oxidda Golem", 135, Rarity.COMMON, mage.cards.o.OxiddaGolem.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/LoseArtifactTypeTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/LoseArtifactTypeTargetEffect.java new file mode 100644 index 0000000000..ac44c271aa --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/LoseArtifactTypeTargetEffect.java @@ -0,0 +1,77 @@ + +package mage.abilities.effects.common.continuous; + +import mage.abilities.Ability; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.constants.*; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.util.CardUtil; + +import java.util.UUID; + +/** + * + * @author noahg + */ +public class LoseArtifactTypeTargetEffect extends ContinuousEffectImpl{ + + public LoseArtifactTypeTargetEffect(Duration duration) { + super(duration, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Neutral); + dependencyTypes.add(DependencyType.ArtifactAddingRemoving); + setText("isn't an artifact"); + } + + public LoseArtifactTypeTargetEffect(final LoseArtifactTypeTargetEffect effect) { + super(effect); + } + + @Override + public LoseArtifactTypeTargetEffect copy() { + return new LoseArtifactTypeTargetEffect(this); + } + + @Override + public void init(Ability source, Game game) { + super.init(source, game); //To change body of generated methods, choose Tools | Templates. + if (duration.isOnlyValidIfNoZoneChange()) { + // If source permanent is no longer onto battlefield discard the effect + if (source.getSourcePermanentIfItStillExists(game) == null) { + discard(); + } + } + } + + @Override + public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { + for (UUID targetId : targetPointer.getTargets(game, source)) { + if (targetId != null) { + Permanent permanent = game.getPermanent(targetId); + if (permanent != null) { + switch (layer) { + case TypeChangingEffects_4: + if (sublayer == SubLayer.NA) { + permanent.getCardType().remove(CardType.ARTIFACT); + permanent.getSubtype(game).removeAll(SubType.getArtifactTypes(false)); + } + break; + } + return true; + } + } + } + return false; + } + + @Override + public boolean apply(Game game, Ability source) { + return false; + } + + @Override + public boolean hasLayer(Layer layer) { + return layer == Layer.TypeChangingEffects_4; + } + +} diff --git a/Mage/src/main/java/mage/abilities/keyword/EquipAbility.java b/Mage/src/main/java/mage/abilities/keyword/EquipAbility.java index 2496f96192..9f75eeaa3c 100644 --- a/Mage/src/main/java/mage/abilities/keyword/EquipAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/EquipAbility.java @@ -35,14 +35,12 @@ public class EquipAbility extends ActivatedAbilityImpl { @Override public ActivationStatus canActivate(UUID playerId, Game game) { - ActivationStatus activationStatus = super.canActivate(playerId, game); - if (activationStatus.canActivate()) { - Permanent permanent = game.getPermanent(sourceId); - if (permanent != null && permanent.hasSubtype(SubType.EQUIPMENT, game)) { - return activationStatus; - } + Permanent permanent = game.getPermanent(sourceId); + if (permanent != null && permanent.hasSubtype(SubType.EQUIPMENT, game) && !permanent.isCreature()) { + return super.canActivate(playerId, game); + } else { + return ActivationStatus.getFalse(); } - return activationStatus; } public EquipAbility(final EquipAbility ability) { diff --git a/Mage/src/main/java/mage/abilities/keyword/FortifyAbility.java b/Mage/src/main/java/mage/abilities/keyword/FortifyAbility.java index 95c2e7be55..43c8ab3254 100644 --- a/Mage/src/main/java/mage/abilities/keyword/FortifyAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/FortifyAbility.java @@ -2,13 +2,22 @@ package mage.abilities.keyword; +import mage.abilities.costs.mana.GenericManaCost; +import mage.constants.Outcome; +import mage.constants.SubType; import mage.constants.TimingRule; import mage.constants.Zone; import mage.abilities.ActivatedAbilityImpl; import mage.abilities.costs.Cost; import mage.abilities.effects.common.AttachEffect; import mage.filter.common.FilterControlledLandPermanent; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.Target; import mage.target.TargetPermanent; +import mage.target.common.TargetControlledCreaturePermanent; + +import java.util.UUID; /** * @@ -17,10 +26,29 @@ import mage.target.TargetPermanent; //20091005 - 702.64 public class FortifyAbility extends ActivatedAbilityImpl { - public FortifyAbility(Zone zone, AttachEffect effect, Cost cost) { - super(zone, effect, cost); - this.addTarget(new TargetPermanent(new FilterControlledLandPermanent())); - timing = TimingRule.SORCERY; + + public FortifyAbility(int cost) { + this(Outcome.AddAbility, new GenericManaCost(cost)); + } + + public FortifyAbility(Outcome outcome, Cost cost) { + this(outcome, cost, new TargetPermanent(new FilterControlledLandPermanent())); + } + + public FortifyAbility(Outcome outcome, Cost cost, Target target) { + super(Zone.BATTLEFIELD, new AttachEffect(outcome, "Fortify"), cost); + this.addTarget(target); + this.timing = TimingRule.SORCERY; + } + + @Override + public ActivationStatus canActivate(UUID playerId, Game game) { + Permanent permanent = game.getPermanent(sourceId); + if (permanent != null && permanent.hasSubtype(SubType.FORTIFICATION, game) && !permanent.isCreature() && !permanent.isLand()) { + return super.canActivate(playerId, game); + } else { + return ActivationStatus.getFalse(); + } } public FortifyAbility(final FortifyAbility ability) { @@ -31,4 +59,10 @@ public class FortifyAbility extends ActivatedAbilityImpl { public FortifyAbility copy() { return new FortifyAbility(this); } + + + @Override + public String getRule() { + return "Fortify " + costs.getText() + manaCosts.getText() + " (" + manaCosts.getText() + ": Attach to target land you control. Fortify only as a sorcery.)"; + } } \ No newline at end of file diff --git a/Mage/src/main/java/mage/constants/SubType.java b/Mage/src/main/java/mage/constants/SubType.java index fb38796b59..cb53325148 100644 --- a/Mage/src/main/java/mage/constants/SubType.java +++ b/Mage/src/main/java/mage/constants/SubType.java @@ -462,6 +462,16 @@ public enum SubType { return subTypeSet; } + public static Set getArtifactTypes(boolean withCustomSets) { + Set subTypes = EnumSet.noneOf(SubType.class); + for (SubType subType : values()) { + if (subType.getSubTypeSet() == SubTypeSet.ArtifactType && (withCustomSets || !subType.customSet)) { + subTypes.add(subType); + } + } + return subTypes; + } + public static Set getPlaneswalkerTypes(boolean withCustomSets) { Set subTypes = EnumSet.noneOf(SubType.class); for (SubType subType : values()) {