cleanup SetBasePowerToughnessSourceEffect usages

This commit is contained in:
xenohedron 2023-08-26 01:22:49 -04:00
parent ab0abcfd22
commit 2eab7836f6
10 changed files with 27 additions and 22 deletions

View file

@ -20,11 +20,11 @@ public class SetBasePowerToughnessSourceEffect extends ContinuousEffectImpl {
private final DynamicValue toughness;
/**
* Note: Need to set text manually if calling this constructor directly.
* <p>
* It is possible to have power or toughness to null, in which case only the other is modified.
* This constructor is called by the other more specific constructors which set text for appropriate usages.
* @param power can be null, if only toughness is to be modified
* @param toughness can be null, if only power is to be modified
*/
public SetBasePowerToughnessSourceEffect(DynamicValue power, DynamicValue toughness, Duration duration, SubLayer subLayer) {
protected SetBasePowerToughnessSourceEffect(DynamicValue power, DynamicValue toughness, Duration duration, SubLayer subLayer) {
super(duration, Layer.PTChangingEffects_7, subLayer, Outcome.BoostCreature);
setCharacterDefining(subLayer == SubLayer.CharacteristicDefining_7a);
this.power = power;
@ -39,6 +39,19 @@ public class SetBasePowerToughnessSourceEffect extends ContinuousEffectImpl {
this.staticText = "{this}'s power and toughness are each equal to the number of " + amount.getMessage();
}
/**
* @param amount Power and toughness to set in layer 7b
* @param duration Duration for the effect
*/
public SetBasePowerToughnessSourceEffect(DynamicValue amount, Duration duration) {
this(amount, amount, duration, SubLayer.SetPT_7b);
if (duration.toString().isEmpty()) {
staticText = "{this}'s power and toughness are each equal to the number of " + amount.getMessage();
} else {
staticText = "{this} has base power and toughness each equal to the number of " + amount.getMessage() + " " + duration;
}
}
public SetBasePowerToughnessSourceEffect(int power, int toughness, Duration duration) {
this(StaticValue.get(power), StaticValue.get(toughness), duration, SubLayer.SetPT_7b);
this.staticText = "{this} has base power and toughness " + power + '/' + toughness + ' ' + duration.toString();