forked from External/mage
refactor text gen for PreventDamageByTargetEffect
This commit is contained in:
parent
203feb9ad1
commit
91bf9344e2
7 changed files with 39 additions and 36 deletions
|
|
@ -34,7 +34,7 @@ public final class BorosFuryShield extends CardImpl {
|
|||
// If {R} was spent to cast Boros Fury-Shield, it deals damage to that creature's controller equal to the creature's power.
|
||||
this.getSpellAbility().addEffect(new ConditionalOneShotEffect(
|
||||
new BorosFuryShieldDamageEffect(),
|
||||
ManaWasSpentCondition.RED, "If {R} was spent to cast this spell, it deals damage to that creature's controller equal to the creature's power"));
|
||||
ManaWasSpentCondition.RED, "If {R} was spent to cast this spell, {this} deals damage to that creature's controller equal to the creature's power"));
|
||||
}
|
||||
|
||||
private BorosFuryShield(final BorosFuryShield card) {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,8 @@ public final class DromokasCommand extends CardImpl {
|
|||
this.getSpellAbility().getModes().setMaxModes(2);
|
||||
|
||||
// Prevent all damage target instant or sorcery spell would deal this turn;
|
||||
this.getSpellAbility().getEffects().add(new PreventDamageByTargetEffect(Duration.EndOfTurn, false));
|
||||
this.getSpellAbility().getEffects().add(new PreventDamageByTargetEffect(Duration.EndOfTurn, false)
|
||||
.withTextOptions(false, true));
|
||||
this.getSpellAbility().getTargets().add(new TargetSpell(new FilterInstantOrSorcerySpell()));
|
||||
|
||||
// or Target player sacrifices an enchantment;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,8 @@ public final class ResistanceFighter extends CardImpl {
|
|||
this.toughness = new MageInt(1);
|
||||
|
||||
// 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 ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new PreventDamageByTargetEffect(Duration.EndOfTurn, true)
|
||||
.withTextOptions(false, true), new SacrificeSourceCost());
|
||||
ability.addTarget(new TargetCreaturePermanent());
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,12 +47,16 @@ public final class ShieldmageElder extends CardImpl {
|
|||
this.toughness = new MageInt(3);
|
||||
|
||||
// Tap two untapped Clerics you control: Prevent all damage target creature would deal this turn.
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new PreventDamageByTargetEffect(Duration.EndOfTurn, false), new TapTargetCost(new TargetControlledPermanent(2, 2, filter1, false)));
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
|
||||
new PreventDamageByTargetEffect(Duration.EndOfTurn, false).withTextOptions(false, true),
|
||||
new TapTargetCost(new TargetControlledPermanent(2, 2, filter1, false)));
|
||||
ability.addTarget(new TargetCreaturePermanent());
|
||||
this.addAbility(ability);
|
||||
|
||||
// Tap two untapped Wizards you control: Prevent all damage target spell would deal this turn.
|
||||
Ability ability2 = new SimpleActivatedAbility(Zone.BATTLEFIELD, new PreventDamageByTargetEffect(Duration.EndOfTurn, false), new TapTargetCost(new TargetControlledPermanent(2, 2, filter2, false)));
|
||||
Ability ability2 = new SimpleActivatedAbility(Zone.BATTLEFIELD,
|
||||
new PreventDamageByTargetEffect(Duration.EndOfTurn, false).withTextOptions(false, true),
|
||||
new TapTargetCost(new TargetControlledPermanent(2, 2, filter2, false)));
|
||||
ability2.addTarget(new TargetSpell());
|
||||
this.addAbility(ability2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,8 @@ public final class Songstitcher extends CardImpl {
|
|||
this.toughness = new MageInt(1);
|
||||
|
||||
// {1}{W}: Prevent all combat damage that would be dealt this turn by target attacking creature with flying.
|
||||
Ability ability = new SimpleActivatedAbility(new PreventDamageByTargetEffect(Duration.EndOfTurn, true), new ManaCostsImpl<>("{1}{W}"));
|
||||
Ability ability = new SimpleActivatedAbility(new PreventDamageByTargetEffect(Duration.EndOfTurn, true)
|
||||
.withTextOptions(true, false), new ManaCostsImpl<>("{1}{W}"));
|
||||
ability.addTarget(new TargetCreaturePermanent(filter));
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,14 @@
|
|||
|
||||
|
||||
package mage.cards.s;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.effects.common.PreventDamageByTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.target.Target;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author nantuko
|
||||
|
|
@ -19,13 +17,11 @@ public final class SoulParry extends CardImpl {
|
|||
|
||||
public SoulParry (UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{W}");
|
||||
|
||||
|
||||
// Prevent all damage one or two target creatures would deal this turn
|
||||
Target target = new TargetCreaturePermanent(1,2);
|
||||
target.setTargetName("one or two creatures");
|
||||
this.getSpellAbility().addEffect(new PreventDamageByTargetEffect(Duration.EndOfTurn, false));
|
||||
this.getSpellAbility().addTarget(target);
|
||||
this.getSpellAbility().addEffect(new PreventDamageByTargetEffect(Duration.EndOfTurn, false)
|
||||
.withTextOptions(false, true));
|
||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent(1, 2));
|
||||
}
|
||||
|
||||
private SoulParry(final SoulParry card) {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@ import mage.target.TargetSpell;
|
|||
*/
|
||||
public class PreventDamageByTargetEffect extends PreventionEffectImpl {
|
||||
|
||||
private boolean passiveVoice = true;
|
||||
private boolean durationRuleAtEnd = true;
|
||||
|
||||
public PreventDamageByTargetEffect(Duration duration, boolean onlyCombat) {
|
||||
this(duration, Integer.MAX_VALUE, onlyCombat);
|
||||
}
|
||||
|
|
@ -25,6 +28,8 @@ public class PreventDamageByTargetEffect extends PreventionEffectImpl {
|
|||
|
||||
protected PreventDamageByTargetEffect(final PreventDamageByTargetEffect effect) {
|
||||
super(effect);
|
||||
this.passiveVoice = effect.passiveVoice;
|
||||
this.durationRuleAtEnd = effect.durationRuleAtEnd;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -51,33 +56,28 @@ public class PreventDamageByTargetEffect extends PreventionEffectImpl {
|
|||
return false;
|
||||
}
|
||||
|
||||
public PreventDamageByTargetEffect withTextOptions(boolean passiveVoice, boolean durationRuleAtEnd) {
|
||||
this.passiveVoice = passiveVoice;
|
||||
this.durationRuleAtEnd = durationRuleAtEnd;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (amountToPrevent == Integer.MAX_VALUE) {
|
||||
sb.append("Prevent all");
|
||||
if (onlyCombat) {
|
||||
sb.append(" combat");
|
||||
}
|
||||
sb.append(" damage target ");
|
||||
String durationText = duration == Duration.EndOfTurn ? " this turn" : ' ' + duration.toString();
|
||||
String targetText = getTargetPointer().describeTargets(mode.getTargets(), "it");
|
||||
String preventText = (amountToPrevent == Integer.MAX_VALUE ? "Prevent all" : "Prevent the next" + amountToPrevent)
|
||||
+ (onlyCombat ? " combat damage " : " damage ");
|
||||
if (passiveVoice) {
|
||||
preventText += "that would be dealt" + (durationRuleAtEnd ?
|
||||
" by " + targetText + durationText :
|
||||
durationText + " by " + targetText);
|
||||
} else {
|
||||
sb.append("Prevent the next ");
|
||||
sb.append(amountToPrevent);
|
||||
if (onlyCombat) {
|
||||
sb.append(" combat");
|
||||
}
|
||||
sb.append(" damage that ");
|
||||
preventText += targetText + " would deal" + durationText;
|
||||
}
|
||||
sb.append(mode.getTargets().get(0).getTargetName());
|
||||
sb.append(" would deal ");
|
||||
if (duration == Duration.EndOfTurn) {
|
||||
sb.append("this turn");
|
||||
} else {
|
||||
sb.append(duration);
|
||||
}
|
||||
return sb.toString();
|
||||
return preventText;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue