[ZNR] fixed issues with Tajuru Paragon (#7046)

This commit is contained in:
Evan Kranzler 2020-09-11 19:55:20 -04:00
parent 5420feb471
commit cd6ee4a006

View file

@ -14,8 +14,7 @@ import mage.abilities.keyword.KickerAbility;
import mage.cards.*; import mage.cards.*;
import mage.constants.*; import mage.constants.*;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.filter.predicate.ObjectSourcePlayer; import mage.filter.predicate.Predicate;
import mage.filter.predicate.ObjectSourcePlayerPredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
@ -51,7 +50,8 @@ public final class TajuruParagon extends CardImpl {
// When Tajuru Paragon enters the battlefield, if it was kicked, reveal the top six cards of your library. You may put a card that shares a creature type with it from among them into your hand. Put the rest on the bottom of your library in a random order. // When Tajuru Paragon enters the battlefield, if it was kicked, reveal the top six cards of your library. You may put a card that shares a creature type with it from among them into your hand. Put the rest on the bottom of your library in a random order.
this.addAbility(new ConditionalInterveningIfTriggeredAbility( this.addAbility(new ConditionalInterveningIfTriggeredAbility(
new EntersBattlefieldTriggeredAbility(new TajuruParagonEffect()), KickedCondition.instance, new EntersBattlefieldTriggeredAbility(new TajuruParagonEffect()), KickedCondition.instance,
"reveal the top six cards of your library. You may put a card that shares a creature type with it " + "When {this} enters the battlefield, if it was kicked, reveal the top six cards of your library. " +
"You may put a card that shares a creature type with it " +
"from among them into your hand. Put the rest on the bottom of your library in a random order" "from among them into your hand. Put the rest on the bottom of your library in a random order"
)); ));
} }
@ -68,12 +68,6 @@ public final class TajuruParagon extends CardImpl {
class TajuruParagonEffect extends OneShotEffect { class TajuruParagonEffect extends OneShotEffect {
private static final FilterCard filter = new FilterCard("card that shares a creature type");
static {
filter.add(TajuruParagonPredicate.instance);
}
TajuruParagonEffect() { TajuruParagonEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
} }
@ -95,6 +89,10 @@ class TajuruParagonEffect extends OneShotEffect {
} }
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 6)); Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 6));
player.revealCards(source, cards, game); player.revealCards(source, cards, game);
Permanent permanent = source.getSourcePermanentOrLKI(game);
if (permanent != null) {
FilterCard filter = new FilterCard("card that shares a creature type with " + permanent.getName());
filter.add(new TajuruParagonPredicate(permanent));
TargetCard target = new TargetCardInLibrary(0, 1, filter); TargetCard target = new TargetCardInLibrary(0, 1, filter);
player.choose(outcome, cards, target, game); player.choose(outcome, cards, target, game);
Card card = game.getCard(target.getFirstTarget()); Card card = game.getCard(target.getFirstTarget());
@ -102,30 +100,31 @@ class TajuruParagonEffect extends OneShotEffect {
player.moveCards(card, Zone.HAND, source, game); player.moveCards(card, Zone.HAND, source, game);
cards.remove(card); cards.remove(card);
} }
}
player.putCardsOnBottomOfLibrary(cards, game, source, false); player.putCardsOnBottomOfLibrary(cards, game, source, false);
return true; return true;
} }
} }
enum TajuruParagonPredicate implements ObjectSourcePlayerPredicate<ObjectSourcePlayer<Card>> { class TajuruParagonPredicate implements Predicate<Card> {
instance;
private final Permanent permanent;
TajuruParagonPredicate(Permanent permanent) {
this.permanent = permanent;
}
@Override @Override
public boolean apply(ObjectSourcePlayer<Card> input, Game game) { public boolean apply(Card input, Game game) {
Permanent permanent = game.getPermanentOrLKIBattlefield(input.getSourceId());
if (permanent == null) {
return false;
}
boolean isAllA = permanent.isAllCreatureTypes() boolean isAllA = permanent.isAllCreatureTypes()
|| permanent.hasAbility(ChangelingAbility.getInstance(), game); || permanent.hasAbility(ChangelingAbility.getInstance(), game);
boolean isAnyA = isAllA || permanent.getSubtype(game) boolean isAnyA = isAllA || permanent.getSubtype(game)
.stream() .stream()
.map(SubType::getSubTypeSet) .map(SubType::getSubTypeSet)
.anyMatch(SubTypeSet.CreatureType::equals); .anyMatch(SubTypeSet.CreatureType::equals);
boolean isAllB = input.getObject().isAllCreatureTypes() boolean isAllB = input.isAllCreatureTypes()
|| input.getObject().hasAbility(ChangelingAbility.getInstance(), game); || input.hasAbility(ChangelingAbility.getInstance(), game);
boolean isAnyB = isAllB || input boolean isAnyB = isAllB || input
.getObject()
.getSubtype(game) .getSubtype(game)
.stream() .stream()
.map(SubType::getSubTypeSet) .map(SubType::getSubTypeSet)
@ -138,6 +137,6 @@ enum TajuruParagonPredicate implements ObjectSourcePlayerPredicate<ObjectSourceP
.getSubtype(game) .getSubtype(game)
.stream() .stream()
.filter(subType -> subType.getSubTypeSet() == SubTypeSet.CreatureType) .filter(subType -> subType.getSubTypeSet() == SubTypeSet.CreatureType)
.anyMatch(subType -> input.getObject().hasSubtype(subType, game))); .anyMatch(subType -> input.hasSubtype(subType, game)));
} }
} }