foul-magics/Mage/src/main/java/mage/target/common/TargetCreatureOrPlaneswalkerAmount.java
Cameron Merkel 73b63d14ad
TargetAmount refactors (#13128)
* Add minimum and maximum target counts as parameters for TargetAmount and its subclasses; update/add several rules comments (and one actual text) for clarity; remove unused imports

* Get amount+description from target instead of parameters for DistributeCountersEffect and DamageMultiEffect; additions to TargetImpl.getDescription to accommodate

* Create separate method to check if "any number" phrasing should be used, override it in TargetAmount

* Check instanceof TargetAmount before casting

* Add new constructors to chain off of for TargetCreaturePermanentAmount & TargetCreatureOrPlaneswalkerAmount

* Fix text for Storm the Seedcore

* Use Integer.MAX_VALUE instead of 0 to represent no maximum targets

* Add comment about getUseAnyNumber()

* Use amount-only constructors in some TargetAmount subclasses, add clarifying documentation

* Fix a few calls

* Require more specific filters
2024-12-17 19:23:18 -05:00

80 lines
3.9 KiB
Java

package mage.target.common;
import mage.filter.common.FilterControlledCreatureOrPlaneswalkerPermanent;
import mage.filter.common.FilterCreatureOrPlaneswalkerPermanent;
/**
* @author BetaSteward_at_googlemail.com
*/
public class TargetCreatureOrPlaneswalkerAmount extends TargetPermanentAmount {
private static final FilterCreatureOrPlaneswalkerPermanent defaultFilter
= new FilterCreatureOrPlaneswalkerPermanent("target creatures and/or planeswalkers");
/**
* <b>IMPORTANT</b>: Use more specific constructor if {@code amount} is not always the same number!<br>
* {@code minNumberOfTargets} defaults to zero for {@code amount} > 3, otherwise to one, in line with typical templating.<br>
* {@code maxNumberOfTargets} defaults to {@code amount}.<br>
* {@code filter} defaults to all creature and planeswalker permanents. ("target creatures and/or planeswalkers")
*
* @see TargetCreatureOrPlaneswalkerAmount#TargetCreatureOrPlaneswalkerAmount(int, int, int, FilterCreatureOrPlaneswalkerPermanent)
*/
public TargetCreatureOrPlaneswalkerAmount(int amount) {
this(amount, defaultFilter);
}
/**
* <b>IMPORTANT</b>: Use more specific constructor if {@code amount} is not always the same number!<br>
* {@code minNumberOfTargets} defaults to zero for {@code amount} > 3, otherwise to one, in line with typical templating.<br>
* {@code maxNumberOfTargets} defaults to {@code amount}.
*
* @see TargetCreatureOrPlaneswalkerAmount#TargetCreatureOrPlaneswalkerAmount(int, int, int, FilterCreatureOrPlaneswalkerPermanent)
*/
public TargetCreatureOrPlaneswalkerAmount(int amount, FilterCreatureOrPlaneswalkerPermanent filter) {
this(amount, amount > 3 ? 0 : 1, amount, filter);
}
/**
* {@code filter} defaults to all creature and planeswalker permanents. ("target creatures and/or planeswalkers")
*
* @see TargetCreatureOrPlaneswalkerAmount#TargetCreatureOrPlaneswalkerAmount(int, int, int, FilterCreatureOrPlaneswalkerPermanent)
*/
public TargetCreatureOrPlaneswalkerAmount(int amount, int minNumberOfTargets, int maxNumberOfTargets) {
this(amount, minNumberOfTargets, maxNumberOfTargets, defaultFilter);
}
/**
* @param amount Amount of stuff (e.g. damage, counters) to distribute.
* @param minNumberOfTargets Minimum number of targets.
* @param maxNumberOfTargets Maximum number of targets. If no lower max is needed, set to {@code amount}.
* @param filter Filter for creatures and/or planeswalkers that something will be distributed amongst.
*/
public TargetCreatureOrPlaneswalkerAmount(int amount, int minNumberOfTargets, int maxNumberOfTargets, FilterCreatureOrPlaneswalkerPermanent filter) {
super(amount, minNumberOfTargets, maxNumberOfTargets, filter);
}
/**
* <b>IMPORTANT</b>: Use more specific constructor if {@code amount} is not always the same number!
*
* @see TargetCreatureOrPlaneswalkerAmount#TargetCreatureOrPlaneswalkerAmount(int, FilterCreatureOrPlaneswalkerPermanent)
*/
public TargetCreatureOrPlaneswalkerAmount(int amount, FilterControlledCreatureOrPlaneswalkerPermanent filter) {
this(amount, amount > 3 ? 0 : 1, amount, filter);
}
/**
* @see TargetCreatureOrPlaneswalkerAmount#TargetCreatureOrPlaneswalkerAmount(int, int, int, FilterCreatureOrPlaneswalkerPermanent)
*/
public TargetCreatureOrPlaneswalkerAmount(int amount, int minNumberOfTargets, int maxNumberOfTargets, FilterControlledCreatureOrPlaneswalkerPermanent filter) {
super(amount, minNumberOfTargets, maxNumberOfTargets, filter);
}
private TargetCreatureOrPlaneswalkerAmount(final TargetCreatureOrPlaneswalkerAmount target) {
super(target);
}
@Override
public TargetCreatureOrPlaneswalkerAmount copy() {
return new TargetCreatureOrPlaneswalkerAmount(this);
}
}