Better fix with text generation.

This commit is contained in:
Grath 2025-11-08 23:41:50 -05:00
parent df20c64c58
commit 784bea734f
3 changed files with 10 additions and 13 deletions

View file

@ -42,7 +42,7 @@ public final class AzulaRuthlessFirebender extends CardImpl {
this.addAbility(new FirebendingAbility(1)); this.addAbility(new FirebendingAbility(1));
// Whenever Azula attacks, you may discard a card. Then you get an experience counter for each player who discarded a card this turn. // Whenever Azula attacks, you may discard a card. Then you get an experience counter for each player who discarded a card this turn.
Ability ability = new AttacksTriggeredAbility(new OptionalOneShotEffect(new DiscardControllerEffect(1), "You may discard a card")); Ability ability = new AttacksTriggeredAbility(new OptionalOneShotEffect(new DiscardControllerEffect(1)));
ability.addEffect(new AddCountersPlayersEffect(CounterType.EXPERIENCE.createInstance(), AzulaRuthlessFirebenderValue.instance, TargetController.YOU).setText("Then you get an experience counter for each player who discarded a card this turn.")); ability.addEffect(new AddCountersPlayersEffect(CounterType.EXPERIENCE.createInstance(), AzulaRuthlessFirebenderValue.instance, TargetController.YOU).setText("Then you get an experience counter for each player who discarded a card this turn."));
this.addAbility(ability, new DiscardedCardWatcher()); this.addAbility(ability, new DiscardedCardWatcher());

View file

@ -60,8 +60,7 @@ class FirebenderAscensionTriggeredAbility extends TriggeredAbilityImpl {
FirebenderAscensionTriggeredAbility() { FirebenderAscensionTriggeredAbility() {
super(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.QUEST.createInstance(), true), false); super(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.QUEST.createInstance(), true), false);
addEffect(new ConditionalOneShotEffect(new OptionalOneShotEffect(new CopyStackObjectEffect(), addEffect(new ConditionalOneShotEffect(new OptionalOneShotEffect(new CopyStackObjectEffect()), condition,
"You may copy that ability. You may choose new targets for the copy."), condition,
"Then if it has four or more quest counters on it, you may copy that ability. You may choose new targets for the copy.")); "Then if it has four or more quest counters on it, you may copy that ability. You may choose new targets for the copy."));
setTriggerPhrase("Whenever a creature you control attacking causes a triggered ability of that creature to trigger, "); setTriggerPhrase("Whenever a creature you control attacking causes a triggered ability of that creature to trigger, ");
} }

View file

@ -4,6 +4,7 @@ import mage.abilities.Ability;
import mage.abilities.Mode; import mage.abilities.Mode;
import mage.abilities.effects.Effects; import mage.abilities.effects.Effects;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.target.targetpointer.TargetPointer; import mage.target.targetpointer.TargetPointer;
@ -19,16 +20,12 @@ public class OptionalOneShotEffect extends OneShotEffect {
private final Effects effects = new Effects(); private final Effects effects = new Effects();
public OptionalOneShotEffect(OneShotEffect effect) { public OptionalOneShotEffect(OneShotEffect effect) {
this(effect, null); super(effect != null ? effect.getOutcome() : Outcome.Benefit); // must be first line, can't error for null effect here.
if (effect == null) {
throw new IllegalArgumentException("Wrong code usage: OptionalOneShotEffect should start with an effect to generate Outcome.");
} }
public OptionalOneShotEffect(OneShotEffect effect, String text) {
super(effect.getOutcome());
if (effect != null) {
this.effects.add(effect); this.effects.add(effect);
} }
this.staticText = text;
}
protected OptionalOneShotEffect(final OptionalOneShotEffect effect) { protected OptionalOneShotEffect(final OptionalOneShotEffect effect) {
super(effect); super(effect);
@ -44,7 +41,8 @@ public class OptionalOneShotEffect extends OneShotEffect {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
String chooseText = staticText; String chooseText = staticText;
if (chooseText == null || chooseText.isEmpty()) { if (chooseText == null || chooseText.isEmpty()) {
chooseText = getText(new Mode(effects.get(0))); chooseText = getText(source.getModes().getMode());
chooseText = Character.toUpperCase(chooseText.charAt(0)) + chooseText.substring(1);
} }
if (player != null && player.chooseUse(outcome, chooseText, source, game)) { if (player != null && player.chooseUse(outcome, chooseText, source, game)) {
effects.setTargetPointer(this.getTargetPointer().copy()); effects.setTargetPointer(this.getTargetPointer().copy());
@ -75,7 +73,7 @@ public class OptionalOneShotEffect extends OneShotEffect {
if (staticText != null && !staticText.isEmpty()) { if (staticText != null && !staticText.isEmpty()) {
return staticText; return staticText;
} }
return "You may " + CardUtil.getTextWithFirstCharLowerCase(effects.getText(mode)); return "you may " + CardUtil.getTextWithFirstCharLowerCase(effects.getText(mode));
} }
@Override @Override