mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
fix Cracked Skull, expand LookTargetHandChooseDiscardEffect
to support FilterCard
This commit is contained in:
parent
497b4321b3
commit
e2531a4da5
4 changed files with 14 additions and 7 deletions
|
|
@ -35,7 +35,7 @@ public final class AbandonHope extends CardImpl {
|
|||
this.addAbility(ability);
|
||||
|
||||
// Look at target opponent's hand and choose X cards from it. That player discards those cards.
|
||||
this.getSpellAbility().addEffect(new LookTargetHandChooseDiscardEffect(false, GetXValue.instance));
|
||||
this.getSpellAbility().addEffect(new LookTargetHandChooseDiscardEffect(false, GetXValue.instance, StaticFilters.FILTER_CARD_CARDS));
|
||||
this.getSpellAbility().addTarget(new TargetOpponent());
|
||||
this.getSpellAbility().setCostAdjuster(AbandonHopeAdjuster.instance);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@ package mage.cards.c;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.DealtDamageAttachedTriggeredAbility;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.abilities.effects.common.DestroyTargetEffect;
|
||||
import mage.abilities.effects.common.discard.DiscardCardYouChooseTargetEffect;
|
||||
import mage.abilities.effects.common.discard.LookTargetHandChooseDiscardEffect;
|
||||
import mage.abilities.keyword.EnchantAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
|
|
@ -35,7 +36,8 @@ public final class CrackedSkull extends CardImpl {
|
|||
|
||||
// When Cracked Skull enters, look at target player's hand. You may choose a nonland card from it. That player discards that card.
|
||||
Ability ability = new EntersBattlefieldTriggeredAbility(
|
||||
new DiscardCardYouChooseTargetEffect(StaticFilters.FILTER_CARD_NON_LAND).setOptional(true)
|
||||
new LookTargetHandChooseDiscardEffect(true, StaticValue.get(1), StaticFilters.FILTER_CARD_NON_LAND)
|
||||
.setText("look at target player's hand. You may choose a nonland card from it. That player discards that card")
|
||||
);
|
||||
ability.addTarget(new TargetPlayer());
|
||||
this.addAbility(ability);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import mage.abilities.effects.common.discard.LookTargetHandChooseDiscardEffect;
|
|||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.target.TargetPlayer;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
@ -18,7 +19,7 @@ public final class MindWarp extends CardImpl {
|
|||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{3}{B}");
|
||||
|
||||
// Look at target player's hand and choose X cards from it. That player discards those cards.
|
||||
this.getSpellAbility().addEffect(new LookTargetHandChooseDiscardEffect(false, GetXValue.instance));
|
||||
this.getSpellAbility().addEffect(new LookTargetHandChooseDiscardEffect(false, GetXValue.instance, StaticFilters.FILTER_CARD_CARDS));
|
||||
this.getSpellAbility().addTarget(new TargetPlayer());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import mage.abilities.dynamicvalue.common.StaticValue;
|
|||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.Outcome;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
|
@ -21,25 +22,28 @@ public class LookTargetHandChooseDiscardEffect extends OneShotEffect {
|
|||
|
||||
private final boolean upTo;
|
||||
private final DynamicValue numberToDiscard;
|
||||
private final FilterCard filter;
|
||||
|
||||
public LookTargetHandChooseDiscardEffect() {
|
||||
this(false, 1);
|
||||
}
|
||||
|
||||
public LookTargetHandChooseDiscardEffect(boolean upTo, int numberToDiscard) {
|
||||
this(upTo, StaticValue.get(numberToDiscard));
|
||||
this(upTo, StaticValue.get(numberToDiscard), numberToDiscard == 1 ? StaticFilters.FILTER_CARD : StaticFilters.FILTER_CARD_CARDS);
|
||||
}
|
||||
|
||||
public LookTargetHandChooseDiscardEffect(boolean upTo, DynamicValue numberToDiscard) {
|
||||
public LookTargetHandChooseDiscardEffect(boolean upTo, DynamicValue numberToDiscard, FilterCard filter) {
|
||||
super(Outcome.Discard);
|
||||
this.upTo = upTo;
|
||||
this.numberToDiscard = numberToDiscard;
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
protected LookTargetHandChooseDiscardEffect(final LookTargetHandChooseDiscardEffect effect) {
|
||||
super(effect);
|
||||
this.upTo = effect.upTo;
|
||||
this.numberToDiscard = effect.numberToDiscard;
|
||||
this.filter = effect.filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -56,7 +60,7 @@ public class LookTargetHandChooseDiscardEffect extends OneShotEffect {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
TargetCard target = new TargetCardInHand(upTo ? 0 : num, num, num > 1 ? StaticFilters.FILTER_CARD_CARDS : StaticFilters.FILTER_CARD);
|
||||
TargetCard target = new TargetCardInHand(upTo ? 0 : num, num, filter);
|
||||
if (controller.choose(Outcome.Discard, player.getHand(), target, source, game)) {
|
||||
player.discard(new CardsImpl(target.getTargets()), false, source, game);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue