forked from External/mage
remove unneeded methods from DamageTargetEffect
minor cleanup to Sentinel Tower, Tephraderm (see #11111)
This commit is contained in:
parent
aa1e2342e4
commit
2893fb43fc
3 changed files with 12 additions and 40 deletions
|
|
@ -5,7 +5,7 @@ import mage.MageObjectReference;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SpellCastAllTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.dynamicvalue.common.SavedDamageValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.abilities.hint.ValueHint;
|
||||
|
|
@ -50,7 +50,7 @@ class SentinelTowerTriggeredAbility extends SpellCastAllTriggeredAbility {
|
|||
private String damageInfo;
|
||||
|
||||
SentinelTowerTriggeredAbility() {
|
||||
super(new DamageTargetEffect(0), StaticFilters.FILTER_SPELL_AN_INSTANT_OR_SORCERY, false);
|
||||
super(new DamageTargetEffect(SavedDamageValue.MUCH), StaticFilters.FILTER_SPELL_AN_INSTANT_OR_SORCERY, false);
|
||||
this.addTarget(new TargetAnyTarget());
|
||||
this.addHint(new ValueHint("There were cast instant and sorcery this turn", SentinelTowerSpellsCastValue.instance));
|
||||
this.damageInfo = null;
|
||||
|
|
@ -87,12 +87,7 @@ class SentinelTowerTriggeredAbility extends SpellCastAllTriggeredAbility {
|
|||
}
|
||||
}
|
||||
damageInfo = " (<b>" + damageToDeal + " damage</b>)";
|
||||
for (Effect effect : this.getEffects()) {
|
||||
if (effect instanceof DamageTargetEffect) {
|
||||
((DamageTargetEffect) effect).setAmount(StaticValue.get(damageToDeal));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
this.getEffects().setValue("damage", damageToDeal);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -166,4 +161,4 @@ enum SentinelTowerSpellsCastValue implements DynamicValue {
|
|||
public String getMessage() {
|
||||
return "There was an instant or sorcery spell in this turn";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@ import mage.MageInt;
|
|||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.DealsDamageToThisAllTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.common.SavedDamageValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
|
|
@ -57,7 +55,8 @@ public final class Tephraderm extends CardImpl {
|
|||
class TephradermSpellDamageTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
TephradermSpellDamageTriggeredAbility() {
|
||||
super(Zone.BATTLEFIELD, new DamageTargetEffect(0));
|
||||
super(Zone.BATTLEFIELD, new DamageTargetEffect(SavedDamageValue.MUCH).withTargetDescription("that spell's controller"));
|
||||
setTriggerPhrase("Whenever a spell deals damage to {this}, ");
|
||||
}
|
||||
|
||||
private TephradermSpellDamageTriggeredAbility(final TephradermSpellDamageTriggeredAbility ability) {
|
||||
|
|
@ -74,18 +73,12 @@ class TephradermSpellDamageTriggeredAbility extends TriggeredAbilityImpl {
|
|||
if (!event.getTargetId().equals(this.getSourceId())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
StackObject sourceSpell = game.getStack().getStackObject(event.getSourceId());
|
||||
if (sourceSpell != null && StaticFilters.FILTER_SPELL.match(sourceSpell, getControllerId(), this, game)) {
|
||||
for (Effect effect : getEffects()) {
|
||||
if (effect instanceof DamageTargetEffect) {
|
||||
effect.setTargetPointer(new FixedTarget(sourceSpell.getControllerId()));
|
||||
((DamageTargetEffect) effect).setAmount(StaticValue.get(event.getAmount()));
|
||||
}
|
||||
}
|
||||
this.getEffects().setTargetPointer(new FixedTarget(sourceSpell.getControllerId()));
|
||||
this.getEffects().setValue("damage", event.getAmount());
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -94,8 +87,4 @@ class TephradermSpellDamageTriggeredAbility extends TriggeredAbilityImpl {
|
|||
return new TephradermSpellDamageTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever a spell deals damage to {this}, {this} deals that much damage to that spell's controller.";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ import java.util.UUID;
|
|||
*/
|
||||
public class DamageTargetEffect extends OneShotEffect {
|
||||
|
||||
protected DynamicValue amount;
|
||||
protected boolean preventable;
|
||||
protected String targetDescription;
|
||||
protected String sourceName = "{this}";
|
||||
private final DynamicValue amount;
|
||||
private final boolean preventable;
|
||||
private String targetDescription;
|
||||
private String sourceName = "{this}";
|
||||
|
||||
public DamageTargetEffect(int amount) {
|
||||
this(StaticValue.get(amount), true);
|
||||
|
|
@ -67,18 +67,6 @@ public class DamageTargetEffect extends OneShotEffect {
|
|||
this.targetDescription = targetDescription;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
if (amount instanceof StaticValue) {
|
||||
return amount.calculate(null, null, this);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void setAmount(DynamicValue amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
protected DamageTargetEffect(final DamageTargetEffect effect) {
|
||||
super(effect);
|
||||
this.amount = effect.amount.copy();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue