Implemented Desperate Research

This commit is contained in:
Evan Kranzler 2018-06-06 13:59:35 -04:00
parent 78c288358b
commit d2e8016a10
4 changed files with 109 additions and 2 deletions

View file

@ -0,0 +1,76 @@
package mage.cards.d;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.NameACardEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.NamePredicate;
import mage.game.Game;
import mage.players.Player;
/**
*
* @author TheElk801
*/
public final class DesperateResearch extends CardImpl {
public DesperateResearch(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{B}");
// Choose a card name other than a basic land card name. Reveal the top seven cards of your library and put all of them with that name into your hand. Exile the rest.
this.getSpellAbility().addEffect(new NameACardEffect(NameACardEffect.TypeOfName.NOT_BASIC_LAND_NAME));
this.getSpellAbility().addEffect(new DesperateResearchEffect());
}
public DesperateResearch(final DesperateResearch card) {
super(card);
}
@Override
public DesperateResearch copy() {
return new DesperateResearch(this);
}
}
class DesperateResearchEffect extends OneShotEffect {
public DesperateResearchEffect() {
super(Outcome.Benefit);
this.staticText = "Reveal the top seven cards of your library and put all of them with that name into your hand. Exile the rest";
}
public DesperateResearchEffect(final DesperateResearchEffect effect) {
super(effect);
}
@Override
public DesperateResearchEffect copy() {
return new DesperateResearchEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
String cardName = (String) game.getState().getValue(source.getSourceId().toString() + NameACardEffect.INFO_KEY);
Player player = game.getPlayer(source.getControllerId());
if (player == null || cardName == null) {
return false;
}
Cards cardsToExile = new CardsImpl(player.getLibrary().getTopCards(game, 7));
player.revealCards(source, cardsToExile, game);
FilterCard filter = new FilterCard();
filter.add(new NamePredicate(cardName));
Cards cardsToKeep = new CardsImpl(cardsToExile.getCards(filter, game));
cardsToExile.removeAll(cardsToKeep);
player.moveCards(cardsToKeep, Zone.HAND, source, game);
player.moveCards(cardsToExile, Zone.EXILED, source, game);
return true;
}
}

View file

@ -88,6 +88,7 @@ public final class Invasion extends ExpansionSet {
cards.add(new SetCardInfo("Darigaaz's Attendant", 301, Rarity.UNCOMMON, mage.cards.d.DarigaazsAttendant.class));
cards.add(new SetCardInfo("Darigaaz, the Igniter", 243, Rarity.RARE, mage.cards.d.DarigaazTheIgniter.class));
cards.add(new SetCardInfo("Defiling Tears", 99, Rarity.UNCOMMON, mage.cards.d.DefilingTears.class));
cards.add(new SetCardInfo("Desperate Research", 100, Rarity.RARE, mage.cards.d.DesperateResearch.class));
cards.add(new SetCardInfo("Devouring Strossus", 101, Rarity.RARE, mage.cards.d.DevouringStrossus.class));
cards.add(new SetCardInfo("Dismantling Blow", 14, Rarity.COMMON, mage.cards.d.DismantlingBlow.class));
cards.add(new SetCardInfo("Disrupt", 51, Rarity.UNCOMMON, mage.cards.d.Disrupt.class));