mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
simplify ConditionalActivatedAbility constructors more
This commit is contained in:
parent
84dc2a27ab
commit
fe1b01114f
3 changed files with 23 additions and 28 deletions
|
|
@ -12,7 +12,10 @@ import mage.abilities.triggers.BeginningOfDrawTriggeredAbility;
|
|||
import mage.abilities.triggers.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.*;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.TargetController;
|
||||
import mage.counters.CounterType;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
@ -38,9 +41,8 @@ public final class ArmageddonClock extends CardImpl {
|
|||
|
||||
// {4}: Remove a doom counter from Armageddon Clock. Any player may activate this ability but only during any upkeep step.
|
||||
this.addAbility(new ConditionalActivatedAbility(
|
||||
Zone.BATTLEFIELD, new RemoveCounterSourceEffect(CounterType.DOOM.createInstance()), new GenericManaCost(4),
|
||||
condition, "any player may activate this ability but only during any upkeep step"
|
||||
).setMayActivate(TargetController.ANY));
|
||||
new RemoveCounterSourceEffect(CounterType.DOOM.createInstance()), new GenericManaCost(4), condition
|
||||
).withConditionText("any player may activate this ability but only during any upkeep step").setMayActivate(TargetController.ANY));
|
||||
}
|
||||
|
||||
private ArmageddonClock(final ArmageddonClock card) {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ import mage.cards.CardImpl;
|
|||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.target.common.TargetAnyTargetAmount;
|
||||
|
||||
|
|
@ -41,9 +40,8 @@ public final class SkarrganHellkite extends CardImpl {
|
|||
|
||||
// {3}{R}: Skarrgan Hellkite deals 2 damage divided as you choose among one or two targets. Activate this ability only if Skarrgan Hellkite has a +1/+1 counter on it.
|
||||
Ability ability = new ConditionalActivatedAbility(
|
||||
Zone.BATTLEFIELD, new DamageMultiEffect(), new ManaCostsImpl<>("{3}{R}"),
|
||||
condition, "activate only if {this} has a +1/+1 counter on it"
|
||||
);
|
||||
new DamageMultiEffect(), new ManaCostsImpl<>("{3}{R}"), condition
|
||||
).withConditionText("activate only if {this} has a +1/+1 counter on it");
|
||||
ability.addTarget(new TargetAnyTargetAmount(2));
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,27 +18,20 @@ public class ConditionalActivatedAbility extends ActivatedAbilityImpl {
|
|||
|
||||
private static final Effects emptyEffects = new Effects();
|
||||
|
||||
private final String conditionText;
|
||||
private boolean showCondition = true;
|
||||
private String conditionText = null;
|
||||
|
||||
public ConditionalActivatedAbility(Effect effect, Cost cost, Condition condition) {
|
||||
this(Zone.BATTLEFIELD, effect, cost, condition);
|
||||
}
|
||||
|
||||
public ConditionalActivatedAbility(Zone zone, Effect effect, Cost cost, Condition condition) {
|
||||
this(zone, effect, cost, condition, null);
|
||||
}
|
||||
|
||||
public ConditionalActivatedAbility(Zone zone, Effect effect, Cost cost, Condition condition, String conditionText) {
|
||||
super(zone, effect, cost);
|
||||
this.condition = condition;
|
||||
this.conditionText = conditionText;
|
||||
}
|
||||
|
||||
protected ConditionalActivatedAbility(final ConditionalActivatedAbility ability) {
|
||||
super(ability);
|
||||
this.conditionText = ability.conditionText;
|
||||
this.showCondition = ability.showCondition;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -55,7 +48,11 @@ public class ConditionalActivatedAbility extends ActivatedAbilityImpl {
|
|||
}
|
||||
|
||||
public ConditionalActivatedAbility hideCondition() {
|
||||
this.showCondition = false;
|
||||
return withConditionText("");
|
||||
}
|
||||
|
||||
public ConditionalActivatedAbility withConditionText(String conditionText) {
|
||||
this.conditionText = conditionText;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -68,7 +65,6 @@ public class ConditionalActivatedAbility extends ActivatedAbilityImpl {
|
|||
return super.getRule() + ' ' + CardUtil.getTextWithFirstCharUpperCase(conditionText) + '.';
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(super.getRule());
|
||||
if (showCondition) {
|
||||
sb.append(" Activate only ");
|
||||
if (timing == TimingRule.SORCERY) {
|
||||
sb.append("as a sorcery and only ");
|
||||
|
|
@ -79,7 +75,6 @@ public class ConditionalActivatedAbility extends ActivatedAbilityImpl {
|
|||
}
|
||||
sb.append(conditionText);
|
||||
sb.append('.');
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue