forked from External/mage
simplify SetBaseToughnessSourceEffect
fix Duration.WhileOnBattlefield -> Duration.Custom in some effects
This commit is contained in:
parent
33a859cb68
commit
ab0abcfd22
5 changed files with 23 additions and 49 deletions
|
|
@ -1,38 +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;
|
||||
|
||||
/**
|
||||
* RENAME
|
||||
*
|
||||
* @author Backfir3, noxx
|
||||
* @author xenohedron
|
||||
*/
|
||||
public class SetBaseToughnessSourceEffect extends ContinuousEffectImpl {
|
||||
|
||||
private final DynamicValue amount;
|
||||
public class SetBaseToughnessSourceEffect extends SetBasePowerToughnessSourceEffect {
|
||||
|
||||
/**
|
||||
* @param amount Toughness to set as a characteristic-defining ability
|
||||
*/
|
||||
public SetBaseToughnessSourceEffect(DynamicValue amount) {
|
||||
super(Duration.EndOfGame, Layer.PTChangingEffects_7, SubLayer.CharacteristicDefining_7a, Outcome.BoostCreature);
|
||||
setCharacterDefining(true);
|
||||
this.amount = amount;
|
||||
super(null, amount, Duration.EndOfGame, SubLayer.CharacteristicDefining_7a);
|
||||
staticText = "{this}'s toughness is equal to the number of " + amount.getMessage();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param amount Toughness to set in layer 7b
|
||||
* @param duration Duration for the effect
|
||||
*/
|
||||
public SetBaseToughnessSourceEffect(int amount, Duration duration) {
|
||||
super(null, StaticValue.get(amount), duration, SubLayer.SetPT_7b);
|
||||
staticText = "{this} has base toughness " + amount + ' ' + duration.toString();
|
||||
}
|
||||
|
||||
protected SetBaseToughnessSourceEffect(final SetBaseToughnessSourceEffect effect) {
|
||||
super(effect);
|
||||
this.amount = effect.amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -40,15 +36,4 @@ public class SetBaseToughnessSourceEffect extends ContinuousEffectImpl {
|
|||
return new SetBaseToughnessSourceEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
MageObject mageObject = game.getObject(source);
|
||||
if (mageObject != null) {
|
||||
int value = amount.calculate(game, source, this);
|
||||
mageObject.getToughness().setModifiedBaseValue(value);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue