diff --git a/Mage.Sets/src/mage/cards/r/RunedCrown.java b/Mage.Sets/src/mage/cards/r/RunedCrown.java new file mode 100644 index 00000000000..635889f9d78 --- /dev/null +++ b/Mage.Sets/src/mage/cards/r/RunedCrown.java @@ -0,0 +1,130 @@ +package mage.cards.r; + +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.continuous.BoostEquippedEffect; +import mage.abilities.keyword.EquipAbility; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.constants.Zone; +import mage.filter.FilterCard; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.common.TargetCardInHand; +import mage.target.common.TargetCardInLibrary; +import mage.target.common.TargetCardInYourGraveyard; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class RunedCrown extends CardImpl { + + public RunedCrown(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}"); + + this.subtype.add(SubType.EQUIPMENT); + + // When Runed Crown enters the battlefield, you may search your library, hand, and/or graveyard for a Rune card and put it onto the battlefield attached to Runed Crown. If you search your library this way, shuffle it. + this.addAbility(new EntersBattlefieldTriggeredAbility(new RunedCrownEffect())); + + // Equipped creature gets +1/+1. + this.addAbility(new SimpleStaticAbility(new BoostEquippedEffect(1, 1))); + + // Equip {2} + this.addAbility(new EquipAbility(2)); + } + + private RunedCrown(final RunedCrown card) { + super(card); + } + + @Override + public RunedCrown copy() { + return new RunedCrown(this); + } +} + +class RunedCrownEffect extends OneShotEffect { + + private static final FilterCard filter = new FilterCard("a Rune card"); + + static { + filter.add(SubType.RUNE.getPredicate()); + } + + RunedCrownEffect() { + super(Outcome.Benefit); + staticText = "you may search your library, hand, and/or graveyard for a Rune card " + + "and put it onto the battlefield attached to {this}. If you search your library this way, shuffle it"; + } + + private RunedCrownEffect(final RunedCrownEffect effect) { + super(effect); + } + + @Override + public RunedCrownEffect copy() { + return new RunedCrownEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { + return false; + } + Card card = null; + Zone zone = null; + if (controller.chooseUse(Outcome.Neutral, "Search your graveyard for a Rune card?", source, game)) { + TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(filter); + target.setNotTarget(true); + if (controller.choose(Outcome.PutCardInPlay, controller.getGraveyard(), target, game)) { + card = game.getCard(target.getFirstTarget()); + if (card != null) { + zone = Zone.GRAVEYARD; + } + } + } + if (card == null && controller.chooseUse(Outcome.Neutral, "Search your hand for a Rune card?", source, game)) { + TargetCardInHand target = new TargetCardInHand(filter); + if (controller.choose(Outcome.PutCardInPlay, controller.getHand(), target, game)) { + card = game.getCard(target.getFirstTarget()); + if (card != null) { + zone = Zone.HAND; + } + } + } + if (card == null) { + TargetCardInLibrary target = new TargetCardInLibrary(filter); + if (controller.searchLibrary(target, source, game)) { + card = game.getCard(target.getFirstTarget()); + if (card != null) { + zone = Zone.LIBRARY; + } + } + controller.shuffleLibrary(source, game); + } + // aura card found - attach it + if (card == null) { + return true; + } + Permanent permanent = source.getSourcePermanentIfItStillExists(game); + if (permanent != null) { + game.getState().setValue("attachTo:" + card.getId(), permanent); + } + controller.moveCards(card, Zone.BATTLEFIELD, source, game); + if (permanent != null) { + return permanent.addAttachment(card.getId(), source, game); + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/Kaldheim.java b/Mage.Sets/src/mage/sets/Kaldheim.java index cb071e6b1ac..ba08e5fc126 100644 --- a/Mage.Sets/src/mage/sets/Kaldheim.java +++ b/Mage.Sets/src/mage/sets/Kaldheim.java @@ -237,6 +237,7 @@ public final class Kaldheim extends ExpansionSet { cards.add(new SetCardInfo("Rune of Mortality", 108, Rarity.UNCOMMON, mage.cards.r.RuneOfMortality.class)); cards.add(new SetCardInfo("Rune of Speed", 148, Rarity.UNCOMMON, mage.cards.r.RuneOfSpeed.class)); cards.add(new SetCardInfo("Rune of Sustenance", 25, Rarity.UNCOMMON, mage.cards.r.RuneOfSustenance.class)); + cards.add(new SetCardInfo("Runed Crown", 245, Rarity.UNCOMMON, mage.cards.r.RunedCrown.class)); cards.add(new SetCardInfo("Runeforge Champion", 26, Rarity.RARE, mage.cards.r.RuneforgeChampion.class)); cards.add(new SetCardInfo("Sarulf's Packmate", 192, Rarity.COMMON, mage.cards.s.SarulfsPackmate.class)); cards.add(new SetCardInfo("Sarulf, Realm Eater", 228, Rarity.RARE, mage.cards.s.SarulfRealmEater.class));