mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
rework CombatDamageByToughnessAllEffect (#11180)
new CombatDamageByToughnessControlledEffect add tests fix #11179
This commit is contained in:
parent
0ad678ff56
commit
fa8e93a29d
13 changed files with 172 additions and 43 deletions
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.effects.common.ruleModifying;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -7,17 +6,25 @@ import mage.constants.Duration;
|
|||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
* @author TheElk801, xanderhall
|
||||
*/
|
||||
public class CombatDamageByToughnessAllEffect extends ContinuousEffectImpl {
|
||||
|
||||
private final FilterCreaturePermanent filter;
|
||||
|
||||
public CombatDamageByToughnessAllEffect() {
|
||||
this(StaticFilters.FILTER_PERMANENT_CREATURE);
|
||||
}
|
||||
|
||||
/**
|
||||
* "Each [] assigns combat damage equal to its toughness rather than its power"
|
||||
* @param filter Warning: ObjectSourcePlayer predicates will be ignored
|
||||
*/
|
||||
public CombatDamageByToughnessAllEffect(FilterCreaturePermanent filter) {
|
||||
this(filter, Duration.WhileOnBattlefield);
|
||||
}
|
||||
|
|
@ -25,9 +32,8 @@ public class CombatDamageByToughnessAllEffect extends ContinuousEffectImpl {
|
|||
public CombatDamageByToughnessAllEffect(FilterCreaturePermanent filter, Duration duration) {
|
||||
super(duration, Layer.RulesEffects, SubLayer.NA, Outcome.Neutral);
|
||||
this.filter = filter;
|
||||
this.staticText = filter.getMessage() + " assigns combat damage equal to its toughness rather than its power";
|
||||
this.staticText = "each " + filter.getMessage() + " assigns combat damage equal to its toughness rather than its power";
|
||||
}
|
||||
|
||||
|
||||
private CombatDamageByToughnessAllEffect(final CombatDamageByToughnessAllEffect effect) {
|
||||
super(effect);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,59 @@
|
|||
package mage.abilities.effects.common.ruleModifying;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.permanent.ControllerIdPredicate;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
* @author TheElk801, xenohedron
|
||||
*/
|
||||
public class CombatDamageByToughnessControlledEffect extends ContinuousEffectImpl {
|
||||
|
||||
private final FilterCreaturePermanent filter;
|
||||
|
||||
public CombatDamageByToughnessControlledEffect() {
|
||||
this(StaticFilters.FILTER_PERMANENT_CREATURE);
|
||||
}
|
||||
|
||||
/**
|
||||
* "Each [] you control assigns combat damage equal to its toughness rather than its power"
|
||||
* @param filter Warning: ObjectSourcePlayer predicates will be ignored
|
||||
*/
|
||||
public CombatDamageByToughnessControlledEffect(FilterCreaturePermanent filter) {
|
||||
this(filter, Duration.WhileOnBattlefield);
|
||||
}
|
||||
|
||||
public CombatDamageByToughnessControlledEffect(FilterCreaturePermanent filter, Duration duration) {
|
||||
super(duration, Layer.RulesEffects, SubLayer.NA, Outcome.Neutral);
|
||||
this.filter = filter;
|
||||
this.staticText = "each " + filter.getMessage()
|
||||
+ (filter.getMessage().contains("you control") ? "" : " you control")
|
||||
+ " assigns combat damage equal to its toughness rather than its power";
|
||||
}
|
||||
|
||||
private CombatDamageByToughnessControlledEffect(final CombatDamageByToughnessControlledEffect effect) {
|
||||
super(effect);
|
||||
this.filter = effect.filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CombatDamageByToughnessControlledEffect copy() {
|
||||
return new CombatDamageByToughnessControlledEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
FilterCreaturePermanent filterPermanent = filter.copy();
|
||||
filterPermanent.add(new ControllerIdPredicate(source.getControllerId()));
|
||||
game.getCombat().setUseToughnessForDamage(true);
|
||||
game.getCombat().addUseToughnessForDamageFilter(filterPermanent);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1229,10 +1229,4 @@ public final class StaticFilters {
|
|||
FILTER_CONTROLLED_FOOD.setLockedFilter(true);
|
||||
}
|
||||
|
||||
public static final FilterCreaturePermanent FILTER_CONTROLLED_CREATURE_EACH = new FilterCreaturePermanent("each creature you control");
|
||||
|
||||
static {
|
||||
FILTER_CONTROLLED_CREATURE_EACH.add(TargetController.YOU.getPlayerPredicate());
|
||||
FILTER_CONTROLLED_CREATURE_EACH.setLockedFilter(true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue