rework more Prevention Effects involving counters. Implement [PIP] Bloatfly Swarm (#12205)

This commit is contained in:
Susucre 2024-05-23 19:48:44 +02:00 committed by GitHub
parent e3e34dae33
commit bcff245a31
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 545 additions and 189 deletions

View file

@ -0,0 +1,46 @@
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;
/**
* For trigger/prevention effects that save a value of removed counters.
* Retrieve the value in resulting effects without need for custom ones.
*
* @author Susucr
*/
public enum SavedCounterRemovedValue implements DynamicValue {
MANY("many"),
MUCH("much");
private final String message;
public static final String VALUE_KEY = "CounterRemoved";
SavedCounterRemovedValue(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 SavedCounterRemovedValue copy() {
return this;
}
@Override
public String toString() {
return message;
}
@Override
public String getMessage() {
return "";
}
}