[AFR] Implemented Instrument of the Bards

This commit is contained in:
Daniel Bomar 2021-07-07 11:09:10 -05:00
parent d519f1d775
commit 3bf876b520
No known key found for this signature in database
GPG key ID: C86C8658F4023918
3 changed files with 105 additions and 0 deletions

View file

@ -0,0 +1,103 @@
package mage.cards.i;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.Card;
import mage.cards.CardsImpl;
import mage.constants.*;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.counters.CounterType;
import mage.filter.common.FilterCreatureCard;
import mage.filter.predicate.mageobject.ManaValuePredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.TreasureToken;
import mage.players.Player;
import mage.target.common.TargetCardInLibrary;
/**
*
* @author weirddan455
*/
public final class InstrumentOfTheBards extends CardImpl {
public InstrumentOfTheBards(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{G}");
this.addSuperType(SuperType.LEGENDARY);
// At the beginning of your upkeep, you may put a harmony counter on Instrument of Bards.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(
new AddCountersSourceEffect(CounterType.HARMONY.createInstance()),
TargetController.YOU, true
));
// {3}{G}, {T}: Search your library for a creature card with mana value equal to the number of harmony
// counters on Instrument of Bards, reveal it, and put it into your hand.
// If that card is legendary, create a Treasure token. Then shuffle.
Ability ability = new SimpleActivatedAbility(new InstrumentOfTheBardsEffect(), new ManaCostsImpl("{3}{G}"));
ability.addCost(new TapSourceCost());
this.addAbility(ability);
}
private InstrumentOfTheBards(final InstrumentOfTheBards card) {
super(card);
}
@Override
public InstrumentOfTheBards copy() {
return new InstrumentOfTheBards(this);
}
}
class InstrumentOfTheBardsEffect extends OneShotEffect {
public InstrumentOfTheBardsEffect() {
super(Outcome.DrawCard);
this.staticText = "Search your library for a creature card with mana value equal to the number of harmony " +
"counters on {this}, reveal it, and put it into your hand. " +
"If that card is legendary, create a Treasure token. Then shuffle";
}
private InstrumentOfTheBardsEffect(final InstrumentOfTheBardsEffect effect) {
super(effect);
}
@Override
public InstrumentOfTheBardsEffect copy() {
return new InstrumentOfTheBardsEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (controller == null || permanent == null) {
return false;
}
int counters = permanent.getCounters(game).getCount(CounterType.HARMONY);
FilterCreatureCard filter = new FilterCreatureCard("creature card with mana value " + counters);
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, counters));
TargetCardInLibrary target = new TargetCardInLibrary(filter);
if (controller.searchLibrary(target, source, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
controller.revealCards(permanent.getIdName(), new CardsImpl(card), game);
controller.moveCards(card, Zone.HAND, source, game);
if (card.isLegendary()) {
new TreasureToken().putOntoBattlefield(1, game, source, source.getControllerId());
}
}
}
controller.shuffleLibrary(source, game);
return true;
}
}

View file

@ -126,6 +126,7 @@ public final class AdventuresInTheForgottenRealms extends ExpansionSet {
cards.add(new SetCardInfo("Inferno of the Star Mounts", 151, Rarity.MYTHIC, mage.cards.i.InfernoOfTheStarMounts.class));
cards.add(new SetCardInfo("Ingenious Smith", 21, Rarity.UNCOMMON, mage.cards.i.IngeniousSmith.class));
cards.add(new SetCardInfo("Inspiring Bard", 189, Rarity.COMMON, mage.cards.i.InspiringBard.class));
cards.add(new SetCardInfo("Instrument of the Bards", 190, Rarity.RARE, mage.cards.i.InstrumentOfTheBards.class));
cards.add(new SetCardInfo("Intrepid Outlander", 191, Rarity.UNCOMMON, mage.cards.i.IntrepidOutlander.class));
cards.add(new SetCardInfo("Iron Golem", 247, Rarity.UNCOMMON, mage.cards.i.IronGolem.class));
cards.add(new SetCardInfo("Island", 266, Rarity.LAND, mage.cards.basiclands.Island.class, NON_FULL_USE_VARIOUS));

View file

@ -72,6 +72,7 @@ public enum CounterType {
GLYPH("glyph"),
GOLD("gold"),
GROWTH("growth"),
HARMONY("harmony"),
HATCHLING("hatchling"),
HEALING("healing"),
HEXPROOF("hexproof"),