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,28 +32,26 @@ import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
import mage.abilities.costs.common.TapSourceCost;
|
import mage.abilities.costs.common.TapSourceCost;
|
||||||
import mage.abilities.costs.mana.GenericManaCost;
|
import mage.abilities.costs.mana.GenericManaCost;
|
||||||
import mage.abilities.effects.PreventionEffectImpl;
|
import mage.abilities.effects.common.PreventDamageToControllerEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.events.GameEvent;
|
|
||||||
import mage.target.TargetPlayer;
|
import mage.target.TargetPlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author KholdFuzion
|
* @author KholdFuzion
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public class Conservator extends CardImpl {
|
public class Conservator extends CardImpl {
|
||||||
|
|
||||||
public Conservator(UUID ownerId, CardSetInfo setInfo) {
|
public Conservator(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{4}");
|
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}");
|
||||||
|
|
||||||
// {3}, {tap}: Prevent the next 2 damage that would be dealt to you this turn.
|
// {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.addTarget(new TargetPlayer());
|
||||||
ability.addCost(new TapSourceCost());
|
ability.addCost(new TapSourceCost());
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
|
@ -68,56 +66,3 @@ public class Conservator extends CardImpl {
|
||||||
return new Conservator(this);
|
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 java.util.UUID;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
import mage.abilities.effects.PreventionEffectImpl;
|
import mage.abilities.effects.common.PreventDamageToControllerEffect;
|
||||||
import mage.abilities.keyword.FlyingAbility;
|
import mage.abilities.keyword.FlyingAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.events.GameEvent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -49,7 +46,7 @@ import mage.game.events.GameEvent;
|
||||||
public class DecoratedGriffin extends CardImpl {
|
public class DecoratedGriffin extends CardImpl {
|
||||||
|
|
||||||
public DecoratedGriffin(UUID ownerId, CardSetInfo setInfo) {
|
public DecoratedGriffin(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{4}{W}");
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{W}");
|
||||||
this.subtype.add("Griffin");
|
this.subtype.add("Griffin");
|
||||||
|
|
||||||
this.power = new MageInt(2);
|
this.power = new MageInt(2);
|
||||||
|
@ -57,8 +54,8 @@ public class DecoratedGriffin extends CardImpl {
|
||||||
|
|
||||||
// Flying
|
// Flying
|
||||||
this.addAbility(FlyingAbility.getInstance());
|
this.addAbility(FlyingAbility.getInstance());
|
||||||
// {1}{W}: Prevent the next 1 damage that would be dealt to you this turn.
|
// {1}{W}: Prevent the next 1 combat damage that would be dealt to you this turn.
|
||||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new DecoratedGriffinPreventEffect(), new ManaCostsImpl("{1}{W}")));
|
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new PreventDamageToControllerEffect(Duration.EndOfTurn, true, true, 1), new ManaCostsImpl("{1}{W}")));
|
||||||
}
|
}
|
||||||
|
|
||||||
public DecoratedGriffin(final DecoratedGriffin card) {
|
public DecoratedGriffin(final DecoratedGriffin card) {
|
||||||
|
@ -70,33 +67,3 @@ public class DecoratedGriffin extends CardImpl {
|
||||||
return new DecoratedGriffin(this);
|
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;
|
package mage.cards.d;
|
||||||
|
|
||||||
import java.util.UUID;
|
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.PopulateEffect;
|
||||||
|
import mage.abilities.effects.common.PreventDamageToControllerEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.game.Game;
|
import mage.constants.CardType;
|
||||||
import mage.game.events.DamageEvent;
|
import mage.constants.Duration;
|
||||||
import mage.game.events.GameEvent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -46,12 +42,11 @@ import mage.game.events.GameEvent;
|
||||||
public class DruidsDeliverance extends CardImpl {
|
public class DruidsDeliverance extends CardImpl {
|
||||||
|
|
||||||
public DruidsDeliverance(UUID ownerId, CardSetInfo setInfo) {
|
public DruidsDeliverance(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{G}");
|
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{G}");
|
||||||
|
|
||||||
|
|
||||||
// Prevent all combat damage that would be dealt to you this turn. Populate.
|
// 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.)
|
// (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());
|
this.getSpellAbility().addEffect(new PopulateEffect());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,49 +59,3 @@ public class DruidsDeliverance extends CardImpl {
|
||||||
return new DruidsDeliverance(this);
|
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;
|
package mage.cards.e;
|
||||||
|
|
||||||
import java.util.UUID;
|
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.CardType;
|
||||||
import mage.constants.ColoredManaSymbol;
|
import mage.constants.ColoredManaSymbol;
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
import mage.constants.Zone;
|
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;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,7 +49,7 @@ import mage.target.common.TargetCreaturePermanent;
|
||||||
public class EsperBattlemage extends CardImpl {
|
public class EsperBattlemage extends CardImpl {
|
||||||
|
|
||||||
public EsperBattlemage(UUID ownerId, CardSetInfo setInfo) {
|
public EsperBattlemage(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT,CardType.CREATURE},"{2}{U}");
|
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{2}{U}");
|
||||||
this.subtype.add("Human");
|
this.subtype.add("Human");
|
||||||
this.subtype.add("Wizard");
|
this.subtype.add("Wizard");
|
||||||
|
|
||||||
|
@ -60,7 +57,7 @@ public class EsperBattlemage extends CardImpl {
|
||||||
this.toughness = new MageInt(2);
|
this.toughness = new MageInt(2);
|
||||||
// {W}, {tap}: Prevent the next 2 damage that would be dealt to you this turn.
|
// {W}, {tap}: Prevent the next 2 damage that would be dealt to you this turn.
|
||||||
SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
|
SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
|
||||||
new EsperBattlemageEffect(),
|
new PreventDamageToControllerEffect(Duration.EndOfTurn, 2),
|
||||||
new ColoredManaCost(ColoredManaSymbol.W));
|
new ColoredManaCost(ColoredManaSymbol.W));
|
||||||
ability.addCost(new TapSourceCost());
|
ability.addCost(new TapSourceCost());
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
|
@ -82,56 +79,3 @@ public class EsperBattlemage extends CardImpl {
|
||||||
return new EsperBattlemage(this);
|
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.EntersBattlefieldTriggeredAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.costs.common.PayLifeCost;
|
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.SacrificeControllerEffect;
|
||||||
import mage.abilities.effects.common.combat.CantAttackAnyPlayerAllEffect;
|
import mage.abilities.effects.common.combat.CantAttackAnyPlayerAllEffect;
|
||||||
import mage.abilities.keyword.CumulativeUpkeepAbility;
|
import mage.abilities.keyword.CumulativeUpkeepAbility;
|
||||||
|
@ -63,7 +63,7 @@ public class GlacialChasm extends CardImpl {
|
||||||
filter.add(new ControllerPredicate(TargetController.YOU));
|
filter.add(new ControllerPredicate(TargetController.YOU));
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackAnyPlayerAllEffect(Duration.WhileOnBattlefield, filter)));
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackAnyPlayerAllEffect(Duration.WhileOnBattlefield, filter)));
|
||||||
// Prevent all damage that would be dealt to you.
|
// 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) {
|
public GlacialChasm(final GlacialChasm card) {
|
||||||
|
|
|
@ -28,11 +28,10 @@
|
||||||
package mage.cards.p;
|
package mage.cards.p;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.abilities.Ability;
|
|
||||||
import mage.abilities.common.BecomesTappedTriggeredAbility;
|
import mage.abilities.common.BecomesTappedTriggeredAbility;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
import mage.abilities.costs.common.RemoveCountersSourceCost;
|
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.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
|
@ -43,8 +42,6 @@ import mage.constants.Zone;
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
import mage.filter.common.FilterCreaturePermanent;
|
import mage.filter.common.FilterCreaturePermanent;
|
||||||
import mage.filter.predicate.permanent.ControllerPredicate;
|
import mage.filter.predicate.permanent.ControllerPredicate;
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.events.GameEvent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -59,13 +56,15 @@ public class PalliationAccord extends CardImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PalliationAccord(UUID ownerId, CardSetInfo setInfo) {
|
public PalliationAccord(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{3}{W}{U}");
|
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{W}{U}");
|
||||||
|
|
||||||
// Whenever a creature an opponent controls becomes tapped, put a shield counter on Palliation Accord.
|
// Whenever a creature an opponent controls becomes tapped, put a shield counter on Palliation Accord.
|
||||||
this.addAbility(new BecomesTappedTriggeredAbility(new AddCountersSourceEffect(CounterType.SHIELD.createInstance()), false, filter));
|
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.
|
// 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) {
|
public PalliationAccord(final PalliationAccord card) {
|
||||||
|
@ -77,49 +76,3 @@ public class PalliationAccord extends CardImpl {
|
||||||
return new PalliationAccord(this);
|
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;
|
package mage.cards.r;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.constants.CardType;
|
|
||||||
import mage.constants.Duration;
|
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
import mage.abilities.costs.common.TapSourceCost;
|
import mage.abilities.costs.common.TapSourceCost;
|
||||||
import mage.abilities.effects.PreventionEffectImpl;
|
import mage.abilities.effects.common.PreventDamageToControllerEffect;
|
||||||
import mage.abilities.keyword.DefenderAbility;
|
import mage.abilities.keyword.DefenderAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.game.Game;
|
import mage.constants.CardType;
|
||||||
import mage.game.events.GameEvent;
|
import mage.constants.Duration;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -49,7 +46,7 @@ import mage.game.events.GameEvent;
|
||||||
public class ReinforcedBulwark extends CardImpl {
|
public class ReinforcedBulwark extends CardImpl {
|
||||||
|
|
||||||
public ReinforcedBulwark(UUID ownerId, CardSetInfo setInfo) {
|
public ReinforcedBulwark(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT,CardType.CREATURE},"{3}");
|
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{3}");
|
||||||
this.subtype.add("Wall");
|
this.subtype.add("Wall");
|
||||||
this.power = new MageInt(0);
|
this.power = new MageInt(0);
|
||||||
this.toughness = new MageInt(4);
|
this.toughness = new MageInt(4);
|
||||||
|
@ -57,7 +54,7 @@ public class ReinforcedBulwark extends CardImpl {
|
||||||
// Defender
|
// Defender
|
||||||
this.addAbility(DefenderAbility.getInstance());
|
this.addAbility(DefenderAbility.getInstance());
|
||||||
// {tap}: Prevent the next 1 damage that would be dealt to you this turn.
|
// {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) {
|
public ReinforcedBulwark(final ReinforcedBulwark card) {
|
||||||
|
@ -69,49 +66,3 @@ public class ReinforcedBulwark extends CardImpl {
|
||||||
return new ReinforcedBulwark(this);
|
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.constants.Duration;
|
||||||
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
|
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
|
||||||
import mage.abilities.effects.common.GainLifeEffect;
|
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.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.TargetController;
|
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.
|
// 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 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
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.cards.s;
|
package mage.cards.s;
|
||||||
|
|
||||||
import java.util.UUID;
|
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.Ability;
|
||||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.costs.common.TapSourceCost;
|
import mage.abilities.costs.common.TapSourceCost;
|
||||||
import mage.abilities.effects.PreventionEffectImpl;
|
|
||||||
import mage.abilities.effects.common.AttachEffect;
|
import mage.abilities.effects.common.AttachEffect;
|
||||||
import mage.abilities.effects.common.CreateTokenEffect;
|
import mage.abilities.effects.common.CreateTokenEffect;
|
||||||
|
import mage.abilities.effects.common.PreventDamageToControllerEffect;
|
||||||
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
||||||
import mage.abilities.keyword.EnchantAbility;
|
import mage.abilities.keyword.EnchantAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.game.Game;
|
import mage.constants.AttachmentType;
|
||||||
import mage.game.events.GameEvent;
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.Duration;
|
||||||
|
import mage.constants.Outcome;
|
||||||
|
import mage.constants.Zone;
|
||||||
import mage.game.permanent.token.KnightToken;
|
import mage.game.permanent.token.KnightToken;
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
import mage.target.common.TargetLandPermanent;
|
import mage.target.common.TargetLandPermanent;
|
||||||
|
@ -60,8 +57,8 @@ public class SecurityBlockade extends CardImpl {
|
||||||
|
|
||||||
static final String rule = "Enchanted land has \"{T}: Prevent the next 1 damage that would be dealt to you this turn.\"";
|
static final String rule = "Enchanted land has \"{T}: Prevent the next 1 damage that would be dealt to you this turn.\"";
|
||||||
|
|
||||||
public SecurityBlockade (UUID ownerId, CardSetInfo setInfo) {
|
public SecurityBlockade(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{W}");
|
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}");
|
||||||
this.subtype.add("Aura");
|
this.subtype.add("Aura");
|
||||||
this.color.setWhite(true);
|
this.color.setWhite(true);
|
||||||
|
|
||||||
|
@ -76,11 +73,11 @@ public class SecurityBlockade extends CardImpl {
|
||||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new CreateTokenEffect(new KnightToken())));
|
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."
|
// 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)));
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(ability, AttachmentType.AURA, Duration.WhileOnBattlefield, rule)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public SecurityBlockade (final SecurityBlockade card) {
|
public SecurityBlockade(final SecurityBlockade card) {
|
||||||
super(card);
|
super(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
package mage.cards.s;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.abilities.Ability;
|
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
import mage.abilities.costs.mana.GenericManaCost;
|
import mage.abilities.costs.mana.GenericManaCost;
|
||||||
import mage.abilities.effects.PreventionEffectImpl;
|
import mage.abilities.effects.common.PreventDamageToControllerEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.events.GameEvent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -47,10 +44,10 @@ import mage.game.events.GameEvent;
|
||||||
public class ShieldOfTheAges extends CardImpl {
|
public class ShieldOfTheAges extends CardImpl {
|
||||||
|
|
||||||
public ShieldOfTheAges(UUID ownerId, CardSetInfo setInfo) {
|
public ShieldOfTheAges(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{2}");
|
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}");
|
||||||
|
|
||||||
// {2}: Prevent the next 1 damage that would be dealt to you this turn.
|
// {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) {
|
public ShieldOfTheAges(final ShieldOfTheAges card) {
|
||||||
|
@ -62,49 +59,3 @@ public class ShieldOfTheAges extends CardImpl {
|
||||||
return new ShieldOfTheAges(this);
|
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.BeginningOfUpkeepTriggeredAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.costs.common.DiscardTargetCost;
|
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.SacrificeSourceUnlessPaysEffect;
|
||||||
import mage.abilities.effects.common.SkipDrawStepEffect;
|
import mage.abilities.effects.common.SkipDrawStepEffect;
|
||||||
import mage.abilities.effects.common.continuous.GainAbilityControllerEffect;
|
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())));
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityControllerEffect(ShroudAbility.getInstance())));
|
||||||
|
|
||||||
// Prevent all damage that would be dealt to you.
|
// 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) {
|
public SolitaryConfinement(final SolitaryConfinement card) {
|
||||||
|
|
|
@ -36,7 +36,7 @@ import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.condition.Condition;
|
import mage.abilities.condition.Condition;
|
||||||
import mage.abilities.decorator.ConditionalReplacementEffect;
|
import mage.abilities.decorator.ConditionalReplacementEffect;
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.Effect;
|
||||||
import mage.abilities.effects.common.PreventAllDamageToControllerEffect;
|
import mage.abilities.effects.common.PreventDamageToControllerEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
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.
|
// As long as you control a permanent of each color, prevent all damage that would be dealt to you.
|
||||||
Effect effect = new ConditionalReplacementEffect(
|
Effect effect = new ConditionalReplacementEffect(
|
||||||
new PreventAllDamageToControllerEffect(Duration.WhileOnBattlefield),
|
new PreventDamageToControllerEffect(Duration.WhileOnBattlefield),
|
||||||
SpiritOfResistanceCondition.getInstance());
|
SpiritOfResistanceCondition.getInstance());
|
||||||
effect.setText("As long as you control a permanent of each color, prevent all damage that would be dealt to you.");
|
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));
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
|
||||||
|
|
|
@ -33,7 +33,7 @@ import mage.abilities.TriggeredAbilityImpl;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
import mage.abilities.costs.common.ExileFromTopOfLibraryCost;
|
import mage.abilities.costs.common.ExileFromTopOfLibraryCost;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.effects.PreventionEffectImpl;
|
import mage.abilities.effects.common.PreventDamageToControllerEffect;
|
||||||
import mage.abilities.keyword.CumulativeUpkeepAbility;
|
import mage.abilities.keyword.CumulativeUpkeepAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
|
@ -55,7 +55,7 @@ import mage.players.Player;
|
||||||
public class ThoughtLash extends CardImpl {
|
public class ThoughtLash extends CardImpl {
|
||||||
|
|
||||||
public ThoughtLash(UUID ownerId, CardSetInfo setInfo) {
|
public ThoughtLash(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{U}{U}");
|
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{U}{U}");
|
||||||
|
|
||||||
// Cumulative upkeep - Exile the top card of your library.
|
// Cumulative upkeep - Exile the top card of your library.
|
||||||
this.addAbility(new CumulativeUpkeepAbility(new ExileFromTopOfLibraryCost(1)));
|
this.addAbility(new CumulativeUpkeepAbility(new ExileFromTopOfLibraryCost(1)));
|
||||||
|
@ -64,7 +64,7 @@ public class ThoughtLash extends CardImpl {
|
||||||
this.addAbility(new ThoughtLashTriggeredAbility());
|
this.addAbility(new ThoughtLashTriggeredAbility());
|
||||||
|
|
||||||
// Exile the top card of your library: Prevent the next 1 damage that would be dealt to you this turn.
|
// 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) {
|
public ThoughtLash(final ThoughtLash card) {
|
||||||
|
@ -136,46 +136,3 @@ class ThoughtLashExileLibraryEffect extends OneShotEffect {
|
||||||
return false;
|
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
|
@ -20,26 +20,26 @@
|
||||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.cards.v;
|
package mage.cards.v;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.constants.CardType;
|
|
||||||
import mage.constants.Duration;
|
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
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.abilities.keyword.FlyingAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.Duration;
|
||||||
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
@ -52,13 +52,16 @@ import mage.target.TargetPlayer;
|
||||||
public class VengefulArchon extends CardImpl {
|
public class VengefulArchon extends CardImpl {
|
||||||
|
|
||||||
public VengefulArchon(UUID ownerId, CardSetInfo setInfo) {
|
public VengefulArchon(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{4}{W}{W}{W}");
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{W}{W}{W}");
|
||||||
this.subtype.add("Archon");
|
this.subtype.add("Archon");
|
||||||
|
|
||||||
this.power = new MageInt(7);
|
this.power = new MageInt(7);
|
||||||
this.toughness = new MageInt(7);
|
this.toughness = new MageInt(7);
|
||||||
|
|
||||||
|
// Flying
|
||||||
this.addAbility(FlyingAbility.getInstance());
|
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 ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new VengefulArchonEffect(), new ManaCostsImpl("{X}"));
|
||||||
ability.addTarget(new TargetPlayer());
|
ability.addTarget(new TargetPlayer());
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
|
@ -75,18 +78,15 @@ public class VengefulArchon extends CardImpl {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class VengefulArchonEffect extends PreventionEffectImpl {
|
class VengefulArchonEffect extends PreventDamageToControllerEffect {
|
||||||
|
|
||||||
protected int amount = 0;
|
|
||||||
|
|
||||||
public VengefulArchonEffect() {
|
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";
|
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) {
|
public VengefulArchonEffect(final VengefulArchonEffect effect) {
|
||||||
super(effect);
|
super(effect);
|
||||||
this.amount = effect.amount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -95,46 +95,16 @@ class VengefulArchonEffect extends PreventionEffectImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Ability source, Game game) {
|
protected PreventionEffectData preventDamageAction(GameEvent event, Ability source, Game game) {
|
||||||
super.init(source, game);
|
PreventionEffectData preventionEffectData = super.preventDamageAction(event, source, game);
|
||||||
amount = source.getManaCostsToPay().getX();
|
int damage = preventionEffectData.getPreventedDamage();
|
||||||
}
|
if (damage > 0) {
|
||||||
|
|
||||||
@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)) {
|
|
||||||
Player player = game.getPlayer(source.getFirstTarget());
|
Player player = game.getPlayer(source.getFirstTarget());
|
||||||
if (player != null) {
|
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);
|
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;
|
return preventionEffectData;
|
||||||
}
|
|
||||||
|
|
||||||
@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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
|
@ -20,29 +20,29 @@
|
||||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.abilities.effects;
|
package mage.abilities.effects;
|
||||||
|
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.dynamicvalue.DynamicValue;
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
import mage.constants.EffectType;
|
import mage.constants.EffectType;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.abilities.Ability;
|
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.DamageEvent;
|
import mage.game.events.DamageEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public abstract class PreventionEffectImpl extends ReplacementEffectImpl implements PreventionEffect {
|
public abstract class PreventionEffectImpl extends ReplacementEffectImpl implements PreventionEffect {
|
||||||
|
|
||||||
|
protected DynamicValue amountToPreventDynamic;
|
||||||
protected int amountToPrevent;
|
protected int amountToPrevent;
|
||||||
protected final boolean onlyCombat;
|
protected final boolean onlyCombat;
|
||||||
protected boolean consumable;
|
protected boolean consumable;
|
||||||
|
@ -54,10 +54,25 @@ public abstract class PreventionEffectImpl extends ReplacementEffectImpl impleme
|
||||||
public PreventionEffectImpl(Duration duration, int amountToPrevent, boolean onlyCombat) {
|
public PreventionEffectImpl(Duration duration, int amountToPrevent, boolean onlyCombat) {
|
||||||
this(duration, amountToPrevent, onlyCombat, true);
|
this(duration, amountToPrevent, onlyCombat, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PreventionEffectImpl(Duration duration, int amountToPrevent, boolean onlyCombat, boolean consumable) {
|
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);
|
super(duration, Outcome.PreventDamage);
|
||||||
this.effectType = EffectType.PREVENTION;
|
this.effectType = EffectType.PREVENTION;
|
||||||
this.amountToPrevent = amountToPrevent;
|
this.amountToPrevent = amountToPrevent;
|
||||||
|
this.amountToPreventDynamic = amountToPreventDynamic;
|
||||||
this.onlyCombat = onlyCombat;
|
this.onlyCombat = onlyCombat;
|
||||||
this.consumable = consumable;
|
this.consumable = consumable;
|
||||||
}
|
}
|
||||||
|
@ -65,10 +80,18 @@ public abstract class PreventionEffectImpl extends ReplacementEffectImpl impleme
|
||||||
public PreventionEffectImpl(final PreventionEffectImpl effect) {
|
public PreventionEffectImpl(final PreventionEffectImpl effect) {
|
||||||
super(effect);
|
super(effect);
|
||||||
this.amountToPrevent = effect.amountToPrevent;
|
this.amountToPrevent = effect.amountToPrevent;
|
||||||
|
this.amountToPreventDynamic = effect.amountToPreventDynamic;
|
||||||
this.onlyCombat = effect.onlyCombat;
|
this.onlyCombat = effect.onlyCombat;
|
||||||
this.consumable = effect.consumable;
|
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
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
|
@ -84,11 +107,11 @@ public abstract class PreventionEffectImpl extends ReplacementEffectImpl impleme
|
||||||
}
|
}
|
||||||
if (amountToPrevent == 0) {
|
if (amountToPrevent == 0) {
|
||||||
this.discard();
|
this.discard();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return preventionData;
|
return preventionData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
preventDamageAction(event, source, game);
|
preventDamageAction(event, source, game);
|
||||||
|
@ -109,7 +132,7 @@ public abstract class PreventionEffectImpl extends ReplacementEffectImpl impleme
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
return event.getFlag() && (!onlyCombat || ((DamageEvent)event).isCombatDamage());
|
return event.getFlag() && (!onlyCombat || ((DamageEvent) event).isCombatDamage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,41 +25,48 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.abilities.effects.common;
|
package mage.abilities.effects.common;
|
||||||
|
|
||||||
import mage.constants.Duration;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.dynamicvalue.DynamicValue;
|
||||||
import mage.abilities.effects.PreventionEffectImpl;
|
import mage.abilities.effects.PreventionEffectImpl;
|
||||||
|
import mage.constants.Duration;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
|
||||||
/**
|
public class PreventDamageToControllerEffect extends PreventionEffectImpl {
|
||||||
*
|
|
||||||
* @author LevelX2
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
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) {
|
public PreventDamageToControllerEffect(Duration duration, boolean onlyCombat, boolean consumable, int amountToPrevent) {
|
||||||
super(duration, Integer.MAX_VALUE, false);
|
super(duration, amountToPrevent, onlyCombat, consumable, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PreventDamageToControllerEffect(Duration duration, boolean onlyCombat, boolean consumable, DynamicValue amountToPreventDynamic) {
|
||||||
|
super(duration, 0, onlyCombat, consumable, amountToPreventDynamic);
|
||||||
staticText = setText();
|
staticText = setText();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PreventAllDamageToControllerEffect(final PreventAllDamageToControllerEffect effect) {
|
public PreventDamageToControllerEffect(final PreventDamageToControllerEffect effect) {
|
||||||
super(effect);
|
super(effect);
|
||||||
|
staticText = setText();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PreventAllDamageToControllerEffect copy() {
|
public PreventDamageToControllerEffect copy() {
|
||||||
return new PreventAllDamageToControllerEffect(this);
|
return new PreventDamageToControllerEffect(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (super.applies(event, source, game)) {
|
if (super.applies(event, source, game)) {
|
||||||
if (event.getTargetId().equals(source.getControllerId())){
|
if (event.getTargetId().equals(source.getControllerId())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,9 +75,21 @@ public class PreventAllDamageToControllerEffect extends PreventionEffectImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String setText() {
|
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)) {
|
if (duration.equals(Duration.EndOfTurn)) {
|
||||||
sb.append(" this turn");
|
sb.append(" this turn");
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
Loading…
Reference in a new issue