mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
implemented Mind Extraction
This commit is contained in:
parent
7ac58f9787
commit
3c67694c7f
2 changed files with 108 additions and 0 deletions
107
Mage.Sets/src/mage/cards/m/MindExtraction.java
Normal file
107
Mage.Sets/src/mage/cards/m/MindExtraction.java
Normal file
|
@ -0,0 +1,107 @@
|
|||
package mage.cards.m;
|
||||
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.common.SacrificeTargetCost;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
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.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPlayer;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class MindExtraction extends CardImpl {
|
||||
|
||||
public MindExtraction(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{B}");
|
||||
|
||||
// As an additional cost to cast this spell, sacrifice a creature.
|
||||
this.getSpellAbility().addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent(
|
||||
1, 1, StaticFilters.FILTER_CONTROLLED_CREATURE_SHORT_TEXT, false
|
||||
)));
|
||||
|
||||
// Target player reveals their hand and discards all cards of each of the sacrificed creature’s colors.
|
||||
this.getSpellAbility().addEffect(new MindExtractionEffect());
|
||||
this.getSpellAbility().addTarget(new TargetPlayer());
|
||||
}
|
||||
|
||||
private MindExtraction(final MindExtraction card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MindExtraction copy() {
|
||||
return new MindExtraction(this);
|
||||
}
|
||||
}
|
||||
|
||||
class MindExtractionEffect extends OneShotEffect {
|
||||
|
||||
MindExtractionEffect() {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "Target player reveals their hand and discards all cards of each of the sacrificed creature’s colors.";
|
||||
}
|
||||
|
||||
private MindExtractionEffect(final MindExtractionEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MindExtractionEffect copy() {
|
||||
return new MindExtractionEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Player player = game.getPlayer(source.getFirstTarget());
|
||||
if (controller == null || player == null) {
|
||||
return false;
|
||||
}
|
||||
Permanent sacrificedCreature = null;
|
||||
for (Cost cost : source.getCosts()) {
|
||||
if (!(cost instanceof SacrificeTargetCost)) {
|
||||
continue;
|
||||
}
|
||||
SacrificeTargetCost sacCost = (SacrificeTargetCost) cost;
|
||||
for (Permanent permanent : sacCost.getPermanents()) {
|
||||
sacrificedCreature = permanent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (sacrificedCreature == null) {
|
||||
return false;
|
||||
}
|
||||
ObjectColor color = sacrificedCreature.getColor(game);
|
||||
Cards cards = new CardsImpl(player.getHand());
|
||||
if (cards.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
player.revealCards(source, cards, game);
|
||||
if (color.isColorless()) {
|
||||
return true;
|
||||
}
|
||||
Cards toDiscard = new CardsImpl();
|
||||
cards.getCards(game)
|
||||
.stream()
|
||||
.filter(card -> card.getColor(game).shares(color))
|
||||
.forEach(toDiscard::add);
|
||||
toDiscard.getCards(game)
|
||||
.stream()
|
||||
.forEach(card -> player.discard(card, source, game));
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -99,6 +99,7 @@ public final class Apocalypse extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Manacles of Decay", 14, Rarity.COMMON, mage.cards.m.ManaclesOfDecay.class));
|
||||
cards.add(new SetCardInfo("Martyrs' Tomb", 110, Rarity.UNCOMMON, mage.cards.m.MartyrsTomb.class));
|
||||
cards.add(new SetCardInfo("Mask of Intolerance", 138, Rarity.RARE, mage.cards.m.MaskOfIntolerance.class));
|
||||
cards.add(new SetCardInfo("Mind Extraction", 42, Rarity.COMMON, mage.cards.m.MindExtraction.class));
|
||||
cards.add(new SetCardInfo("Minotaur Illusionist", 111, Rarity.UNCOMMON, mage.cards.m.MinotaurIllusionist.class));
|
||||
cards.add(new SetCardInfo("Minotaur Tactician", 65, Rarity.COMMON, mage.cards.m.MinotaurTactician.class));
|
||||
cards.add(new SetCardInfo("Mournful Zombie", 43, Rarity.COMMON, mage.cards.m.MournfulZombie.class));
|
||||
|
|
Loading…
Reference in a new issue