1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-06 01:04:10 -09:00

[AFR] Implemented Oswald Fiddlebender

This commit is contained in:
Evan Kranzler 2021-07-10 15:11:13 -04:00
parent b193ffc627
commit 2bd98dd4c8
2 changed files with 106 additions and 0 deletions

View file

@ -0,0 +1,105 @@
package mage.cards.o;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.ActivateAsSorceryActivatedAbility;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.filter.FilterCard;
import mage.filter.StaticFilters;
import mage.filter.common.FilterArtifactCard;
import mage.filter.predicate.mageobject.ManaValuePredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCardInLibrary;
import mage.target.common.TargetControlledPermanent;
import java.util.Collection;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class OswaldFiddlebender extends CardImpl {
public OswaldFiddlebender(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}");
this.addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.GNOME);
this.subtype.add(SubType.ARTIFICER);
this.power = new MageInt(2);
this.toughness = new MageInt(2);
// {W}, {T}, Sacrifice an artifact: Search your library for an artifact card with mana value equal to 1 plus the sacrificed artifact's mana value. Put that card onto the battlefield, then shuffle. Activate only as a sorcery.
Ability ability = new ActivateAsSorceryActivatedAbility(
new OswaldFiddlebenderEffect(), new ManaCostsImpl<>("{W}")
);
ability.addCost(new TapSourceCost());
ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent(
StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT_AN
)));
this.addAbility(ability);
}
private OswaldFiddlebender(final OswaldFiddlebender card) {
super(card);
}
@Override
public OswaldFiddlebender copy() {
return new OswaldFiddlebender(this);
}
}
class OswaldFiddlebenderEffect extends OneShotEffect {
OswaldFiddlebenderEffect() {
super(Outcome.Benefit);
staticText = "search your library for an artifact card with mana value equal to 1 plus the " +
"sacrificed artifact's mana value. Put that card onto the battlefield, then shuffle";
}
private OswaldFiddlebenderEffect(final OswaldFiddlebenderEffect effect) {
super(effect);
}
@Override
public OswaldFiddlebenderEffect copy() {
return new OswaldFiddlebenderEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent sacrificed = source
.getCosts()
.stream()
.filter(SacrificeTargetCost.class::isInstance)
.map(SacrificeTargetCost.class::cast)
.map(SacrificeTargetCost::getPermanents)
.flatMap(Collection::stream)
.findFirst()
.orElse(null);
if (player == null || sacrificed == null) {
return false;
}
FilterCard filterCard = new FilterArtifactCard(
"artifact card with mana value " + (sacrificed.getManaValue() + 1)
);
filterCard.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, sacrificed.getManaValue() + 1));
TargetCardInLibrary target = new TargetCardInLibrary(filterCard);
player.searchLibrary(target, source, game);
Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
player.moveCards(card, Zone.BATTLEFIELD, source, game);
player.shuffleLibrary(source, game);
return true;
}
}

View file

@ -160,6 +160,7 @@ public final class AdventuresInTheForgottenRealms extends ExpansionSet {
cards.add(new SetCardInfo("Nadaar, Selfless Paladin", 27, Rarity.RARE, mage.cards.n.NadaarSelflessPaladin.class));
cards.add(new SetCardInfo("Neverwinter Dryad", 195, Rarity.COMMON, mage.cards.n.NeverwinterDryad.class));
cards.add(new SetCardInfo("Old Gnawbone", 197, Rarity.MYTHIC, mage.cards.o.OldGnawbone.class));
cards.add(new SetCardInfo("Oswald Fiddlebender", 28, Rarity.RARE, mage.cards.o.OswaldFiddlebender.class));
cards.add(new SetCardInfo("Owlbear", 198, Rarity.COMMON, mage.cards.o.Owlbear.class));
cards.add(new SetCardInfo("Paladin's Shield", 30, Rarity.COMMON, mage.cards.p.PaladinsShield.class));
cards.add(new SetCardInfo("Plains", 262, Rarity.LAND, mage.cards.basiclands.Plains.class, NON_FULL_USE_VARIOUS));