mirror of
https://github.com/magefree/mage.git
synced 2026-01-25 20:59:14 -08:00
Some changes to prevention effects.
This commit is contained in:
parent
969aca4b2c
commit
b572e8c7d6
6 changed files with 31 additions and 77 deletions
|
|
@ -29,7 +29,9 @@ package mage.sets.magic2014;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.PreventionEffectImpl;
|
||||
import mage.abilities.effects.common.PreventDamageByTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
|
|
@ -51,8 +53,12 @@ public class PayNoHeed extends CardImpl<PayNoHeed> {
|
|||
this.color.setWhite(true);
|
||||
|
||||
// Prevent all damage a source of your choice would deal this turn.
|
||||
this.getSpellAbility().addEffect(new PayNoHeedEffect());
|
||||
this.getSpellAbility().addTarget(new TargetSource());
|
||||
Effect effect = new PreventDamageByTargetEffect(Duration.EndOfTurn, Integer.MAX_VALUE, false);
|
||||
effect.setText("Prevent all damage a source of your choice would deal this turn");
|
||||
this.getSpellAbility().addEffect(effect);
|
||||
TargetSource targetSource = new TargetSource();
|
||||
targetSource.setRequired(true);
|
||||
this.getSpellAbility().addTarget(targetSource);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -69,7 +75,7 @@ public class PayNoHeed extends CardImpl<PayNoHeed> {
|
|||
class PayNoHeedEffect extends PreventionEffectImpl<PayNoHeedEffect> {
|
||||
|
||||
public PayNoHeedEffect() {
|
||||
super(Duration.EndOfTurn);
|
||||
super(Duration.EndOfTurn, Integer.MAX_VALUE, false);
|
||||
staticText = "Prevent all damage a source of your choice would deal this turn";
|
||||
}
|
||||
|
||||
|
|
@ -87,21 +93,6 @@ class PayNoHeedEffect extends PreventionEffectImpl<PayNoHeedEffect> {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
preventDamage(event, source, event.getSourceId(), game);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void preventDamage(GameEvent event, Ability source, UUID target, Game game) {
|
||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, target, 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, target, source.getSourceId(), source.getControllerId(), damage));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (super.applies(event, source, game)) {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import mage.MageInt;
|
|||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.PayLifeCost;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.PreventDamageSourceEffect;
|
||||
import mage.abilities.effects.common.PreventDamageToSourceEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
|
|
@ -55,7 +55,7 @@ public class EtherealChampion extends CardImpl<EtherealChampion> {
|
|||
this.toughness = new MageInt(4);
|
||||
|
||||
// Pay 1 life: Prevent the next 1 damage that would be dealt to Ethereal Champion this turn.
|
||||
Effect effect = new PreventDamageSourceEffect(Duration.EndOfTurn, 1);
|
||||
Effect effect = new PreventDamageToSourceEffect(Duration.EndOfTurn, 1);
|
||||
effect.setText("Pay 1 life: Prevent the next 1 damage that would be dealt to {source} this turn");
|
||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new PayLifeCost(1)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public class ResistanceFighter extends CardImpl<ResistanceFighter> {
|
|||
|
||||
// Sacrifice Resistance Fighter: Prevent all combat damage target creature would deal this turn.
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new PreventDamageByTargetEffect(Duration.EndOfTurn, true), new SacrificeSourceCost());
|
||||
ability.addTarget(new TargetCreaturePermanent());
|
||||
ability.addTarget(new TargetCreaturePermanent(true));
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue