mirror of
https://github.com/magefree/mage.git
synced 2025-12-28 14:32:06 -08:00
partially refactor TargetCreaturePermanent constructors
This commit is contained in:
parent
80500b5b94
commit
3e65021150
99 changed files with 724 additions and 911 deletions
|
|
@ -6,7 +6,6 @@ import mage.abilities.dynamicvalue.common.StaticValue;
|
|||
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
|
|
@ -23,7 +22,7 @@ public class SupportEffect extends AddCountersTargetEffect {
|
|||
this.amountSupportTargets = StaticValue.get(amount);
|
||||
this.otherPermanent = otherPermanent;
|
||||
if (card.isInstantOrSorcery()) {
|
||||
card.getSpellAbility().addTarget(new TargetCreaturePermanent(0, amount, new FilterCreaturePermanent("target creatures"), false));
|
||||
card.getSpellAbility().addTarget(new TargetCreaturePermanent(0, amount));
|
||||
}
|
||||
staticText = setText();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
|
||||
package mage.abilities.keyword;
|
||||
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.effects.keyword.SupportEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.mageobject.AnotherPredicate;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
/**
|
||||
* 701.32. Support
|
||||
|
|
@ -19,19 +20,25 @@ import mage.target.common.TargetCreaturePermanent;
|
|||
*/
|
||||
public class SupportAbility extends EntersBattlefieldTriggeredAbility {
|
||||
|
||||
private static final FilterPermanent filter = new FilterCreaturePermanent("other target creatures");
|
||||
|
||||
static {
|
||||
filter.add(AnotherPredicate.instance);
|
||||
}
|
||||
|
||||
/*
|
||||
* For enchantments, the text should not include the word "other".
|
||||
* The otherPermanent choice removes the word "other" from rule text creation.
|
||||
*/
|
||||
public SupportAbility(Card card, int amount, boolean otherPermanent) {
|
||||
super(new SupportEffect(card, amount, otherPermanent));
|
||||
if (!card.isInstantOrSorcery()) {
|
||||
FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures");
|
||||
if (card.isCreature()) {
|
||||
filter.add(AnotherPredicate.instance);
|
||||
filter.setMessage("other target creatures");
|
||||
}
|
||||
addTarget(new TargetCreaturePermanent(0, amount, filter, false));
|
||||
if (card.isInstantOrSorcery()) {
|
||||
return;
|
||||
}
|
||||
if (card.isCreature()) {
|
||||
addTarget(new TargetPermanent(0, amount, StaticFilters.FILTER_PERMANENT_CREATURES));
|
||||
} else {
|
||||
addTarget(new TargetPermanent(0, amount, filter));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import mage.filter.predicate.Predicates;
|
|||
import mage.filter.predicate.mageobject.ColorPredicate;
|
||||
import mage.game.command.Plane;
|
||||
import mage.target.Target;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.watchers.common.PlanarRollWatcher;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -62,7 +62,7 @@ public class BantPlane extends Plane {
|
|||
|
||||
// Active player can roll the planar die: Whenever you roll {CHAOS}, put a divinity counter on target green, white, or blue creature. That creature gains indestructible for as long as it has a divinity counter on it.
|
||||
Effect chaosEffect = new ConditionalContinuousEffect(new GainAbilityTargetEffect(IndestructibleAbility.getInstance(), Duration.Custom), new TargetHasCounterCondition(CounterType.DIVINITY), rule);
|
||||
Target chaosTarget = new TargetCreaturePermanent(1, 1, filter2, false);
|
||||
Target chaosTarget = new TargetPermanent(filter2);
|
||||
Effect chaosEffect2 = new AddCountersTargetEffect(CounterType.DIVINITY.createInstance());
|
||||
|
||||
List<Effect> chaosEffects = new ArrayList<Effect>();
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import mage.game.Game;
|
|||
import mage.game.command.Plane;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.target.Target;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.util.CardUtil;
|
||||
import mage.watchers.common.PlanarRollWatcher;
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ public class FeedingGroundsPlane extends Plane {
|
|||
|
||||
// Active player can roll the planar die: Whenever you roll {CHAOS}, target red or green creature gets X +1/+1 counters
|
||||
Effect chaosEffect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(), TargetManaValue.instance);
|
||||
Target chaosTarget = new TargetCreaturePermanent(1, 1, StaticFilters.FILTER_PERMANENT_A_CREATURE, false);
|
||||
Target chaosTarget = new TargetPermanent(StaticFilters.FILTER_PERMANENT_A_CREATURE);
|
||||
|
||||
List<Effect> chaosEffects = new ArrayList<>();
|
||||
chaosEffects.add(chaosEffect);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.target.common;
|
||||
|
||||
import mage.filter.StaticFilters;
|
||||
|
|
@ -15,7 +14,7 @@ public class TargetCreaturePermanent extends TargetPermanent {
|
|||
}
|
||||
|
||||
public TargetCreaturePermanent(FilterCreaturePermanent filter) {
|
||||
this(1, 1, filter, false);
|
||||
super(1, 1, filter, false);
|
||||
}
|
||||
|
||||
public TargetCreaturePermanent(int numTargets) {
|
||||
|
|
@ -23,11 +22,7 @@ public class TargetCreaturePermanent extends TargetPermanent {
|
|||
}
|
||||
|
||||
public TargetCreaturePermanent(int minNumTargets, int maxNumTargets) {
|
||||
this(minNumTargets, maxNumTargets, maxNumTargets > 1 ? StaticFilters.FILTER_PERMANENT_CREATURES : StaticFilters.FILTER_PERMANENT_CREATURE, false);
|
||||
}
|
||||
|
||||
public TargetCreaturePermanent(int minNumTargets, int maxNumTargets, FilterCreaturePermanent filter, boolean notTarget) {
|
||||
super(minNumTargets, maxNumTargets, filter, notTarget);
|
||||
super(minNumTargets, maxNumTargets, maxNumTargets > 1 ? StaticFilters.FILTER_PERMANENT_CREATURES : StaticFilters.FILTER_PERMANENT_CREATURE, false);
|
||||
}
|
||||
|
||||
protected TargetCreaturePermanent(final TargetCreaturePermanent target) {
|
||||
|
|
|
|||
|
|
@ -1,49 +0,0 @@
|
|||
|
||||
package mage.target.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class TargetCreaturePermanentWithDifferentTypes extends TargetCreaturePermanent {
|
||||
|
||||
public TargetCreaturePermanentWithDifferentTypes(int minNumTargets, int maxNumTargets, FilterCreaturePermanent filter, boolean notTarget) {
|
||||
super(minNumTargets, maxNumTargets, filter, notTarget);
|
||||
}
|
||||
|
||||
protected TargetCreaturePermanentWithDifferentTypes(final TargetCreaturePermanentWithDifferentTypes target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetCreaturePermanentWithDifferentTypes copy() {
|
||||
return new TargetCreaturePermanentWithDifferentTypes(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
|
||||
if (super.canTarget(controllerId, id, source, game)) {
|
||||
Permanent creature = game.getPermanent(id);
|
||||
if (creature != null) {
|
||||
for (Object object : getTargets()) {
|
||||
UUID targetId = (UUID) object;
|
||||
Permanent selectedCreature = game.getPermanent(targetId);
|
||||
if (selectedCreature != null
|
||||
&& !creature.getId().equals(selectedCreature.getId())) {
|
||||
if (creature.shareCreatureTypes(game, selectedCreature)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue