mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
Refactor - remove duplicate DamageCantBePreventedEffect classes
This commit is contained in:
parent
541c9727ff
commit
d4f8224ee9
5 changed files with 56 additions and 147 deletions
|
@ -27,23 +27,20 @@
|
||||||
*/
|
*/
|
||||||
package mage.sets.fatereforged;
|
package mage.sets.fatereforged;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.Ability;
|
|
||||||
import mage.abilities.condition.LockedInCondition;
|
import mage.abilities.condition.LockedInCondition;
|
||||||
import mage.abilities.condition.common.FerociousCondition;
|
import mage.abilities.condition.common.FerociousCondition;
|
||||||
import mage.abilities.decorator.ConditionalContinuousRuleModifyingEffect;
|
import mage.abilities.decorator.ConditionalContinuousRuleModifyingEffect;
|
||||||
import mage.abilities.effects.ContinuousRuleModifyingEffect;
|
import mage.abilities.effects.ContinuousRuleModifyingEffect;
|
||||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
|
||||||
import mage.abilities.effects.common.DamageTargetEffect;
|
import mage.abilities.effects.common.DamageTargetEffect;
|
||||||
|
import mage.abilities.effects.common.continuous.DamageCantBePreventedEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.events.GameEvent;
|
|
||||||
import mage.target.common.TargetCreatureOrPlayer;
|
import mage.target.common.TargetCreatureOrPlayer;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author jeffwadsworth
|
* @author jeffwadsworth
|
||||||
|
@ -55,7 +52,7 @@ public class WildSlash extends CardImpl {
|
||||||
this.expansionSetCode = "FRF";
|
this.expansionSetCode = "FRF";
|
||||||
|
|
||||||
// <i>Ferocious</i> If you control a creature with power 4 or greater, damage can't be prevented this turn.
|
// <i>Ferocious</i> If you control a creature with power 4 or greater, damage can't be prevented this turn.
|
||||||
ContinuousRuleModifyingEffect effect = new DamageCantBePreventedEffect();
|
ContinuousRuleModifyingEffect effect = new DamageCantBePreventedEffect(Duration.EndOfTurn, "damage can't be prevented this turn", false, false);
|
||||||
effect.setText("<i>Ferocious</i> — If you control a creature with power 4 or greater, damage can't be prevented this turn.<br>");
|
effect.setText("<i>Ferocious</i> — If you control a creature with power 4 or greater, damage can't be prevented this turn.<br>");
|
||||||
this.getSpellAbility().addEffect(new ConditionalContinuousRuleModifyingEffect(effect,
|
this.getSpellAbility().addEffect(new ConditionalContinuousRuleModifyingEffect(effect,
|
||||||
new LockedInCondition(FerociousCondition.getInstance())));
|
new LockedInCondition(FerociousCondition.getInstance())));
|
||||||
|
@ -75,30 +72,3 @@ public class WildSlash extends CardImpl {
|
||||||
return new WildSlash(this);
|
return new WildSlash(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DamageCantBePreventedEffect extends ContinuousRuleModifyingEffectImpl {
|
|
||||||
|
|
||||||
public DamageCantBePreventedEffect() {
|
|
||||||
super(Duration.EndOfTurn, Outcome.Benefit, false, false);
|
|
||||||
staticText = "damage can't be prevented this turn";
|
|
||||||
}
|
|
||||||
|
|
||||||
public DamageCantBePreventedEffect(final DamageCantBePreventedEffect effect) {
|
|
||||||
super(effect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DamageCantBePreventedEffect copy() {
|
|
||||||
return new DamageCantBePreventedEffect(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checksEventType(GameEvent event, Game game) {
|
|
||||||
return event.getType() == GameEvent.EventType.PREVENT_DAMAGE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -27,21 +27,17 @@
|
||||||
*/
|
*/
|
||||||
package mage.sets.gatecrash;
|
package mage.sets.gatecrash;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import mage.constants.CardType;
|
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.Rarity;
|
|
||||||
import mage.abilities.Ability;
|
|
||||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
|
||||||
import mage.abilities.effects.common.DamageTargetEffect;
|
import mage.abilities.effects.common.DamageTargetEffect;
|
||||||
import mage.abilities.effects.common.continuous.CantGainLifeAllEffect;
|
import mage.abilities.effects.common.continuous.CantGainLifeAllEffect;
|
||||||
|
import mage.abilities.effects.common.continuous.DamageCantBePreventedEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
import mage.constants.CardType;
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
import mage.game.Game;
|
import mage.constants.Rarity;
|
||||||
import mage.game.events.GameEvent;
|
|
||||||
import mage.target.TargetPlayer;
|
import mage.target.TargetPlayer;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
|
@ -55,7 +51,7 @@ public class Skullcrack extends CardImpl {
|
||||||
|
|
||||||
// Players can't gain life this turn. Damage can't be prevented this turn. Skullcrack deals 3 damage to target player.
|
// Players can't gain life this turn. Damage can't be prevented this turn. Skullcrack deals 3 damage to target player.
|
||||||
this.getSpellAbility().addEffect(new CantGainLifeAllEffect(Duration.EndOfTurn));
|
this.getSpellAbility().addEffect(new CantGainLifeAllEffect(Duration.EndOfTurn));
|
||||||
this.getSpellAbility().addEffect(new DamageCantBePreventedEffect());
|
this.getSpellAbility().addEffect(new DamageCantBePreventedEffect(Duration.EndOfTurn, "Damage can't be prevented this turn", true, false));
|
||||||
this.getSpellAbility().addEffect(new DamageTargetEffect(3));
|
this.getSpellAbility().addEffect(new DamageTargetEffect(3));
|
||||||
this.getSpellAbility().addTarget(new TargetPlayer());
|
this.getSpellAbility().addTarget(new TargetPlayer());
|
||||||
|
|
||||||
|
@ -70,35 +66,3 @@ public class Skullcrack extends CardImpl {
|
||||||
return new Skullcrack(this);
|
return new Skullcrack(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DamageCantBePreventedEffect extends ContinuousRuleModifyingEffectImpl {
|
|
||||||
|
|
||||||
public DamageCantBePreventedEffect() {
|
|
||||||
super(Duration.EndOfTurn, Outcome.Benefit);
|
|
||||||
staticText = "Damage can't be prevented this turn";
|
|
||||||
}
|
|
||||||
|
|
||||||
public DamageCantBePreventedEffect(final DamageCantBePreventedEffect effect) {
|
|
||||||
super(effect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DamageCantBePreventedEffect copy() {
|
|
||||||
return new DamageCantBePreventedEffect(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Game game, Ability source) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checksEventType(GameEvent event, Game game) {
|
|
||||||
return event.getType() == GameEvent.EventType.PREVENT_DAMAGE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -27,19 +27,16 @@
|
||||||
*/
|
*/
|
||||||
package mage.sets.judgment;
|
package mage.sets.judgment;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.Ability;
|
|
||||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
import mage.abilities.effects.common.continuous.DamageCantBePreventedEffect;
|
||||||
import mage.abilities.keyword.FlashbackAbility;
|
import mage.abilities.keyword.FlashbackAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.constants.TimingRule;
|
import mage.constants.TimingRule;
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.events.GameEvent;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -53,7 +50,7 @@ public class FlaringPain extends CardImpl {
|
||||||
|
|
||||||
|
|
||||||
// Damage can't be prevented this turn.
|
// Damage can't be prevented this turn.
|
||||||
this.getSpellAbility().addEffect(new DamageCantBePreventedEffect());
|
this.getSpellAbility().addEffect(new DamageCantBePreventedEffect(Duration.EndOfTurn, "Damage can't be prevented this turn", false, false));
|
||||||
// Flashback {R}
|
// Flashback {R}
|
||||||
this.addAbility(new FlashbackAbility(new ManaCostsImpl("{R}"), TimingRule.INSTANT));
|
this.addAbility(new FlashbackAbility(new ManaCostsImpl("{R}"), TimingRule.INSTANT));
|
||||||
}
|
}
|
||||||
|
@ -67,33 +64,3 @@ public class FlaringPain extends CardImpl {
|
||||||
return new FlaringPain(this);
|
return new FlaringPain(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DamageCantBePreventedEffect extends ContinuousRuleModifyingEffectImpl {
|
|
||||||
|
|
||||||
public DamageCantBePreventedEffect() {
|
|
||||||
super(Duration.EndOfTurn, Outcome.Benefit, false, false);
|
|
||||||
staticText = "Damage can't be prevented this turn";
|
|
||||||
}
|
|
||||||
|
|
||||||
public DamageCantBePreventedEffect(final DamageCantBePreventedEffect effect) {
|
|
||||||
super(effect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DamageCantBePreventedEffect copy() {
|
|
||||||
return new DamageCantBePreventedEffect(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Game game, Ability source) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
|
||||||
if (event.getType().equals(GameEvent.EventType.PREVENT_DAMAGE)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -30,9 +30,9 @@ package mage.sets.shadowmoor;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
|
||||||
import mage.abilities.effects.ReplacementEffectImpl;
|
import mage.abilities.effects.ReplacementEffectImpl;
|
||||||
import mage.abilities.effects.common.continuous.CantGainLifeAllEffect;
|
import mage.abilities.effects.common.continuous.CantGainLifeAllEffect;
|
||||||
|
import mage.abilities.effects.common.continuous.DamageCantBePreventedEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
|
@ -60,7 +60,8 @@ public class EverlastingTorment extends CardImpl {
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantGainLifeAllEffect()));
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantGainLifeAllEffect()));
|
||||||
|
|
||||||
// Damage can't be prevented.
|
// Damage can't be prevented.
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new DamageCantBePreventedEffect(Duration.WhileOnBattlefield)));
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
|
||||||
|
new DamageCantBePreventedEffect(Duration.WhileOnBattlefield, "Damage can't be prevented", true, false)));
|
||||||
|
|
||||||
// All damage is dealt as though its source had wither.
|
// All damage is dealt as though its source had wither.
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new DamageDealtAsIfSourceHadWitherEffect()));
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new DamageDealtAsIfSourceHadWitherEffect()));
|
||||||
|
@ -77,38 +78,6 @@ public class EverlastingTorment extends CardImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DamageCantBePreventedEffect extends ContinuousRuleModifyingEffectImpl {
|
|
||||||
|
|
||||||
public DamageCantBePreventedEffect(Duration duration) {
|
|
||||||
super(duration, Outcome.Benefit);
|
|
||||||
staticText = "Damage can't be prevented";
|
|
||||||
}
|
|
||||||
|
|
||||||
public DamageCantBePreventedEffect(final DamageCantBePreventedEffect effect) {
|
|
||||||
super(effect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DamageCantBePreventedEffect copy() {
|
|
||||||
return new DamageCantBePreventedEffect(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Game game, Ability source) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checksEventType(GameEvent event, Game game) {
|
|
||||||
return event.getType().equals(GameEvent.EventType.PREVENT_DAMAGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class DamageDealtAsIfSourceHadWitherEffect extends ReplacementEffectImpl {
|
class DamageDealtAsIfSourceHadWitherEffect extends ReplacementEffectImpl {
|
||||||
|
|
||||||
public DamageDealtAsIfSourceHadWitherEffect() {
|
public DamageDealtAsIfSourceHadWitherEffect() {
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
package mage.abilities.effects.common.continuous;
|
||||||
|
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||||
|
import mage.constants.Duration;
|
||||||
|
import mage.constants.Outcome;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.events.GameEvent;
|
||||||
|
|
||||||
|
public class DamageCantBePreventedEffect extends ContinuousRuleModifyingEffectImpl {
|
||||||
|
public DamageCantBePreventedEffect(Duration duration, String staticText, boolean messageToUser, boolean messageToLog) {
|
||||||
|
super(duration, Outcome.Benefit, messageToUser, messageToLog);
|
||||||
|
this.staticText = staticText;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DamageCantBePreventedEffect(final DamageCantBePreventedEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DamageCantBePreventedEffect copy() {
|
||||||
|
return new DamageCantBePreventedEffect(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checksEventType(GameEvent event, Game game) {
|
||||||
|
return event.getType().equals(GameEvent.EventType.PREVENT_DAMAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue