[CLB] Implemented Druid of the Emerald Grove

This commit is contained in:
Evan Kranzler 2022-06-04 10:54:28 -04:00
parent e9a7df8665
commit 0b9062833a
2 changed files with 132 additions and 0 deletions

View file

@ -0,0 +1,131 @@
package mage.cards.d;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.common.InfoEffect;
import mage.abilities.effects.common.RollDieWithResultTableEffect;
import mage.cards.*;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetCardInLibrary;
import java.util.Objects;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class DruidOfTheEmeraldGrove extends CardImpl {
public DruidOfTheEmeraldGrove(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}");
this.subtype.add(SubType.DWARF);
this.subtype.add(SubType.DRUID);
this.power = new MageInt(2);
this.toughness = new MageInt(2);
// When Druid of the Emerald Grove enters the battlefield, search your library for up to two basic lands cards and reveal them, then roll a d20.
// 1-9 | Put those cards into your hand, then shuffle.
// 10-19 | Put one of those cards onto the battlefield tapped and the other into your hand, then shuffle.
// 20 | Put those cards onto the battlefield tapped, then shuffle.
this.addAbility(new EntersBattlefieldTriggeredAbility(new DruidOfTheEmeraldGroveEffect()));
}
private DruidOfTheEmeraldGrove(final DruidOfTheEmeraldGrove card) {
super(card);
}
@Override
public DruidOfTheEmeraldGrove copy() {
return new DruidOfTheEmeraldGrove(this);
}
}
class DruidOfTheEmeraldGroveEffect extends RollDieWithResultTableEffect {
DruidOfTheEmeraldGroveEffect() {
super(20, "search your library for up to two basic lands cards and reveal them, then roll a d20");
this.addTableEntry(
1, 9,
new InfoEffect("put those cards into your hand, then shuffle")
);
this.addTableEntry(
10, 19,
new InfoEffect("put one of those cards onto the battlefield tapped and the other into your hand, then shuffle")
);
this.addTableEntry(
20, 20,
new InfoEffect("put those cards onto the battlefield tapped, then shuffle")
);
}
private DruidOfTheEmeraldGroveEffect(final DruidOfTheEmeraldGroveEffect effect) {
super(effect);
}
@Override
public DruidOfTheEmeraldGroveEffect copy() {
return new DruidOfTheEmeraldGroveEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
TargetCardInLibrary targetCardInLibrary = new TargetCardInLibrary(
0, 2, StaticFilters.FILTER_CARD_BASIC_LANDS
);
player.searchLibrary(targetCardInLibrary, source, game);
Cards cards = new CardsImpl();
targetCardInLibrary
.getTargets()
.stream()
.map(uuid -> player.getLibrary().getCard(uuid, game))
.filter(Objects::nonNull)
.forEach(cards::add);
player.revealCards(source, cards, game);
int amount = player.rollDice(outcome, source, game, 20);
if (amount < 1) {
} else if (amount <= 9) {
player.moveCards(cards, Zone.HAND, source, game);
} else if (amount <= 19) {
Card card;
switch (cards.size()) {
case 0:
card = null;
break;
case 1:
card = cards.getRandom(game);
break;
default:
TargetCard target = new TargetCardInLibrary();
player.choose(outcome, target, source, game);
card = cards.get(target.getFirstTarget(), game);
}
if (card != null) {
player.moveCards(
card, Zone.BATTLEFIELD, source, game, true,
false, false, null
);
cards.remove(card);
}
player.moveCards(cards, Zone.HAND, source, game);
} else if (amount != 20) {
player.moveCards(
cards.getCards(game), Zone.BATTLEFIELD, source, game,
true, false, false, null
);
}
player.shuffleLibrary(source, game);
return true;
}
}

View file

@ -186,6 +186,7 @@ public final class CommanderLegendsBattleForBaldursGate extends ExpansionSet {
cards.add(new SetCardInfo("Dross Harvester", 750, Rarity.RARE, mage.cards.d.DrossHarvester.class));
cards.add(new SetCardInfo("Drown in the Loch", 842, Rarity.UNCOMMON, mage.cards.d.DrownInTheLoch.class));
cards.add(new SetCardInfo("Drownyard Temple", 892, Rarity.RARE, mage.cards.d.DrownyardTemple.class));
cards.add(new SetCardInfo("Druid of the Emerald Grove", 226, Rarity.COMMON, mage.cards.d.DruidOfTheEmeraldGrove.class));
cards.add(new SetCardInfo("Druidic Ritual", 227, Rarity.COMMON, mage.cards.d.DruidicRitual.class));
cards.add(new SetCardInfo("Duke Ulder Ravengard", 272, Rarity.RARE, mage.cards.d.DukeUlderRavengard.class));
cards.add(new SetCardInfo("Dungeon Delver", 67, Rarity.UNCOMMON, mage.cards.d.DungeonDelver.class));