simplify SetBasePowerSourceEffect

This commit is contained in:
xenohedron 2023-08-26 01:01:48 -04:00
parent c84fbfd00e
commit 33a859cb68
5 changed files with 27 additions and 51 deletions

View file

@ -1,36 +1,34 @@
package mage.abilities.effects.common.continuous;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.game.Game;
/**
* @author LevelX2
* @author xenohedron
*/
public class SetBasePowerSourceEffect extends ContinuousEffectImpl {
private final DynamicValue amount;
public class SetBasePowerSourceEffect extends SetBasePowerToughnessSourceEffect {
/**
* @param amount Power to set as a characteristic-defining ability
*/
public SetBasePowerSourceEffect(DynamicValue amount) {
super(Duration.EndOfGame, Layer.PTChangingEffects_7, SubLayer.CharacteristicDefining_7a, Outcome.BoostCreature);
setCharacterDefining(true);
this.amount = amount;
super(amount, null, Duration.EndOfGame, SubLayer.CharacteristicDefining_7a);
staticText = "{this}'s power is equal to the number of " + amount.getMessage();
}
/**
* @param amount Power to set in layer 7b
* @param duration Duration for the effect
*/
public SetBasePowerSourceEffect(int amount, Duration duration) {
super(StaticValue.get(amount), null, duration, SubLayer.SetPT_7b);
staticText = "{this} has base power " + amount + ' ' + duration.toString();
}
protected SetBasePowerSourceEffect(final SetBasePowerSourceEffect effect) {
super(effect);
this.amount = effect.amount;
}
@Override
@ -38,15 +36,4 @@ public class SetBasePowerSourceEffect extends ContinuousEffectImpl {
return new SetBasePowerSourceEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
MageObject mageObject = game.getObject(source);
if (mageObject == null) {
return false;
}
int value = amount.calculate(game, source, this);
mageObject.getPower().setModifiedBaseValue(value);
return true;
}
}