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

@ -4,6 +4,7 @@ import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.Effects;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.game.Game;
import mage.players.Player;
import mage.target.targetpointer.TargetPointer;
@ -19,15 +20,11 @@ public class OptionalOneShotEffect extends OneShotEffect {
private final Effects effects = new Effects();
public OptionalOneShotEffect(OneShotEffect effect) {
this(effect, null);
}
public OptionalOneShotEffect(OneShotEffect effect, String text) {
super(effect.getOutcome());
if (effect != null) {
this.effects.add(effect);
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.");
}
this.staticText = text;
this.effects.add(effect);
}
protected OptionalOneShotEffect(final OptionalOneShotEffect effect) {
@ -44,7 +41,8 @@ public class OptionalOneShotEffect extends OneShotEffect {
Player player = game.getPlayer(source.getControllerId());
String chooseText = staticText;
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)) {
effects.setTargetPointer(this.getTargetPointer().copy());
@ -75,7 +73,7 @@ public class OptionalOneShotEffect extends OneShotEffect {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
return "You may " + CardUtil.getTextWithFirstCharLowerCase(effects.getText(mode));
return "you may " + CardUtil.getTextWithFirstCharLowerCase(effects.getText(mode));
}
@Override