[MIC] Implemented Empty the Laboratory

This commit is contained in:
Evan Kranzler 2021-09-21 09:14:46 -04:00
parent d35e1fbfb1
commit b81b02b6c3
2 changed files with 111 additions and 0 deletions

View file

@ -0,0 +1,110 @@
package mage.cards.e;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.*;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.common.FilterCreatureCard;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPermanent;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class EmptyTheLaboratory extends CardImpl {
public EmptyTheLaboratory(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{U}{U}");
// Sacrifice X Zombies, then reveal cards from the top of your library until you reveal a number of Zombie creature cards equal to the number of Zombies sacrificed this way. Put those cards onto the battlefield and the rest on the bottom of your library in a random order.
this.getSpellAbility().addEffect(new EmptyTheLaboratoryEffect());
}
private EmptyTheLaboratory(final EmptyTheLaboratory card) {
super(card);
}
@Override
public EmptyTheLaboratory copy() {
return new EmptyTheLaboratory(this);
}
}
class EmptyTheLaboratoryEffect extends OneShotEffect {
private static final FilterPermanent filter = new FilterControlledPermanent(SubType.ZOMBIE, "Zombies");
private static final FilterCard filter2 = new FilterCreatureCard();
static {
filter2.add(SubType.ZOMBIE.getPredicate());
}
EmptyTheLaboratoryEffect() {
super(Outcome.Benefit);
staticText = "sacrifice X Zombies, then reveal cards from the top of your library until you reveal " +
"a number of Zombie creature cards equal to the number of Zombies sacrificed this way. " +
"Put those cards onto the battlefield and the rest on the bottom of your library in a random order";
}
private EmptyTheLaboratoryEffect(final EmptyTheLaboratoryEffect effect) {
super(effect);
}
@Override
public EmptyTheLaboratoryEffect copy() {
return new EmptyTheLaboratoryEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
int toSacrifice = Math.min(
source.getManaCostsToPay().getX(),
game.getBattlefield().count(
filter, source.getSourceId(), source.getControllerId(), game
)
);
if (toSacrifice < 1) {
return false;
}
TargetPermanent target = new TargetPermanent(toSacrifice, filter);
target.setNotTarget(true);
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
int sacrificed = 0;
for (UUID permanentId : target.getTargets()) {
Permanent permanent = game.getPermanent(permanentId);
if (permanent != null && permanent.sacrifice(source, game)) {
sacrificed++;
}
}
Cards toReveal = new CardsImpl();
int zombies = 0;
for (Card card : player.getLibrary().getCards(game)) {
toReveal.add(card);
if (card.isCreature(game) && card.hasSubtype(SubType.ZOMBIE, game)) {
zombies++;
}
if (zombies >= sacrificed) {
break;
}
}
player.revealCards(source, toReveal, game);
player.moveCards(toReveal.getCards(filter2, game), Zone.BATTLEFIELD, source, game);
toReveal.retainZone(Zone.LIBRARY, game);
player.putCardsOnBottomOfLibrary(toReveal, game, source, false);
return true;
}
}

View file

@ -69,6 +69,7 @@ public final class MidnightHuntCommander extends ExpansionSet {
cards.add(new SetCardInfo("Eater of Hope", 115, Rarity.RARE, mage.cards.e.EaterOfHope.class));
cards.add(new SetCardInfo("Elite Scaleguard", 85, Rarity.UNCOMMON, mage.cards.e.EliteScaleguard.class));
cards.add(new SetCardInfo("Eloise, Nephalia Sleuth", 3, Rarity.MYTHIC, mage.cards.e.EloiseNephaliaSleuth.class));
cards.add(new SetCardInfo("Empty the Laboratory", 14, Rarity.RARE, mage.cards.e.EmptyTheLaboratory.class));
cards.add(new SetCardInfo("Endless Ranks of the Dead", 116, Rarity.RARE, mage.cards.e.EndlessRanksOfTheDead.class));
cards.add(new SetCardInfo("Enduring Scalelord", 149, Rarity.UNCOMMON, mage.cards.e.EnduringScalelord.class));
cards.add(new SetCardInfo("Eternal Skylord", 99, Rarity.UNCOMMON, mage.cards.e.EternalSkylord.class));