forked from External/mage
Implemented High Alert
This commit is contained in:
parent
66676f7833
commit
89454f9c8e
7 changed files with 165 additions and 192 deletions
|
|
@ -0,0 +1,62 @@
|
|||
|
||||
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.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.permanent.ControllerIdPredicate;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public class CombatDamageByToughnessEffect extends ContinuousEffectImpl {
|
||||
|
||||
private final FilterCreaturePermanent filter;
|
||||
private final boolean onlyControlled;
|
||||
|
||||
public CombatDamageByToughnessEffect(FilterCreaturePermanent filter, boolean onlyControlled) {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Detriment);
|
||||
this.filter = filter;
|
||||
this.onlyControlled = onlyControlled;
|
||||
staticText = "Each " + filter.getMessage() + (onlyControlled ? " you control" : "") +
|
||||
" assigns combat damage equal to its toughness rather than its power";
|
||||
}
|
||||
|
||||
public CombatDamageByToughnessEffect(final CombatDamageByToughnessEffect effect) {
|
||||
super(effect);
|
||||
this.filter = effect.filter;
|
||||
this.onlyControlled = effect.onlyControlled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CombatDamageByToughnessEffect copy() {
|
||||
return new CombatDamageByToughnessEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
// Change the rule
|
||||
FilterCreaturePermanent filterPermanent = filter.copy();
|
||||
if (onlyControlled) {
|
||||
filterPermanent.add(new ControllerIdPredicate(source.getControllerId()));
|
||||
}
|
||||
game.getCombat().setUseToughnessForDamage(true);
|
||||
game.getCombat().addUseToughnessForDamageFilter(filterPermanent);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLayer(Layer layer) {
|
||||
return layer == Layer.RulesEffects;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue