foul-magics/Mage/src/main/java/mage/target/common/TargetAnyTargetAmount.java
Oleg Agafonov 255c292104 * Deals damage divided as you choose - fixed that some cards can't choose planeswalkers (example: Arc Lightning, see #7276);
Refactor: simplified FilterCreaturePlayerOrPlaneswalker to use single permanent filter;
2020-12-23 02:31:41 +04:00

49 lines
1.7 KiB
Java

package mage.target.common;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePlayerOrPlaneswalker;
/**
* @author BetaSteward_at_googlemail.com
*/
public class TargetAnyTargetAmount extends TargetPermanentOrPlayerAmount {
private static final FilterCreaturePlayerOrPlaneswalker defaultFilter
= new FilterCreaturePlayerOrPlaneswalker("targets");
public TargetAnyTargetAmount(int amount) {
this(amount, 0);
}
public TargetAnyTargetAmount(int amount, int maxNumberOfTargets) {
// 107.1c If a rule or ability instructs a player to choose “any number,” that player may choose
// any positive number or zero, unless something (such as damage or counters) is being divided
// or distributed among “any number” of players and/or objects. In that case, a nonzero number
// of players and/or objects must be chosen if possible.
this(StaticValue.get(amount), maxNumberOfTargets);
this.minNumberOfTargets = 1;
}
public TargetAnyTargetAmount(DynamicValue amount) {
this(amount, 0);
}
public TargetAnyTargetAmount(DynamicValue amount, int maxNumberOfTargets) {
super(amount, maxNumberOfTargets);
this.zone = Zone.ALL;
this.filter = defaultFilter;
this.targetName = filter.getMessage();
}
private TargetAnyTargetAmount(final TargetAnyTargetAmount target) {
super(target);
this.filter = target.filter.copy();
}
@Override
public TargetAnyTargetAmount copy() {
return new TargetAnyTargetAmount(this);
}
}