Update OptionalOneShotEffect with possibly better text generation.

This commit is contained in:
Grath 2025-11-08 23:01:44 -05:00
parent eb69df1623
commit 86d0910e1e

View file

@ -18,6 +18,10 @@ public class OptionalOneShotEffect extends OneShotEffect {
private final Effects effects = new Effects(); private final Effects effects = new Effects();
public OptionalOneShotEffect(OneShotEffect effect) {
this(effect, null);
}
public OptionalOneShotEffect(OneShotEffect effect, String text) { public OptionalOneShotEffect(OneShotEffect effect, String text) {
super(effect.getOutcome()); super(effect.getOutcome());
if (effect != null) { if (effect != null) {
@ -38,7 +42,11 @@ public class OptionalOneShotEffect extends OneShotEffect {
return true; return true;
} }
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (player != null && player.chooseUse(outcome, staticText, source, game)) { String chooseText = staticText;
if (chooseText == null || chooseText.isEmpty()) {
chooseText = getText(new Mode(effects.get(0)));
}
if (player != null && player.chooseUse(outcome, chooseText, source, game)) {
effects.setTargetPointer(this.getTargetPointer().copy()); effects.setTargetPointer(this.getTargetPointer().copy());
effects.forEach(effect -> effect.apply(game, source)); effects.forEach(effect -> effect.apply(game, source));
return true; return true;
@ -67,7 +75,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