mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
Reworked PreventAllDamageToControllerEffect to be more generic.
This commit is contained in:
parent
859b169b3d
commit
db4644cbc1
16 changed files with 148 additions and 567 deletions
|
@ -32,20 +32,18 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.abilities.effects.PreventionEffectImpl;
|
||||
import mage.abilities.effects.common.PreventDamageToControllerEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.target.TargetPlayer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author KholdFuzion
|
||||
|
||||
*
|
||||
*/
|
||||
public class Conservator extends CardImpl {
|
||||
|
||||
|
@ -53,7 +51,7 @@ public class Conservator extends CardImpl {
|
|||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}");
|
||||
|
||||
// {3}, {tap}: Prevent the next 2 damage that would be dealt to you this turn.
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ConservatorEffect(), new GenericManaCost(3));
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new PreventDamageToControllerEffect(Duration.EndOfTurn, 2), new GenericManaCost(3));
|
||||
ability.addTarget(new TargetPlayer());
|
||||
ability.addCost(new TapSourceCost());
|
||||
this.addAbility(ability);
|
||||
|
@ -68,56 +66,3 @@ public class Conservator extends CardImpl {
|
|||
return new Conservator(this);
|
||||
}
|
||||
}
|
||||
|
||||
class ConservatorEffect extends PreventionEffectImpl {
|
||||
|
||||
private int amount = 2;
|
||||
|
||||
public ConservatorEffect() {
|
||||
super(Duration.EndOfTurn);
|
||||
this.staticText = "Prevent the next 2 damage that would be dealt to you this turn";
|
||||
}
|
||||
|
||||
public ConservatorEffect(final ConservatorEffect effect) {
|
||||
super(effect);
|
||||
this.amount = effect.amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConservatorEffect copy() {
|
||||
return new ConservatorEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE,
|
||||
source.getControllerId(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
||||
if (!game.replaceEvent(preventEvent)) {
|
||||
int damage = event.getAmount();
|
||||
if (damage >= this.amount) {
|
||||
event.setAmount(damage - this.amount);
|
||||
damage = this.amount;
|
||||
this.used = true;
|
||||
} else {
|
||||
event.setAmount(0);
|
||||
this.amount -= damage;
|
||||
}
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE,
|
||||
source.getControllerId(), source.getSourceId(), source.getControllerId(), damage));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (!this.used && super.applies(event, source, game) && event.getTargetId().equals(source.getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -29,18 +29,15 @@ package mage.cards.d;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.PreventionEffectImpl;
|
||||
import mage.abilities.effects.common.PreventDamageToControllerEffect;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -57,8 +54,8 @@ public class DecoratedGriffin extends CardImpl {
|
|||
|
||||
// Flying
|
||||
this.addAbility(FlyingAbility.getInstance());
|
||||
// {1}{W}: Prevent the next 1 damage that would be dealt to you this turn.
|
||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new DecoratedGriffinPreventEffect(), new ManaCostsImpl("{1}{W}")));
|
||||
// {1}{W}: Prevent the next 1 combat damage that would be dealt to you this turn.
|
||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new PreventDamageToControllerEffect(Duration.EndOfTurn, true, true, 1), new ManaCostsImpl("{1}{W}")));
|
||||
}
|
||||
|
||||
public DecoratedGriffin(final DecoratedGriffin card) {
|
||||
|
@ -70,33 +67,3 @@ public class DecoratedGriffin extends CardImpl {
|
|||
return new DecoratedGriffin(this);
|
||||
}
|
||||
}
|
||||
|
||||
class DecoratedGriffinPreventEffect extends PreventionEffectImpl {
|
||||
|
||||
public DecoratedGriffinPreventEffect() {
|
||||
super(Duration.EndOfTurn, 1, false, true);
|
||||
this.staticText = "Prevent the next 1 damage that would be dealt to you this turn";
|
||||
}
|
||||
|
||||
public DecoratedGriffinPreventEffect(final DecoratedGriffinPreventEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DecoratedGriffinPreventEffect copy() {
|
||||
return new DecoratedGriffinPreventEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (super.applies(event, source, game) && event.getTargetId().equals(source.getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,16 +28,12 @@
|
|||
package mage.cards.d;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.PreventionEffectImpl;
|
||||
import mage.abilities.effects.common.PopulateEffect;
|
||||
import mage.abilities.effects.common.PreventDamageToControllerEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.DamageEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -48,10 +44,9 @@ public class DruidsDeliverance extends CardImpl {
|
|||
public DruidsDeliverance(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{G}");
|
||||
|
||||
|
||||
// Prevent all combat damage that would be dealt to you this turn. Populate.
|
||||
// (Create a token that's a copy of a creature token you control.)
|
||||
this.getSpellAbility().addEffect(new DruidsDeliverancePreventCombatDamageEffect());
|
||||
this.getSpellAbility().addEffect(new PreventDamageToControllerEffect(Duration.EndOfTurn, true, false, Integer.MAX_VALUE));
|
||||
this.getSpellAbility().addEffect(new PopulateEffect());
|
||||
}
|
||||
|
||||
|
@ -64,49 +59,3 @@ public class DruidsDeliverance extends CardImpl {
|
|||
return new DruidsDeliverance(this);
|
||||
}
|
||||
}
|
||||
|
||||
class DruidsDeliverancePreventCombatDamageEffect extends PreventionEffectImpl {
|
||||
|
||||
public DruidsDeliverancePreventCombatDamageEffect() {
|
||||
super(Duration.EndOfTurn);
|
||||
staticText = "Prevent all combat damage that would be dealt to you this turn";
|
||||
}
|
||||
|
||||
public DruidsDeliverancePreventCombatDamageEffect(final DruidsDeliverancePreventCombatDamageEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DruidsDeliverancePreventCombatDamageEffect copy() {
|
||||
return new DruidsDeliverancePreventCombatDamageEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
||||
if (!game.replaceEvent(preventEvent)) {
|
||||
int damage = event.getAmount();
|
||||
event.setAmount(0);
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE, source.getFirstTarget(), source.getSourceId(), source.getControllerId(), damage));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (super.applies(event, source, game)) {
|
||||
DamageEvent damageEvent = (DamageEvent) event;
|
||||
if (event.getTargetId().equals(source.getControllerId()) && damageEvent.isCombatDamage()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -28,21 +28,18 @@
|
|||
package mage.cards.e;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.costs.mana.ColoredManaCost;
|
||||
import mage.abilities.effects.common.PreventDamageToControllerEffect;
|
||||
import mage.abilities.effects.common.continuous.BoostTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.ColoredManaSymbol;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.costs.mana.ColoredManaCost;
|
||||
import mage.abilities.effects.PreventionEffectImpl;
|
||||
import mage.abilities.effects.common.continuous.BoostTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
/**
|
||||
|
@ -60,7 +57,7 @@ public class EsperBattlemage extends CardImpl {
|
|||
this.toughness = new MageInt(2);
|
||||
// {W}, {tap}: Prevent the next 2 damage that would be dealt to you this turn.
|
||||
SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
|
||||
new EsperBattlemageEffect(),
|
||||
new PreventDamageToControllerEffect(Duration.EndOfTurn, 2),
|
||||
new ColoredManaCost(ColoredManaSymbol.W));
|
||||
ability.addCost(new TapSourceCost());
|
||||
this.addAbility(ability);
|
||||
|
@ -82,56 +79,3 @@ public class EsperBattlemage extends CardImpl {
|
|||
return new EsperBattlemage(this);
|
||||
}
|
||||
}
|
||||
|
||||
class EsperBattlemageEffect extends PreventionEffectImpl {
|
||||
|
||||
private int amount = 2;
|
||||
|
||||
public EsperBattlemageEffect() {
|
||||
super(Duration.EndOfTurn);
|
||||
this.staticText = "Prevent the next 2 damage that would be dealt to you this turn";
|
||||
}
|
||||
|
||||
public EsperBattlemageEffect(final EsperBattlemageEffect effect) {
|
||||
super(effect);
|
||||
this.amount = effect.amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EsperBattlemageEffect copy() {
|
||||
return new EsperBattlemageEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE,
|
||||
source.getControllerId(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
||||
if (!game.replaceEvent(preventEvent)) {
|
||||
int damage = event.getAmount();
|
||||
if (damage >= this.amount) {
|
||||
event.setAmount(damage - this.amount);
|
||||
damage = this.amount;
|
||||
this.used = true;
|
||||
} else {
|
||||
event.setAmount(0);
|
||||
this.amount -= damage;
|
||||
}
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE,
|
||||
source.getControllerId(), source.getSourceId(), source.getControllerId(), damage));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (!this.used && super.applies(event, source, game) && event.getTargetId().equals(source.getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ import java.util.UUID;
|
|||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.common.PayLifeCost;
|
||||
import mage.abilities.effects.common.PreventAllDamageToControllerEffect;
|
||||
import mage.abilities.effects.common.PreventDamageToControllerEffect;
|
||||
import mage.abilities.effects.common.SacrificeControllerEffect;
|
||||
import mage.abilities.effects.common.combat.CantAttackAnyPlayerAllEffect;
|
||||
import mage.abilities.keyword.CumulativeUpkeepAbility;
|
||||
|
@ -63,7 +63,7 @@ public class GlacialChasm extends CardImpl {
|
|||
filter.add(new ControllerPredicate(TargetController.YOU));
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackAnyPlayerAllEffect(Duration.WhileOnBattlefield, filter)));
|
||||
// Prevent all damage that would be dealt to you.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PreventAllDamageToControllerEffect(Duration.WhileOnBattlefield)));
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PreventDamageToControllerEffect(Duration.WhileOnBattlefield)));
|
||||
}
|
||||
|
||||
public GlacialChasm(final GlacialChasm card) {
|
||||
|
|
|
@ -28,11 +28,10 @@
|
|||
package mage.cards.p;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BecomesTappedTriggeredAbility;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.RemoveCountersSourceCost;
|
||||
import mage.abilities.effects.PreventionEffectImpl;
|
||||
import mage.abilities.effects.common.PreventDamageToControllerEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
|
@ -43,8 +42,6 @@ import mage.constants.Zone;
|
|||
import mage.counters.CounterType;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.permanent.ControllerPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -65,7 +62,9 @@ public class PalliationAccord extends CardImpl {
|
|||
this.addAbility(new BecomesTappedTriggeredAbility(new AddCountersSourceEffect(CounterType.SHIELD.createInstance()), false, filter));
|
||||
|
||||
// Remove a shield counter from Palliation Accord: Prevent the next 1 damage that would be dealt to you this turn.
|
||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new PalliationAccordPreventionEffect(), new RemoveCountersSourceCost(CounterType.SHIELD.createInstance())));
|
||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD,
|
||||
new PreventDamageToControllerEffect(Duration.EndOfTurn, 1),
|
||||
new RemoveCountersSourceCost(CounterType.SHIELD.createInstance())));
|
||||
}
|
||||
|
||||
public PalliationAccord(final PalliationAccord card) {
|
||||
|
@ -77,49 +76,3 @@ public class PalliationAccord extends CardImpl {
|
|||
return new PalliationAccord(this);
|
||||
}
|
||||
}
|
||||
|
||||
class PalliationAccordPreventionEffect extends PreventionEffectImpl {
|
||||
|
||||
public PalliationAccordPreventionEffect() {
|
||||
super(Duration.EndOfTurn);
|
||||
this.staticText = "Prevent the next 1 damage that would be dealt to you this turn";
|
||||
}
|
||||
|
||||
public PalliationAccordPreventionEffect(final PalliationAccordPreventionEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PalliationAccordPreventionEffect copy() {
|
||||
return new PalliationAccordPreventionEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE,
|
||||
source.getControllerId(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
||||
if (!game.replaceEvent(preventEvent)) {
|
||||
int damage = event.getAmount();
|
||||
if (damage > 0) {
|
||||
event.setAmount(damage - 1);
|
||||
this.used = true;
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE,
|
||||
source.getControllerId(), source.getSourceId(), source.getControllerId(), 1));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (!this.used && super.applies(event, source, game) && event.getTargetId().equals(source.getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,19 +28,16 @@
|
|||
package mage.cards.r;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.effects.PreventionEffectImpl;
|
||||
import mage.abilities.effects.common.PreventDamageToControllerEffect;
|
||||
import mage.abilities.keyword.DefenderAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Zone;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -57,7 +54,7 @@ public class ReinforcedBulwark extends CardImpl {
|
|||
// Defender
|
||||
this.addAbility(DefenderAbility.getInstance());
|
||||
// {tap}: Prevent the next 1 damage that would be dealt to you this turn.
|
||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new ReinforcedBulwarkEffect(), new TapSourceCost()));
|
||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new PreventDamageToControllerEffect(Duration.EndOfTurn, 1), new TapSourceCost()));
|
||||
}
|
||||
|
||||
public ReinforcedBulwark(final ReinforcedBulwark card) {
|
||||
|
@ -69,49 +66,3 @@ public class ReinforcedBulwark extends CardImpl {
|
|||
return new ReinforcedBulwark(this);
|
||||
}
|
||||
}
|
||||
|
||||
class ReinforcedBulwarkEffect extends PreventionEffectImpl {
|
||||
|
||||
public ReinforcedBulwarkEffect() {
|
||||
super(Duration.EndOfTurn);
|
||||
this.staticText = "Prevent the next 1 damage that would be dealt to you this turn";
|
||||
}
|
||||
|
||||
public ReinforcedBulwarkEffect(final ReinforcedBulwarkEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReinforcedBulwarkEffect copy() {
|
||||
return new ReinforcedBulwarkEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE,
|
||||
source.getControllerId(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
||||
if (!game.replaceEvent(preventEvent)) {
|
||||
int damage = event.getAmount();
|
||||
if (damage > 0) {
|
||||
event.setAmount(damage - 1);
|
||||
this.used = true;
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE,
|
||||
source.getControllerId(), source.getSourceId(), source.getControllerId(), 1));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (!this.used && super.applies(event, source, game) && event.getTargetId().equals(source.getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ import mage.constants.CardType;
|
|||
import mage.constants.Duration;
|
||||
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
|
||||
import mage.abilities.effects.common.GainLifeEffect;
|
||||
import mage.abilities.effects.common.PreventAllDamageToControllerEffect;
|
||||
import mage.abilities.effects.common.PreventDamageToControllerEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.TargetController;
|
||||
|
@ -60,7 +60,7 @@ public class RiotControl extends CardImpl {
|
|||
|
||||
// Gain 1 life for each creature your opponents control. Prevent all damage that would be dealt to you this turn.
|
||||
this.getSpellAbility().addEffect(new GainLifeEffect(new PermanentsOnBattlefieldCount(filter)));
|
||||
this.getSpellAbility().addEffect(new PreventAllDamageToControllerEffect(Duration.EndOfTurn));
|
||||
this.getSpellAbility().addEffect(new PreventDamageToControllerEffect(Duration.EndOfTurn));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -25,29 +25,26 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.cards.s;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.AttachmentType;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.effects.PreventionEffectImpl;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.abilities.effects.common.CreateTokenEffect;
|
||||
import mage.abilities.effects.common.PreventDamageToControllerEffect;
|
||||
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
||||
import mage.abilities.keyword.EnchantAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.constants.AttachmentType;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.permanent.token.KnightToken;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetLandPermanent;
|
||||
|
@ -76,7 +73,7 @@ public class SecurityBlockade extends CardImpl {
|
|||
this.addAbility(new EntersBattlefieldTriggeredAbility(new CreateTokenEffect(new KnightToken())));
|
||||
|
||||
// Enchanted land has "{T}: Prevent the next 1 damage that would be dealt to you this turn."
|
||||
ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new SecurityBlockadePreventionEffect(), new TapSourceCost());
|
||||
ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new PreventDamageToControllerEffect(Duration.EndOfTurn, 1), new TapSourceCost());
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(ability, AttachmentType.AURA, Duration.WhileOnBattlefield, rule)));
|
||||
}
|
||||
|
||||
|
@ -90,48 +87,3 @@ public class SecurityBlockade extends CardImpl {
|
|||
}
|
||||
|
||||
}
|
||||
class SecurityBlockadePreventionEffect extends PreventionEffectImpl {
|
||||
|
||||
public SecurityBlockadePreventionEffect() {
|
||||
super(Duration.EndOfTurn);
|
||||
this.staticText = "Prevent the next 1 damage that would be dealt to you this turn";
|
||||
}
|
||||
|
||||
public SecurityBlockadePreventionEffect(final SecurityBlockadePreventionEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecurityBlockadePreventionEffect copy() {
|
||||
return new SecurityBlockadePreventionEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE,
|
||||
source.getControllerId(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
||||
if (!game.replaceEvent(preventEvent)) {
|
||||
int damage = event.getAmount();
|
||||
if (damage > 0) {
|
||||
event.setAmount(damage - 1);
|
||||
this.used = true;
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE,
|
||||
source.getControllerId(), source.getSourceId(), source.getControllerId(), 1));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (!this.used && super.applies(event, source, game) && event.getTargetId().equals(source.getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,17 +28,14 @@
|
|||
package mage.cards.s;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.abilities.effects.PreventionEffectImpl;
|
||||
import mage.abilities.effects.common.PreventDamageToControllerEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -50,7 +47,7 @@ public class ShieldOfTheAges extends CardImpl {
|
|||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}");
|
||||
|
||||
// {2}: Prevent the next 1 damage that would be dealt to you this turn.
|
||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new ShieldOfTheAgesEffect(), new GenericManaCost(2)));
|
||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new PreventDamageToControllerEffect(Duration.EndOfTurn, 1), new GenericManaCost(2)));
|
||||
}
|
||||
|
||||
public ShieldOfTheAges(final ShieldOfTheAges card) {
|
||||
|
@ -62,49 +59,3 @@ public class ShieldOfTheAges extends CardImpl {
|
|||
return new ShieldOfTheAges(this);
|
||||
}
|
||||
}
|
||||
|
||||
class ShieldOfTheAgesEffect extends PreventionEffectImpl {
|
||||
|
||||
public ShieldOfTheAgesEffect() {
|
||||
super(Duration.EndOfTurn);
|
||||
this.staticText = "Prevent the next 1 damage that would be dealt to you this turn";
|
||||
}
|
||||
|
||||
public ShieldOfTheAgesEffect(final ShieldOfTheAgesEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShieldOfTheAgesEffect copy() {
|
||||
return new ShieldOfTheAgesEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE,
|
||||
source.getControllerId(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
||||
if (!game.replaceEvent(preventEvent)) {
|
||||
int damage = event.getAmount();
|
||||
if (damage > 0) {
|
||||
event.setAmount(damage - 1);
|
||||
this.used = true;
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE,
|
||||
source.getControllerId(), source.getSourceId(), source.getControllerId(), 1));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (!this.used && super.applies(event, source, game) && event.getTargetId().equals(source.getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -31,7 +31,7 @@ import java.util.UUID;
|
|||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.common.DiscardTargetCost;
|
||||
import mage.abilities.effects.common.PreventAllDamageToControllerEffect;
|
||||
import mage.abilities.effects.common.PreventDamageToControllerEffect;
|
||||
import mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect;
|
||||
import mage.abilities.effects.common.SkipDrawStepEffect;
|
||||
import mage.abilities.effects.common.continuous.GainAbilityControllerEffect;
|
||||
|
@ -63,7 +63,7 @@ public class SolitaryConfinement extends CardImpl {
|
|||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityControllerEffect(ShroudAbility.getInstance())));
|
||||
|
||||
// Prevent all damage that would be dealt to you.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PreventAllDamageToControllerEffect(Duration.WhileOnBattlefield)));
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PreventDamageToControllerEffect(Duration.WhileOnBattlefield)));
|
||||
}
|
||||
|
||||
public SolitaryConfinement(final SolitaryConfinement card) {
|
||||
|
|
|
@ -36,7 +36,7 @@ import mage.abilities.common.SimpleStaticAbility;
|
|||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.decorator.ConditionalReplacementEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.PreventAllDamageToControllerEffect;
|
||||
import mage.abilities.effects.common.PreventDamageToControllerEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
|
@ -57,7 +57,7 @@ public class SpiritOfResistance extends CardImpl {
|
|||
|
||||
// As long as you control a permanent of each color, prevent all damage that would be dealt to you.
|
||||
Effect effect = new ConditionalReplacementEffect(
|
||||
new PreventAllDamageToControllerEffect(Duration.WhileOnBattlefield),
|
||||
new PreventDamageToControllerEffect(Duration.WhileOnBattlefield),
|
||||
SpiritOfResistanceCondition.getInstance());
|
||||
effect.setText("As long as you control a permanent of each color, prevent all damage that would be dealt to you.");
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
|
||||
|
|
|
@ -33,7 +33,7 @@ import mage.abilities.TriggeredAbilityImpl;
|
|||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.ExileFromTopOfLibraryCost;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.PreventionEffectImpl;
|
||||
import mage.abilities.effects.common.PreventDamageToControllerEffect;
|
||||
import mage.abilities.keyword.CumulativeUpkeepAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
|
@ -64,7 +64,7 @@ public class ThoughtLash extends CardImpl {
|
|||
this.addAbility(new ThoughtLashTriggeredAbility());
|
||||
|
||||
// Exile the top card of your library: Prevent the next 1 damage that would be dealt to you this turn.
|
||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new ThoughtLashPreventionEffect(), new ExileFromTopOfLibraryCost(1)));
|
||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new PreventDamageToControllerEffect(Duration.EndOfTurn, 1), new ExileFromTopOfLibraryCost(1)));
|
||||
}
|
||||
|
||||
public ThoughtLash(final ThoughtLash card) {
|
||||
|
@ -136,46 +136,3 @@ class ThoughtLashExileLibraryEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class ThoughtLashPreventionEffect extends PreventionEffectImpl {
|
||||
|
||||
ThoughtLashPreventionEffect() {
|
||||
super(Duration.EndOfTurn);
|
||||
this.staticText = "Prevent the next 1 damage that would be dealt to you this turn";
|
||||
}
|
||||
|
||||
ThoughtLashPreventionEffect(final ThoughtLashPreventionEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThoughtLashPreventionEffect copy() {
|
||||
return new ThoughtLashPreventionEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE,
|
||||
source.getControllerId(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
||||
if (!game.replaceEvent(preventEvent)) {
|
||||
int damage = event.getAmount();
|
||||
if (damage > 0) {
|
||||
event.setAmount(damage - 1);
|
||||
this.used = true;
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE,
|
||||
source.getControllerId(), source.getSourceId(), source.getControllerId(), 1));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
return !this.used && super.applies(event, source, game) && event.getTargetId().equals(source.getControllerId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,21 +25,21 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.cards.v;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.PreventionEffectImpl;
|
||||
import mage.abilities.effects.PreventionEffectData;
|
||||
import mage.abilities.effects.common.PreventDamageToControllerEffect;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.players.Player;
|
||||
|
@ -58,7 +58,10 @@ public class VengefulArchon extends CardImpl {
|
|||
this.power = new MageInt(7);
|
||||
this.toughness = new MageInt(7);
|
||||
|
||||
// Flying
|
||||
this.addAbility(FlyingAbility.getInstance());
|
||||
|
||||
// {X}: Prevent the next X damage that would be dealt to you this turn. If damage is prevented this way, Vengeful Archon deals that much damage to target player.
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new VengefulArchonEffect(), new ManaCostsImpl("{X}"));
|
||||
ability.addTarget(new TargetPlayer());
|
||||
this.addAbility(ability);
|
||||
|
@ -75,18 +78,15 @@ public class VengefulArchon extends CardImpl {
|
|||
|
||||
}
|
||||
|
||||
class VengefulArchonEffect extends PreventionEffectImpl {
|
||||
|
||||
protected int amount = 0;
|
||||
class VengefulArchonEffect extends PreventDamageToControllerEffect {
|
||||
|
||||
public VengefulArchonEffect() {
|
||||
super(Duration.EndOfTurn);
|
||||
super(Duration.EndOfTurn, 0, false, true, new ManacostVariableValue());
|
||||
staticText = "Prevent the next X damage that would be dealt to you this turn. If damage is prevented this way, {this} deals that much damage to target player";
|
||||
}
|
||||
|
||||
public VengefulArchonEffect(final VengefulArchonEffect effect) {
|
||||
super(effect);
|
||||
this.amount = effect.amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -95,46 +95,16 @@ class VengefulArchonEffect extends PreventionEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
amount = source.getManaCostsToPay().getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getControllerId(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
||||
if (!game.replaceEvent(preventEvent)) {
|
||||
protected PreventionEffectData preventDamageAction(GameEvent event, Ability source, Game game) {
|
||||
PreventionEffectData preventionEffectData = super.preventDamageAction(event, source, game);
|
||||
int damage = preventionEffectData.getPreventedDamage();
|
||||
if (damage > 0) {
|
||||
Player player = game.getPlayer(source.getFirstTarget());
|
||||
if (player != null) {
|
||||
int damage = event.getAmount();
|
||||
if (event.getAmount() >= this.amount) {
|
||||
event.setAmount(damage - this.amount);
|
||||
damage = this.amount;
|
||||
this.used = true;
|
||||
} else {
|
||||
event.setAmount(0);
|
||||
this.amount -= damage;
|
||||
}
|
||||
|
||||
player.damage(damage, source.getSourceId(), game, false, true);
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE,
|
||||
source.getControllerId(), source.getSourceId(), source.getControllerId(), damage));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (!this.used && super.applies(event, source, game) && event.getTargetId().equals(source.getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return preventionEffectData;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,24 +25,24 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.EffectType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.abilities.Ability;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.DamageEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public abstract class PreventionEffectImpl extends ReplacementEffectImpl implements PreventionEffect {
|
||||
|
||||
protected DynamicValue amountToPreventDynamic;
|
||||
protected int amountToPrevent;
|
||||
protected final boolean onlyCombat;
|
||||
protected boolean consumable;
|
||||
|
@ -54,10 +54,25 @@ public abstract class PreventionEffectImpl extends ReplacementEffectImpl impleme
|
|||
public PreventionEffectImpl(Duration duration, int amountToPrevent, boolean onlyCombat) {
|
||||
this(duration, amountToPrevent, onlyCombat, true);
|
||||
}
|
||||
|
||||
public PreventionEffectImpl(Duration duration, int amountToPrevent, boolean onlyCombat, boolean consumable) {
|
||||
this(duration, amountToPrevent, onlyCombat, consumable, null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param duration
|
||||
* @param amountToPrevent
|
||||
* @param onlyCombat
|
||||
* @param consumable
|
||||
* @param amountToPreventDynamic if set, on init amountToPrevent is set to
|
||||
* calculated value of amountToPreventDynamic
|
||||
*/
|
||||
public PreventionEffectImpl(Duration duration, int amountToPrevent, boolean onlyCombat, boolean consumable, DynamicValue amountToPreventDynamic) {
|
||||
super(duration, Outcome.PreventDamage);
|
||||
this.effectType = EffectType.PREVENTION;
|
||||
this.amountToPrevent = amountToPrevent;
|
||||
this.amountToPreventDynamic = amountToPreventDynamic;
|
||||
this.onlyCombat = onlyCombat;
|
||||
this.consumable = consumable;
|
||||
}
|
||||
|
@ -65,10 +80,18 @@ public abstract class PreventionEffectImpl extends ReplacementEffectImpl impleme
|
|||
public PreventionEffectImpl(final PreventionEffectImpl effect) {
|
||||
super(effect);
|
||||
this.amountToPrevent = effect.amountToPrevent;
|
||||
this.amountToPreventDynamic = effect.amountToPreventDynamic;
|
||||
this.onlyCombat = effect.onlyCombat;
|
||||
this.consumable = effect.consumable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
if (amountToPreventDynamic != null) {
|
||||
amountToPrevent = amountToPreventDynamic.calculate(game, source, this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
|
|
|
@ -25,35 +25,42 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.constants.Duration;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.PreventionEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class PreventDamageToControllerEffect extends PreventionEffectImpl {
|
||||
|
||||
public PreventDamageToControllerEffect(Duration duration) {
|
||||
this(duration, false, false, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
public class PreventAllDamageToControllerEffect extends PreventionEffectImpl {
|
||||
public PreventDamageToControllerEffect(Duration duration, int amountToPrevent) {
|
||||
this(duration, false, true, amountToPrevent);
|
||||
}
|
||||
|
||||
public PreventAllDamageToControllerEffect(Duration duration) {
|
||||
super(duration, Integer.MAX_VALUE, false);
|
||||
public PreventDamageToControllerEffect(Duration duration, boolean onlyCombat, boolean consumable, int amountToPrevent) {
|
||||
super(duration, amountToPrevent, onlyCombat, consumable, null);
|
||||
}
|
||||
|
||||
public PreventDamageToControllerEffect(Duration duration, boolean onlyCombat, boolean consumable, DynamicValue amountToPreventDynamic) {
|
||||
super(duration, 0, onlyCombat, consumable, amountToPreventDynamic);
|
||||
staticText = setText();
|
||||
}
|
||||
|
||||
public PreventAllDamageToControllerEffect(final PreventAllDamageToControllerEffect effect) {
|
||||
public PreventDamageToControllerEffect(final PreventDamageToControllerEffect effect) {
|
||||
super(effect);
|
||||
staticText = setText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreventAllDamageToControllerEffect copy() {
|
||||
return new PreventAllDamageToControllerEffect(this);
|
||||
public PreventDamageToControllerEffect copy() {
|
||||
return new PreventDamageToControllerEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -68,7 +75,19 @@ public class PreventAllDamageToControllerEffect extends PreventionEffectImpl {
|
|||
}
|
||||
|
||||
private String setText() {
|
||||
StringBuilder sb = new StringBuilder("Prevent all damage that would be dealt to you");
|
||||
// Prevent the next X damage that would be dealt to you this turn
|
||||
StringBuilder sb = new StringBuilder("Prevent ");
|
||||
if (amountToPrevent == Integer.MAX_VALUE) {
|
||||
sb.append("all ");
|
||||
} else if (amountToPreventDynamic != null) {
|
||||
sb.append("the next ").append(amountToPreventDynamic.toString()).append(" ");
|
||||
} else {
|
||||
sb.append("the next ").append(amountToPrevent).append(" ");
|
||||
}
|
||||
if (onlyCombat) {
|
||||
sb.append("combat ");
|
||||
}
|
||||
sb.append("damage that would be dealt to you");
|
||||
if (duration.equals(Duration.EndOfTurn)) {
|
||||
sb.append(" this turn");
|
||||
}
|
Loading…
Reference in a new issue