- Fixed #8186 - Did not test it yet, but it should work fine. In the middle of a large refactor.

This commit is contained in:
jeffwadsworth 2021-08-31 17:04:07 -05:00
parent 0ee1d428e1
commit 842e9bb30e

View file

@ -1,5 +1,6 @@
package mage.cards.n;
import java.util.Set;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
@ -8,14 +9,11 @@ import mage.abilities.effects.common.continuous.GainAbilityAllEffect;
import mage.abilities.keyword.LifelinkAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.filter.FilterPermanent;
import mage.filter.StaticFilters;
import mage.filter.common.FilterControlledPermanent;
import mage.game.Game;
import mage.game.permanent.token.ZombieToken;
@ -23,6 +21,10 @@ import mage.players.Player;
import mage.target.TargetPlayer;
import java.util.UUID;
import mage.cards.Card;
import mage.filter.common.FilterCreatureCard;
import mage.game.ExileZone;
import mage.util.CardUtil;
/**
* @author jeffwadsworth
@ -60,8 +62,8 @@ class NecromancersConvenantEffect extends OneShotEffect {
NecromancersConvenantEffect() {
super(Outcome.PutCreatureInPlay);
staticText = "exile all creature cards from target player's graveyard, " +
"then create a 2/2 black Zombie creature token for each card exiled this way";
staticText = "exile all creature cards from target player's graveyard, "
+ "then create a 2/2 black Zombie creature token for each card exiled this way";
}
private NecromancersConvenantEffect(NecromancersConvenantEffect effect) {
@ -72,12 +74,20 @@ class NecromancersConvenantEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player player = game.getPlayer(source.getFirstTarget());
if (controller == null || player == null) {
if (controller == null
|| player == null) {
return false;
}
Cards cards = new CardsImpl(player.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game));
int count = cards.size();
return count > 0 && new ZombieToken().putOntoBattlefield(count, game, source, controller.getId());
Set<Card> cards = player.getGraveyard().getCards(new FilterCreatureCard(), game);
UUID exileId = CardUtil.getCardExileZoneId(game, source);
controller.moveCardsToExile(cards, source, game, true, exileId, "Necromancer's Convenant"); // a previous refactor removed the exile code. Just putting it back.
ExileZone exileZone = game.getState().getExile().getExileZone(exileId);
if (exileZone != null) {
int count = exileZone.getCards(game).size();
return count > 0
&& new ZombieToken().putOntoBattlefield(count, game, source, controller.getId());
}
return false;
}
@Override