mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
some more target filter refactors
This commit is contained in:
parent
14c61caf39
commit
80500b5b94
14 changed files with 35 additions and 79 deletions
|
|
@ -15,7 +15,7 @@ import mage.filter.predicate.mageobject.AnotherPredicate;
|
|||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.target.common.TargetCreatureOrPlaneswalker;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
|
@ -45,7 +45,7 @@ public final class BarrinTolarianArchmage extends CardImpl {
|
|||
|
||||
// When Barrin, Tolarian Archmage enters the battlefield, return up to one other target creature or planeswalker to its owner's hand.
|
||||
Ability ability = new EntersBattlefieldTriggeredAbility(new ReturnToHandTargetEffect());
|
||||
ability.addTarget(new TargetCreatureOrPlaneswalker(0, 1, filter, false));
|
||||
ability.addTarget(new TargetPermanent(0, 1, filter));
|
||||
this.addAbility(ability);
|
||||
|
||||
// At the beginning of your end step, if a permanent was put into your hand from the battlefield this turn, draw a card.
|
||||
|
|
|
|||
|
|
@ -16,10 +16,11 @@ import mage.constants.Outcome;
|
|||
import mage.constants.SubType;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.common.FilterAnyTarget;
|
||||
import mage.filter.common.FilterPermanentOrPlayer;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.common.TargetAnyTarget;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
import mage.target.common.TargetPermanentOrPlayer;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -28,7 +29,7 @@ import java.util.UUID;
|
|||
*/
|
||||
public final class CallousSellSword extends AdventureCard {
|
||||
|
||||
private static final FilterAnyTarget filterSecondTarget = new FilterAnyTarget("any other target");
|
||||
private static final FilterPermanentOrPlayer filterSecondTarget = new FilterAnyTarget("any other target");
|
||||
|
||||
private static final Hint hint = new ValueHint(
|
||||
"Creatures that died under your control this turn", CreaturesYouControlDiedCount.instance
|
||||
|
|
@ -54,7 +55,7 @@ public final class CallousSellSword extends AdventureCard {
|
|||
// Target creature you control deals damage equal to its power to any other target. Then sacrifice it.
|
||||
this.getSpellCard().getSpellAbility().addEffect(new DamageWithPowerFromOneToAnotherTargetEffect());
|
||||
this.getSpellCard().getSpellAbility().addTarget(new TargetControlledCreaturePermanent().setTargetTag(1));
|
||||
this.getSpellCard().getSpellAbility().addTarget(new TargetAnyTarget(1, 1, filterSecondTarget).setTargetTag(2));
|
||||
this.getSpellCard().getSpellAbility().addTarget(new TargetPermanentOrPlayer(filterSecondTarget).setTargetTag(2));
|
||||
this.getSpellCard().getSpellAbility().addEffect(new CallousSellSwordSacrificeFirstTargetEffect().concatBy("Then"));
|
||||
|
||||
this.finalizeAdventure();
|
||||
|
|
|
|||
|
|
@ -16,13 +16,12 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
import mage.target.common.TargetCreatureOrPlaneswalker;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author htrajan
|
||||
*/
|
||||
public final class ClosingStatement extends CardImpl {
|
||||
|
|
@ -44,11 +43,9 @@ public final class ClosingStatement extends CardImpl {
|
|||
this.addAbility(ability);
|
||||
|
||||
// Destroy target creature or planeswalker you don't control. Put a +1/+1 counter on up to one target creature you control.
|
||||
this.getSpellAbility().addTarget(new TargetCreatureOrPlaneswalker(1, 1, filter, false)
|
||||
.setTargetTag(1));
|
||||
this.getSpellAbility().addTarget(new TargetPermanent(filter).setTargetTag(1));
|
||||
this.getSpellAbility().addEffect(new DestroyTargetEffect());
|
||||
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent(0, 1)
|
||||
.setTargetTag(2));
|
||||
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent(0, 1).setTargetTag(2));
|
||||
this.getSpellAbility().addEffect(new ClosingStatementEffect());
|
||||
}
|
||||
|
||||
|
|
@ -85,9 +82,9 @@ class ClosingStatementEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
Target target = source.getTargets().stream()
|
||||
.filter(t -> t.getTargetTag() == 2)
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new IllegalStateException("Expected to find target with tag 2 but none exists"));
|
||||
.filter(t -> t.getTargetTag() == 2)
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new IllegalStateException("Expected to find target with tag 2 but none exists"));
|
||||
Permanent permanent = game.getPermanent(target.getFirstTarget());
|
||||
if (permanent != null) {
|
||||
return permanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import mage.cards.CardImpl;
|
|||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.filter.common.FilterCreatureOrPlaneswalkerPermanent;
|
||||
import mage.target.common.TargetCreatureOrPlaneswalker;
|
||||
import mage.target.common.TargetOpponent;
|
||||
|
||||
|
|
@ -34,7 +33,7 @@ public final class RakdosFirewheeler extends CardImpl {
|
|||
effect.setText("it deals 2 damage to target opponent and 2 damage to up to one target creature or planeswalker");
|
||||
Ability ability = new EntersBattlefieldTriggeredAbility(effect, false);
|
||||
ability.addTarget(new TargetOpponent());
|
||||
ability.addTarget(new TargetCreatureOrPlaneswalker(0, 1, new FilterCreatureOrPlaneswalkerPermanent(), false));
|
||||
ability.addTarget(new TargetCreatureOrPlaneswalker(0, 1));
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import mage.filter.predicate.mageobject.AnotherPredicate;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetAnyTarget;
|
||||
import mage.target.common.TargetPermanentOrPlayer;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
@ -45,7 +45,7 @@ public final class ScreamingNemesis extends CardImpl {
|
|||
|
||||
// Whenever Screaming Nemesis is dealt damage, it deals that much damage to any other target. If a player is dealt damage this way, they can't gain life for the rest of the game.
|
||||
Ability ability = new DealtDamageToSourceTriggeredAbility(new ScreamingNemesisEffect(), false);
|
||||
ability.addTarget(new TargetAnyTarget(filter));
|
||||
ability.addTarget(new TargetPermanentOrPlayer(filter));
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
|
|
@ -98,4 +98,4 @@ class ScreamingNemesisEffect extends OneShotEffect {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ import mage.filter.predicate.other.AnotherTargetPredicate;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetAnyTarget;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
import mage.target.common.TargetPermanentOrPlayer;
|
||||
import mage.target.targetpointer.EachTargetPointer;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -36,7 +36,7 @@ public final class SelfDestruct extends CardImpl {
|
|||
// Target creature you control deals X damage to any other target and X damage to itself, where X is its power.
|
||||
this.getSpellAbility().addEffect(new SelfDestructEffect());
|
||||
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent().setTargetTag(1));
|
||||
this.getSpellAbility().addTarget(new TargetAnyTarget(filter).setTargetTag(2));
|
||||
this.getSpellAbility().addTarget(new TargetPermanentOrPlayer(filter).setTargetTag(2));
|
||||
}
|
||||
|
||||
private SelfDestruct(final SelfDestruct card) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import mage.constants.SubType;
|
|||
import mage.constants.SuperType;
|
||||
import mage.constants.TargetController;
|
||||
import mage.filter.common.FilterCreatureOrPlaneswalkerPermanent;
|
||||
import mage.target.common.TargetCreatureOrPlaneswalker;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ public final class SkysovereignConsulFlagship extends CardImpl {
|
|||
|
||||
// Whenever Skysovereign, Consul Flagship enters the battlefield or attacks, it deals 3 damage to target creature or planeswalker an opponent controls.
|
||||
Ability ability = new EntersBattlefieldOrAttacksSourceTriggeredAbility(new DamageTargetEffect(3, "it"));
|
||||
ability.addTarget(new TargetCreatureOrPlaneswalker(1, 1, filter, false));
|
||||
ability.addTarget(new TargetPermanent(filter));
|
||||
this.addAbility(ability);
|
||||
|
||||
// Crew 3
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ import mage.filter.common.FilterCreatureOrPlayer;
|
|||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.game.permanent.token.TIEFighterToken;
|
||||
import mage.target.common.TargetCreatureOrPlayer;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.target.common.TargetPermanentOrPlayer;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ public final class StarDestroyer extends CardImpl {
|
|||
|
||||
// {2}{R}: Star Destroyer deals 2 damge to target non-Starship creature or player.
|
||||
ability = new SimpleActivatedAbility(new DamageTargetEffect(2), new ManaCostsImpl<>("{2}{R}"));
|
||||
ability.addTarget(new TargetCreatureOrPlayer(filter3));
|
||||
ability.addTarget(new TargetPermanentOrPlayer(filter3));
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import mage.constants.CardType;
|
|||
import mage.filter.common.FilterCreatureOrPlayer;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.AbilityPredicate;
|
||||
import mage.target.common.TargetCreatureOrPlayer;
|
||||
import mage.target.common.TargetPermanentOrPlayer;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ public final class ThermalDetonator extends CardImpl {
|
|||
// {2}, Sacrifice Thermal Detonator: Thermal Detonator deals 2 damage to target creature without spaceflight or target player.
|
||||
Ability ability = new SimpleActivatedAbility(new DamageTargetEffect(2), new ManaCostsImpl<>("{2}"));
|
||||
ability.addCost(new SacrificeSourceCost());
|
||||
ability.addTarget(new TargetCreatureOrPlayer(filter));
|
||||
ability.addTarget(new TargetPermanentOrPlayer(filter));
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import mage.constants.CardType;
|
|||
import mage.constants.Outcome;
|
||||
import mage.constants.SuperType;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterCreatureOrPlaneswalkerPermanent;
|
||||
import mage.filter.common.FilterPermanentCard;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.game.Game;
|
||||
|
|
@ -47,7 +46,7 @@ public final class YawgmothsVileOffering extends CardImpl {
|
|||
// Destroy up to one target creature or planeswalker. Exile Yawgmoth's Vile Offering.
|
||||
this.getSpellAbility().addEffect(new YawgmothsVileOfferingEffect());
|
||||
this.getSpellAbility().addTarget(new TargetCardInGraveyard(0, 1, cardFilter));
|
||||
this.getSpellAbility().addTarget(new TargetCreatureOrPlaneswalker(0, 1, new FilterCreatureOrPlaneswalkerPermanent(), false));
|
||||
this.getSpellAbility().addTarget(new TargetCreatureOrPlaneswalker(0, 1));
|
||||
this.getSpellAbility().addEffect(new ExileSpellEffect());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,20 +15,12 @@ public class TargetAnyTarget extends TargetPermanentOrPlayer {
|
|||
this(1);
|
||||
}
|
||||
|
||||
public TargetAnyTarget(FilterAnyTarget filter) {
|
||||
this(1, 1, filter);
|
||||
}
|
||||
|
||||
public TargetAnyTarget(int numTargets) {
|
||||
this(numTargets, numTargets);
|
||||
}
|
||||
|
||||
public TargetAnyTarget(int minNumTargets, int maxNumTargets) {
|
||||
this(minNumTargets, maxNumTargets, defaultFilter);
|
||||
}
|
||||
|
||||
public TargetAnyTarget(int minNumTargets, int maxNumTargets, FilterAnyTarget filter) {
|
||||
super(minNumTargets, maxNumTargets, filter, false);
|
||||
super(minNumTargets, maxNumTargets, defaultFilter, false);
|
||||
}
|
||||
|
||||
protected TargetAnyTarget(final TargetAnyTarget target) {
|
||||
|
|
|
|||
|
|
@ -1,14 +1,8 @@
|
|||
|
||||
package mage.target.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.filter.common.FilterCreatureOrPlaneswalkerPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
|
@ -23,11 +17,7 @@ public class TargetCreatureOrPlaneswalker extends TargetPermanent {
|
|||
}
|
||||
|
||||
public TargetCreatureOrPlaneswalker(int minNumTargets, int maxNumTargets) {
|
||||
this(minNumTargets, maxNumTargets, new FilterCreatureOrPlaneswalkerPermanent(), false);
|
||||
}
|
||||
|
||||
public TargetCreatureOrPlaneswalker(int minNumTargets, int maxNumTargets, FilterCreatureOrPlaneswalkerPermanent filter, boolean notTarget) {
|
||||
super(minNumTargets, maxNumTargets, filter, notTarget);
|
||||
super(minNumTargets, maxNumTargets, StaticFilters.FILTER_PERMANENT_CREATURE_OR_PLANESWALKER, false);
|
||||
}
|
||||
|
||||
protected TargetCreatureOrPlaneswalker(final TargetCreatureOrPlaneswalker target) {
|
||||
|
|
@ -38,17 +28,4 @@ public class TargetCreatureOrPlaneswalker extends TargetPermanent {
|
|||
public TargetCreatureOrPlaneswalker copy() {
|
||||
return new TargetCreatureOrPlaneswalker(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLegal(Ability source, Game game) {
|
||||
for (UUID playerId : targets.keySet()) {
|
||||
Player targetPlayer = game.getPlayer(playerId);
|
||||
if (targetPlayer != null) {
|
||||
// there seems to be no possibility to add more predicates for theplayer so return here true
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.isLegal(source, game);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +1,17 @@
|
|||
package mage.target.common;
|
||||
|
||||
import mage.filter.common.FilterCreatureOrPlayer;
|
||||
import mage.filter.common.FilterPermanentOrPlayer;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class TargetCreatureOrPlayer extends TargetPermanentOrPlayer {
|
||||
|
||||
private static final FilterPermanentOrPlayer filter = new FilterCreatureOrPlayer();
|
||||
|
||||
public TargetCreatureOrPlayer() {
|
||||
this(1, 1, new FilterCreatureOrPlayer());
|
||||
}
|
||||
|
||||
public TargetCreatureOrPlayer(FilterCreatureOrPlayer filter) {
|
||||
this(1, 1, filter);
|
||||
}
|
||||
|
||||
public TargetCreatureOrPlayer(int minNumTargets, int maxNumTargets, FilterCreatureOrPlayer filter) {
|
||||
super(minNumTargets, maxNumTargets, filter, false);
|
||||
super(1, 1, filter, false);
|
||||
}
|
||||
|
||||
protected TargetCreatureOrPlayer(final TargetCreatureOrPlayer target) {
|
||||
|
|
@ -27,5 +22,4 @@ public class TargetCreatureOrPlayer extends TargetPermanentOrPlayer {
|
|||
public TargetCreatureOrPlayer copy() {
|
||||
return new TargetCreatureOrPlayer(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,16 @@
|
|||
|
||||
package mage.target.common;
|
||||
|
||||
import mage.constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.filter.predicate.card.OwnerIdPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.target.TargetCard;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.filter.predicate.card.OwnerIdPredicate;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
|
|
@ -54,5 +52,4 @@ public class TargetDiscard extends TargetCard {
|
|||
public TargetDiscard copy() {
|
||||
return new TargetDiscard(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue