Fix text generation for default duration rule at end

This commit is contained in:
xenohedron 2023-05-20 20:53:38 -04:00
parent 60e488cf05
commit 70248cdd2b

View file

@ -20,6 +20,7 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl implements
protected boolean loseAbilities; protected boolean loseAbilities;
protected DynamicValue power = null; protected DynamicValue power = null;
protected DynamicValue toughness = null; protected DynamicValue toughness = null;
protected boolean durationRuleAtStart = false; // put duration rule at the start of the rules text rather than the end
public BecomesCreatureSourceEffect(Token token, String theyAreStillType, Duration duration) { public BecomesCreatureSourceEffect(Token token, String theyAreStillType, Duration duration) {
this(token, theyAreStillType, duration, false, false); this(token, theyAreStillType, duration, false, false);
@ -59,6 +60,7 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl implements
if (effect.toughness != null) { if (effect.toughness != null) {
this.toughness = effect.toughness.copy(); this.toughness = effect.toughness.copy();
} }
this.durationRuleAtStart = effect.durationRuleAtStart;
} }
@Override @Override
@ -145,11 +147,22 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl implements
} }
private void setText() { private void setText() {
if (theyAreStillType != null && !theyAreStillType.isEmpty()) { StringBuilder sb = new StringBuilder();
staticText = duration.toString() + ", {this} becomes a " + token.getDescription() + " that's still a " + this.theyAreStillType; if (!duration.toString().isEmpty() && durationRuleAtStart) {
} else { sb.append(duration.toString());
staticText = duration.toString() + ", {this} becomes a " + token.getDescription(); sb.append(", ");
} }
sb.append("{this} becomes a ");
sb.append(token.getDescription());
if (!duration.toString().isEmpty() && !durationRuleAtStart) {
sb.append(" ");
sb.append(duration.toString());
}
if (theyAreStillType != null && !theyAreStillType.isEmpty()) {
sb.append(". It's still a ");
sb.append(theyAreStillType);
}
staticText = sb.toString();
} }
@Override @Override