forked from External/mage
refactor SavedGainedLifeValue instead of getValue("gainedLife")
This commit is contained in:
parent
53a5f53f78
commit
24b184c28f
16 changed files with 198 additions and 380 deletions
|
|
@ -0,0 +1,45 @@
|
|||
package mage.abilities.dynamicvalue.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Stores gained life value in relevant triggers, to pass down on effects.
|
||||
*
|
||||
* @author Susucr
|
||||
*/
|
||||
public enum SavedGainedLifeValue implements DynamicValue {
|
||||
MANY("many"),
|
||||
MUCH("much");
|
||||
|
||||
private final String message;
|
||||
public static final String VALUE_KEY = "gainedLife";
|
||||
|
||||
SavedGainedLifeValue(String message) {
|
||||
this.message = "that " + message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
return Optional.ofNullable((Integer) effect.getValue(VALUE_KEY)).orElse(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SavedGainedLifeValue copy() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue