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

@ -4,9 +4,8 @@ import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.SetBasePowerToughnessSourceEffect;
import mage.abilities.effects.common.continuous.SetBasePowerSourceEffect;
import mage.abilities.keyword.BoastAbility;
import mage.abilities.keyword.HasteAbility;
import mage.cards.CardImpl;
@ -88,7 +87,7 @@ class ArniBrokenbrowEffect extends OneShotEffect {
if (controller.chooseUse(outcome, "Change base power of " + mageObject.getLogName() + " to "
+ power + " until end of turn?", source, game
)) {
game.addEffect(new SetBasePowerToughnessSourceEffect(StaticValue.get(power), null, Duration.EndOfTurn, SubLayer.SetPT_7b), source);
game.addEffect(new SetBasePowerSourceEffect(power, Duration.EndOfTurn), source);
return true;
}
return false;

View file

@ -8,9 +8,8 @@ import mage.abilities.condition.common.FormidableCondition;
import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.continuous.SetBasePowerToughnessSourceEffect;
import mage.abilities.effects.common.continuous.SetBasePowerSourceEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
@ -41,8 +40,7 @@ public final class CraterElemental extends CardImpl {
// <i>Formidable</i> &mdash; {2}{R}: Crater Elemental has base power 8 until end of turn. Activate this ability only if creatures you control have total power 8 or greater.
ability = new ActivateIfConditionActivatedAbility(
Zone.BATTLEFIELD,
new SetBasePowerToughnessSourceEffect(StaticValue.get(8), null, Duration.EndOfTurn, SubLayer.SetPT_7b)
.setText("{this} has base power 8 until end of turn"),
new SetBasePowerSourceEffect(8, Duration.EndOfTurn),
new ManaCostsImpl<>("{2}{R}"),
FormidableCondition.instance
);

View file

@ -1,28 +1,22 @@
package mage.cards.e;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.SetBasePowerToughnessSourceEffect;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.abilities.effects.common.continuous.SetBasePowerSourceEffect;
import mage.abilities.keyword.LifelinkAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import java.util.UUID;
/**
*
* @author TheElk801
@ -88,7 +82,7 @@ class EvraHalcyonWitnessEffect extends OneShotEffect {
// For example, say Evra is enchanted with Dub (which makes it 6/6) and your life total is 7.
// After the exchange, Evra would be a 9/6 creature (its power became 7, which was then modified by Dub) and your life total would be 6.
// (2018-04-27)
game.addEffect(new SetBasePowerToughnessSourceEffect(StaticValue.get(life), null, Duration.Custom, SubLayer.SetPT_7b), source);
game.addEffect(new SetBasePowerSourceEffect(life, Duration.Custom), source);
return true;
}
}

View file

@ -1,25 +1,23 @@
package mage.cards.r;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.SetBasePowerToughnessSourceEffect;
import mage.constants.SubType;
import mage.abilities.effects.common.continuous.SetBasePowerSourceEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.SubType;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
*
* @author TheElk801
@ -71,7 +69,7 @@ class RiptideManglerEffect extends OneShotEffect {
if (permanent == null) {
return false;
}
game.addEffect(new SetBasePowerToughnessSourceEffect(StaticValue.get(permanent.getPower().getValue()), null, Duration.WhileOnBattlefield, SubLayer.SetPT_7b), source);
game.addEffect(new SetBasePowerSourceEffect(permanent.getPower().getValue(), Duration.WhileOnBattlefield), source);
return true;
}
}

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;
}
}