From 18ca3bcff9f9224f602eb2b9dec8e6f0423e761c Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sat, 4 Jan 2020 20:21:29 -0500 Subject: [PATCH] Implemented One with the Stars --- .../src/mage/cards/o/OneWithTheStars.java | 95 +++++++++++++++++++ .../src/mage/sets/TherosBeyondDeath.java | 1 + 2 files changed, 96 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/o/OneWithTheStars.java diff --git a/Mage.Sets/src/mage/cards/o/OneWithTheStars.java b/Mage.Sets/src/mage/cards/o/OneWithTheStars.java new file mode 100644 index 00000000000..262efaa5ef9 --- /dev/null +++ b/Mage.Sets/src/mage/cards/o/OneWithTheStars.java @@ -0,0 +1,95 @@ +package mage.cards.o; + +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.keyword.EnchantAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.FilterPermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.TargetPermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class OneWithTheStars extends CardImpl { + + private static final FilterPermanent filter = new FilterPermanent("creature or enchantment"); + + static { + filter.add(Predicates.or( + new CardTypePredicate(CardType.CREATURE), + new CardTypePredicate(CardType.ENCHANTMENT) + )); + } + + public OneWithTheStars(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{U}"); + + this.subtype.add(SubType.AURA); + + // Enchant creature or enchantment + TargetPermanent auraTarget = new TargetPermanent(filter); + this.getSpellAbility().addTarget(auraTarget); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature)); + Ability ability = new EnchantAbility(auraTarget.getTargetName()); + this.addAbility(ability); + + // Enchanted permanent is an enchantment and loses all other card types. + this.addAbility(new SimpleStaticAbility(new OneWithTheStarsEffect())); + } + + private OneWithTheStars(final OneWithTheStars card) { + super(card); + } + + @Override + public OneWithTheStars copy() { + return new OneWithTheStars(this); + } +} + +class OneWithTheStarsEffect extends ContinuousEffectImpl { + + OneWithTheStarsEffect() { + super(Duration.WhileOnBattlefield, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Detriment); + this.staticText = "Enchanted permanent is an enchantment and loses all other card types."; + } + + private OneWithTheStarsEffect(final OneWithTheStarsEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + return false; + } + + @Override + public OneWithTheStarsEffect copy() { + return new OneWithTheStarsEffect(this); + } + + @Override + public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { + Permanent enchantment = game.getPermanent(source.getSourceId()); + if (enchantment == null || enchantment.getAttachedTo() == null) { + return false; + } + Permanent permanent = game.getPermanent(enchantment.getAttachedTo()); + if (permanent == null) { + return false; + } + permanent.getCardType().clear(); + permanent.addCardType(CardType.ENCHANTMENT); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/TherosBeyondDeath.java b/Mage.Sets/src/mage/sets/TherosBeyondDeath.java index 86b0d3d6601..24f76fee29c 100644 --- a/Mage.Sets/src/mage/sets/TherosBeyondDeath.java +++ b/Mage.Sets/src/mage/sets/TherosBeyondDeath.java @@ -88,6 +88,7 @@ public final class TherosBeyondDeath extends ExpansionSet { cards.add(new SetCardInfo("Omen of the Forge", 145, Rarity.COMMON, mage.cards.o.OmenOfTheForge.class)); cards.add(new SetCardInfo("Omen of the Sea", 58, Rarity.COMMON, mage.cards.o.OmenOfTheSea.class)); cards.add(new SetCardInfo("Omen of the Sun", 30, Rarity.COMMON, mage.cards.o.OmenOfTheSun.class)); + cards.add(new SetCardInfo("One with the Stars", 59, Rarity.UNCOMMON, mage.cards.o.OneWithTheStars.class)); cards.add(new SetCardInfo("Ox of Agonas", 147, Rarity.MYTHIC, mage.cards.o.OxOfAgonas.class)); cards.add(new SetCardInfo("Pharika's Spawn", 112, Rarity.UNCOMMON, mage.cards.p.PharikasSpawn.class)); cards.add(new SetCardInfo("Pious Wayfarer", 32, Rarity.COMMON, mage.cards.p.PiousWayfarer.class));