forked from External/mage
fix #12867 (Devouring Hellion)
by refactoring to use DevourEffect test added
This commit is contained in:
parent
d052ab45c6
commit
842fa90e7e
7 changed files with 116 additions and 134 deletions
|
|
@ -6,8 +6,7 @@ import mage.abilities.effects.ReplacementEffectImpl;
|
|||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.common.FilterControlledPermanent;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.predicate.mageobject.AnotherPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.EntersTheBattlefieldEvent;
|
||||
|
|
@ -45,9 +44,9 @@ public class DevourEffect extends ReplacementEffectImpl {
|
|||
// "creature" is a special case as the rule will not mention it.
|
||||
//
|
||||
// 's' will be added to pluralize, so far so good with the current text generation.
|
||||
private final FilterControlledPermanent filterDevoured;
|
||||
private final FilterPermanent filterDevoured;
|
||||
|
||||
public DevourEffect(int devourFactor, FilterControlledPermanent filterDevoured) {
|
||||
public DevourEffect(int devourFactor, FilterPermanent filterDevoured) {
|
||||
super(Duration.EndOfGame, Outcome.Detriment);
|
||||
this.devourFactor = devourFactor;
|
||||
this.filterDevoured = filterDevoured;
|
||||
|
|
@ -81,11 +80,8 @@ public class DevourEffect extends ReplacementEffectImpl {
|
|||
if (creature == null || controller == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FilterControlledPermanent filter = new FilterControlledPermanent(filterDevoured.getMessage() + "s to devour");
|
||||
for (Predicate predicate : filterDevoured.getPredicates()) {
|
||||
filter.add(predicate);
|
||||
}
|
||||
FilterPermanent filter = filterDevoured.copy();
|
||||
filter.setMessage(filterDevoured.getMessage() + "s (to devour)");
|
||||
filter.add(AnotherPredicate.instance);
|
||||
|
||||
Target target = new TargetSacrifice(1, Integer.MAX_VALUE, filter);
|
||||
|
|
@ -142,9 +138,9 @@ public class DevourEffect extends ReplacementEffectImpl {
|
|||
text += devourFactor;
|
||||
}
|
||||
|
||||
text += " <i>(As this enters the battlefield, you may sacrifice any number of "
|
||||
text += " <i>(As this enters, you may sacrifice any number of "
|
||||
+ filterMessage + "s. "
|
||||
+ "This creature enters the battlefield with ";
|
||||
+ "This creature enters with ";
|
||||
|
||||
if (devourFactor == Integer.MAX_VALUE) {
|
||||
text += "X +1/+1 counters on it for each of those creatures";
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
|
||||
package mage.abilities.keyword;
|
||||
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.common.DevourEffect;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.common.FilterControlledPermanent;
|
||||
|
||||
/**
|
||||
* 502.82. Devour
|
||||
|
|
@ -45,12 +44,12 @@ import mage.filter.common.FilterControlledPermanent;
|
|||
*/
|
||||
public class DevourAbility extends SimpleStaticAbility {
|
||||
|
||||
private static final FilterControlledPermanent filterCreature = new FilterControlledCreaturePermanent("creature");
|
||||
private static final FilterPermanent filterCreature = new FilterControlledCreaturePermanent("creature");
|
||||
|
||||
// Integer.MAX_VALUE is a special value
|
||||
// for "devour X, where X is the number of devored permanents"
|
||||
// see DevourEffect for the full details.
|
||||
public static DevourAbility DevourX() {
|
||||
public static DevourAbility devourX() {
|
||||
return new DevourAbility(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
|
|
@ -58,7 +57,7 @@ public class DevourAbility extends SimpleStaticAbility {
|
|||
this(devourFactor, filterCreature);
|
||||
}
|
||||
|
||||
public DevourAbility(int devourFactor, FilterControlledPermanent filterDevoured) {
|
||||
public DevourAbility(int devourFactor, FilterPermanent filterDevoured) {
|
||||
super(Zone.ALL, new DevourEffect(devourFactor, filterDevoured));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue